*** empty log message ***
[yaffs/.git] / yaffs_fs.c
index 099a1083122eb1ff1f1cccc3c9fea0a4c2e84260..00bb742cf4aff519208c626eab8a167cf458b33b 100644 (file)
  * * Nick Bane for numerous patches.
  * * Nick Bane for 2.5/2.6 integration.
  * * Andras Toth for mknod rdev issue.
+ * * Michael Fischer for finding the problem with inode inconsistency.
  * * Some code bodily lifted from JFFS2.
  */
 
 
-const char *yaffs_fs_c_version = "$Id: yaffs_fs.c,v 1.34 2004-09-20 22:00:20 charles Exp $";
+const char *yaffs_fs_c_version = "$Id: yaffs_fs.c,v 1.35 2004-10-20 20:12:43 charles Exp $";
 extern const char *yaffs_guts_c_version;
 
 
@@ -364,15 +365,29 @@ static void yaffs_put_inode(struct inode *inode)
 // clear is called to tell the fs to release any per-inode data it holds
 static void yaffs_clear_inode(struct inode *inode)
 {
-       yaffs_Object *obj = yaffs_InodeToObject(inode);
+       yaffs_Object *obj;
+       yaffs_Device *dev;
+       
+       obj = yaffs_InodeToObject(inode);
        
        T(YAFFS_TRACE_OS,("yaffs_clear_inode: ino %d, count %d %s\n",(int)inode->i_ino, atomic_read(&inode->i_count),
                obj ? "object exists" : "null object"));        
 
        if(obj)
        {
+               dev = obj->myDev;
+               yaffs_GrossLock(dev);
+               
+               // Clear the association between the inode ant the yaffs_Object.
                obj->myInode = NULL;
-               inode->u.generic_ip = NULL;     
+               inode->u.generic_ip = NULL;
+               
+               // If the object freeing was deferred, then the real free happens now.
+               // This should fix the inode inconsistency problem.
+               
+               yaffs_HandleDeferedFree(obj);
+               
+               yaffs_GrossUnlock(dev);
        }