From: charles Date: Wed, 23 Sep 2009 23:24:55 +0000 (+0000) Subject: Improve sync to flush metadata X-Git-Tag: pre-name-change~196 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=3e61039bf6fc5a2f8af6a5cdd29e30b3fa10b4f5;hp=095fa307f5d9089421e4173e7641df3854cebeed Improve sync to flush metadata --- diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index 3be1ea7..1da4d05 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -24,7 +24,7 @@ #endif -const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.25 2009-03-05 01:47:17 charles Exp $"; +const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.26 2009-09-23 23:24:55 charles Exp $"; // configurationList is the list of devices that are supported static yaffsfs_DeviceConfiguration *yaffsfs_configurationList; @@ -587,7 +587,7 @@ int yaffs_open(const YCHAR *path, int oflag, int mode) 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,mode_t mode) { obj->yst_mode = mode; obj->dirty = 1; - result = yaffs_FlushFile(obj,0); + result = yaffs_FlushFile(obj,0,0); } return result == YAFFS_OK ? 0 : -1; diff --git a/direct/yaffsfs.h b/direct/yaffsfs.h index c05e02a..7cb8453 100644 --- 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); diff --git a/yaffs_fs.c b/yaffs_fs.c index 855a639..3fd94df 100644 --- a/yaffs_fs.c +++ b/yaffs_fs.c @@ -32,7 +32,7 @@ */ const char *yaffs_fs_c_version = - "$Id: yaffs_fs.c,v 1.82 2009-09-18 00:39:21 charles Exp $"; + "$Id: yaffs_fs.c,v 1.83 2009-09-23 23:24:55 charles Exp $"; extern const char *yaffs_guts_c_version; #include @@ -589,7 +589,7 @@ static int yaffs_file_flush(struct file *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 *file, struct dentry *dentry, 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_block *sb, struct statfs *buf) } + +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_block *sb) if (dev) { yaffs_FlushEntireDeviceCache(dev); + yaffs_flush_sb_inodes(sb); yaffs_CheckpointSave(dev); } diff --git a/yaffs_guts.c b/yaffs_guts.c index 2acfb8e..2b9bf7b 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -12,7 +12,7 @@ */ const char *yaffs_guts_c_version = - "$Id: yaffs_guts.c,v 1.89 2009-09-09 00:56:53 charles Exp $"; + "$Id: yaffs_guts.c,v 1.90 2009-09-23 23:24:55 charles Exp $"; #include "yportenv.h" @@ -5060,23 +5060,27 @@ loff_t yaffs_GetFileSize(yaffs_Object *obj) -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; } diff --git a/yaffs_guts.h b/yaffs_guts.h index a3b1102..cb8d8ec 100644 --- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -840,7 +840,8 @@ int yaffs_ResizeFile(yaffs_Object *obj, loff_t newSize); 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);