Unionfs: cleanup lower inodes after successful unlink
authorErez Zadok <ezk@cs.sunysb.edu>
Thu, 10 Jan 2008 12:12:09 +0000 (07:12 -0500)
committerRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Thu, 1 May 2008 23:03:32 +0000 (19:03 -0400)
fs/unionfs/unlink.c

index f16d32cf553fb57be9144d1550b57b248f9eb3f3..ce7891e530f6e6f584aeb15751382661dd34cc1b 100644 (file)
@@ -101,7 +101,9 @@ out:
 int unionfs_unlink(struct inode *dir, struct dentry *dentry)
 {
        int err = 0;
+       struct inode *inode = dentry->d_inode;
 
+       BUG_ON(S_ISDIR(inode->i_mode));
        unionfs_read_lock(dentry->d_sb, UNIONFS_SMUTEX_CHILD);
        unionfs_lock_dentry(dentry, UNIONFS_DMUTEX_CHILD);
 
@@ -125,8 +127,13 @@ int unionfs_unlink(struct inode *dir, struct dentry *dentry)
                err = odf_remove(dentry, ODF_RMV_NOTWH);
        }
        if (!err) {
-               if (!S_ISDIR(dentry->d_inode->i_mode))
-                       unionfs_postcopyup_release(dentry);
+               unionfs_postcopyup_release(dentry);
+               if (inode->i_nlink == 0) {
+                       /* drop lower inodes */
+                       iput(unionfs_lower_inode(inode));
+                       unionfs_set_lower_inode(inode, NULL);
+                       ibstart(inode) = ibend(inode) = -1;
+               }
                d_drop(dentry);
        }