Unionfs: remove whiteout of opened but unlinked file from readonly branch
authorErez Zadok <ezk@cs.sunysb.edu>
Tue, 6 Sep 2011 01:20:36 +0000 (21:20 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Tue, 6 Sep 2011 01:20:36 +0000 (21:20 -0400)
If we unlink an opened file in a readonly branch, then we create a whiteout.
But then if if ftruncate it, we copyup a zero-length file.  So we have to
delete the whiteout.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/inode.c

index 449d9db360286512452db89996be8ea26248548e..eb03b9b1c333a0a6a6fb3f5a2c1292ce87601b2c 100644 (file)
@@ -968,6 +968,16 @@ static int unionfs_setattr(struct dentry *dentry, struct iattr *ia)
                /* get updated lower_dentry/inode after copyup */
                lower_dentry = unionfs_lower_dentry(dentry);
                lower_inode = unionfs_lower_inode(inode);
+               /*
+                * check for whiteouts in writeable branch, and remove them
+                * if necessary.
+                */
+               if (lower_dentry) {
+                       err = check_unlink_whiteout(dentry, lower_dentry,
+                                                   bindex);
+                       if (err > 0) /* ignore if whiteout found and removed */
+                               err = 0;
+               }
        }
 
        /*