Mercurial > yaffs-ecoscentric
changeset 127:89a8d2461783
Flush entire cache at umount
| author | charles |
|---|---|
| date | Wed, 08 Mar 2006 07:59:20 +0000 |
| parents | 41fbe6d74849 |
| children | 4b1283b56e5a |
| files | direct/dtest.c direct/yaffsfs.c yaffs_fs.c yaffs_guts.c yaffs_guts.h |
| diffstat | 5 files changed, 71 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/direct/dtest.c +++ b/direct/dtest.c @@ -248,6 +248,35 @@ void yaffs_backward_scan_test(const char 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");
--- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -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)
--- a/yaffs_fs.c +++ b/yaffs_fs.c @@ -1278,6 +1278,9 @@ static void yaffs_put_super(struct super yaffs_Device *dev = yaffs_SuperToDevice(sb); yaffs_GrossLock(dev); + + yaffs_FlushEntireDeviceCache(dev); + if (dev->putSuperFunc) { dev->putSuperFunc(sb); }
--- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -3037,6 +3037,36 @@ static void yaffs_FlushFilesChunkCache(y } +/*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.
--- a/yaffs_guts.h +++ b/yaffs_guts.h @@ -675,6 +675,8 @@ static Y_INLINE yaffs_BlockInfo *yaffs_G 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,
