From: charles Date: Wed, 8 Mar 2006 07:59:20 +0000 (+0000) Subject: Flush entire cache at umount X-Git-Tag: pre-name-change~364 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=751cba724040d777d1768dd5d4997039962d2608 Flush entire cache at umount --- diff --git a/direct/dtest.c b/direct/dtest.c index 8edd85f..45bd9a9 100644 --- a/direct/dtest.c +++ b/direct/dtest.c @@ -248,6 +248,35 @@ void yaffs_backward_scan_test(const char *path) yaffs_mount(path); } +char xxzz[2000]; + + +void yaffs_device_flush_test(const char *path) +{ + char fn[100]; + int h; + int i; + + yaffs_StartUp(); + + yaffs_mount(path); + + do_some_file_stuff(path); + + // Open and add some data to a few files + for(i = 0; i < 10; i++) { + + sprintf(fn,"%s/ff%d",path,i); + + h = yaffs_open(fn, O_CREAT | O_RDWR | O_TRUNC, S_IWRITE | S_IREAD); + yaffs_write(h,xxzz,2000); + yaffs_write(h,xxzz,2000); + } + yaffs_unmount(path); + + yaffs_mount(path); +} + void short_scan_test(const char *path, int fsize, int niterations) @@ -1658,7 +1687,9 @@ int main(int argc, char *argv[]) //huge_directory_test_on_path("/ram2k"); - //yaffs_backward_scan_test("/flash") ; + //yaffs_backward_scan_test("/flash/flash"); + yaffs_device_flush_test("/flash/flash"); + //scan_pattern_test("/flash",10000,10); //short_scan_test("/flash",40000,200); @@ -1672,7 +1703,7 @@ int main(int argc, char *argv[]) //lookup_test("/flash"); //freespace_test("/flash/flash"); - link_test("/flash/flash"); + //link_test("/flash/flash"); diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index 0638c80..b395247 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -25,7 +25,7 @@ #endif -const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.9 2006-03-01 08:18:09 charles Exp $"; +const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.10 2006-03-08 07:59:20 charles Exp $"; // configurationList is the list of devices that are supported static yaffsfs_DeviceConfiguration *yaffsfs_configurationList; @@ -1076,6 +1076,9 @@ int yaffs_unmount(const char *path) { int i; int inUse; + + yaffs_FlushEntireDeviceCache(dev); + for(i = inUse = 0; i < YAFFSFS_N_HANDLES && !inUse; i++) { if(yaffsfs_handle[i].inUse && yaffsfs_handle[i].obj->myDev == dev) diff --git a/yaffs_fs.c b/yaffs_fs.c index 101cecf..fd5e23f 100644 --- a/yaffs_fs.c +++ b/yaffs_fs.c @@ -31,7 +31,7 @@ */ const char *yaffs_fs_c_version = - "$Id: yaffs_fs.c,v 1.42 2006-02-08 07:52:51 charles Exp $"; + "$Id: yaffs_fs.c,v 1.43 2006-03-08 07:59:20 charles Exp $"; extern const char *yaffs_guts_c_version; #include @@ -1278,6 +1278,9 @@ static void yaffs_put_super(struct super_block *sb) yaffs_Device *dev = yaffs_SuperToDevice(sb); yaffs_GrossLock(dev); + + yaffs_FlushEntireDeviceCache(dev); + if (dev->putSuperFunc) { dev->putSuperFunc(sb); } diff --git a/yaffs_guts.c b/yaffs_guts.c index ca1dd6a..e8873e1 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -13,7 +13,7 @@ */ const char *yaffs_guts_c_version = - "$Id: yaffs_guts.c,v 1.30 2006-03-01 08:14:32 charles Exp $"; + "$Id: yaffs_guts.c,v 1.31 2006-03-08 07:59:20 charles Exp $"; #include "yportenv.h" @@ -3037,6 +3037,36 @@ static void yaffs_FlushFilesChunkCache(yaffs_Object * obj) } +/*yaffs_FlushEntireDeviceCache(dev) + * + * + */ + +void yaffs_FlushEntireDeviceCache(yaffs_Device *dev) +{ + yaffs_Object *obj; + int nCaches = dev->nShortOpCaches; + int i; + + /* Find a dirty object in the cache and flush it... + * until there are no further dirty objects. + */ + do { + obj = NULL; + for( i = 0; i < nCaches && !obj; i++) { + if (dev->srCache[i].object && + dev->srCache[i].dirty) + obj = dev->srCache[i].object; + + } + if(obj) + yaffs_FlushFilesChunkCache(obj); + + } while(obj); + +} + + /* Grab us a cache chunk for use. * First look for an empty one. * Then look for the least recently used non-dirty one. diff --git a/yaffs_guts.h b/yaffs_guts.h index b1e9374..aaeda26 100644 --- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -14,7 +14,7 @@ * * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL. * - * $Id: yaffs_guts.h,v 1.19 2006-03-01 08:15:45 charles Exp $ + * $Id: yaffs_guts.h,v 1.20 2006-03-08 07:59:20 charles Exp $ */ #ifndef __YAFFS_GUTS_H__ @@ -675,6 +675,8 @@ static Y_INLINE yaffs_BlockInfo *yaffs_GetBlockInfo(yaffs_Device * dev, int blk) int yaffs_GutsInitialise(yaffs_Device * dev); void yaffs_Deinitialise(yaffs_Device * dev); +void yaffs_FlushEntireDeviceCache(yaffs_Device *dev); + int yaffs_GetNumberOfFreeChunks(yaffs_Device * dev); int yaffs_RenameObject(yaffs_Object * oldDir, const YCHAR * oldName,