Unionfs: remove whiteout of opened but unlinked file from readonly branch
authorErez Zadok <ezk@cs.sunysb.edu>
Wed, 30 Mar 2011 23:23:53 +0000 (19:23 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Wed, 30 Mar 2011 23:23:53 +0000 (19:23 -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 c5eea2e9c231e58f27c6ea18cd7b7f2b72c51b69..1905a328139e56b0dc10da553ed05f060bd038be 100644 (file)
@@ -973,6 +973,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;
+               }
        }
 
        /*