Flush entire cache at umount
authorcharles <charles>
Wed, 8 Mar 2006 07:59:20 +0000 (07:59 +0000)
committercharles <charles>
Wed, 8 Mar 2006 07:59:20 +0000 (07:59 +0000)
direct/dtest.c
direct/yaffsfs.c
yaffs_fs.c
yaffs_guts.c
yaffs_guts.h

index 8edd85f68883a0e163dfcd38436f5f95db98be13..45bd9a9cab5430439f0cae0c60ee66d6c68ea553 100644 (file)
@@ -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");
        
        
        
index 0638c80b4af0423af184291efa4e43ff68c51e34..b39524719491d87469cdb198a0c6f0e40896690a 100644 (file)
@@ -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)
index 101cecf1c62e3729fdade0f99b8ce1dc5708c739..fd5e23f26b557596959313889a3142a263e0b0f6 100644 (file)
@@ -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 <linux/config.h>
@@ -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);
        }
index ca1dd6a4c88f751e32ccef3e8490fc4bca107958..e8873e1debfd176641816a23490676e9eafddbec 100644 (file)
@@ -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.
index b1e9374b1845d94b595ffb242841a19d2e9834ac..aaeda26e1c29703f36dee9560b0d647c0a890766 100644 (file)
@@ -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,