Mercurial > yaffs-ecoscentric
changeset 308:63d50ebbae7d
Improve sync to flush metadata
| author | charles |
|---|---|
| date | Thu, 24 Sep 2009 00:24:55 +0100 |
| parents | b6d23e273df3 |
| children | b21bd2a64496 |
| files | direct/yaffsfs.c direct/yaffsfs.h yaffs_fs.c yaffs_guts.c yaffs_guts.h |
| diffstat | 5 files changed, 48 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -587,7 +587,7 @@ int yaffs_open(const YCHAR *path, int of return handle; } -int yaffs_flush(int fd) +int yaffs_Dofsync(int fd,int datasync) { yaffsfs_Handle *h = NULL; int retVal = 0; @@ -599,7 +599,7 @@ int yaffs_flush(int fd) if(h && h->inUse) { // flush the file - yaffs_FlushFile(h->obj,1); + yaffs_FlushFile(h->obj,1,datasync); } else { @@ -613,6 +613,15 @@ int yaffs_flush(int fd) return retVal; } +int yaffs_fsync(int fd) +{ + return yaffs_Dofsync(fd,0); +} + +int yaffs_fdatasync(int fd) +{ + return yaffs_Dofsync(fd,1); +} int yaffs_close(int fd) { @@ -626,7 +635,7 @@ int yaffs_close(int fd) if(h && h->inUse) { // clean up - yaffs_FlushFile(h->obj,1); + yaffs_FlushFile(h->obj,1,0); h->obj->inUse--; if(h->obj->inUse <= 0 && h->obj->unlinked) { @@ -1265,7 +1274,7 @@ int yaffs_set_wince_times(int fd, } obj->dirty = 1; - result = yaffs_FlushFile(obj,0); + result = yaffs_FlushFile(obj,0,0); retVal = 0; } else @@ -1295,7 +1304,7 @@ static int yaffsfs_DoChMod(yaffs_Object { obj->yst_mode = mode; obj->dirty = 1; - result = yaffs_FlushFile(obj,0); + result = yaffs_FlushFile(obj,0,0); } return result == YAFFS_OK ? 0 : -1;
--- a/direct/yaffsfs.h +++ b/direct/yaffsfs.h @@ -216,7 +216,9 @@ struct yaffs_stat{ int yaffs_open(const YCHAR *path, int oflag, int mode) ; int yaffs_close(int fd) ; -int yaffs_flush(int fd) ; +int yaffs_fsync(int fd) ; +int yaffs_fdatasync(int fd) ; +int yaffs_flush(int fd) ; /* same as yaffs_fsync() */ int yaffs_access(const YCHAR *path, int amode);
--- a/yaffs_fs.c +++ b/yaffs_fs.c @@ -589,7 +589,7 @@ static int yaffs_file_flush(struct file yaffs_GrossLock(dev); - yaffs_FlushFile(obj, 1); + yaffs_FlushFile(obj, 1,0); yaffs_GrossUnlock(dev); @@ -1438,7 +1438,7 @@ static int yaffs_sync_object(struct file T(YAFFS_TRACE_OS, ("yaffs_sync_object\n")); yaffs_GrossLock(dev); - yaffs_FlushFile(obj, 1); + yaffs_FlushFile(obj, 1, datasync); yaffs_GrossUnlock(dev); return 0; } @@ -1596,6 +1596,21 @@ static int yaffs_statfs(struct super_blo } + +static void yaffs_flush_sb_inodes(struct super_block *sb) +{ + struct inode *iptr; + yaffs_Object *obj; + + list_for_each_entry(iptr,&sb->s_inodes, i_sb_list){ + obj = yaffs_InodeToObject(iptr); + if(obj){ + T(YAFFS_TRACE_OS, ("flushing obj %d\n",obj->objectId)); + yaffs_FlushFile(obj,1,0); + } + } +} + static int yaffs_do_sync_fs(struct super_block *sb) { @@ -1607,6 +1622,7 @@ static int yaffs_do_sync_fs(struct super if (dev) { yaffs_FlushEntireDeviceCache(dev); + yaffs_flush_sb_inodes(sb); yaffs_CheckpointSave(dev); }
--- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -5060,23 +5060,27 @@ loff_t yaffs_GetFileSize(yaffs_Object *o -int yaffs_FlushFile(yaffs_Object *in, int updateTime) +int yaffs_FlushFile(yaffs_Object *in, int updateTime, int dataSync) { int retVal; if (in->dirty) { yaffs_FlushFilesChunkCache(in); - if (updateTime) { + if(dataSync) /* Only sync data */ + retVal=YAFFS_OK; + else { + if (updateTime) { #ifdef CONFIG_YAFFS_WINCE - yfsd_WinFileTimeNow(in->win_mtime); + yfsd_WinFileTimeNow(in->win_mtime); #else - in->yst_mtime = Y_CURRENT_TIME; + in->yst_mtime = Y_CURRENT_TIME; #endif + } + + retVal = (yaffs_UpdateObjectHeader(in, NULL, 0, 0, 0) >= + 0) ? YAFFS_OK : YAFFS_FAIL; } - - retVal = (yaffs_UpdateObjectHeader(in, NULL, 0, 0, 0) >= - 0) ? YAFFS_OK : YAFFS_FAIL; } else { retVal = YAFFS_OK; }
--- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -840,7 +840,8 @@ int yaffs_ResizeFile(yaffs_Object *obj, yaffs_Object *yaffs_MknodFile(yaffs_Object *parent, const YCHAR *name, __u32 mode, __u32 uid, __u32 gid); -int yaffs_FlushFile(yaffs_Object *obj, int updateTime); + +int yaffs_FlushFile(yaffs_Object *obj, int updateTime, int dataSync); /* Flushing and checkpointing */ void yaffs_FlushEntireDeviceCache(yaffs_Device *dev);
