Unionfs: remove whiteout of opened but unlinked file from readonly branch
authorErez Zadok <ezk@cs.sunysb.edu>
Tue, 6 Sep 2011 04:02:27 +0000 (00:02 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Fri, 20 Jun 2014 00:42:14 +0000 (20:42 -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 ee655412dc55fbb1313c74d51d00bf52ac9ef6b7..d04f3a225d44cf7b969a0b9bf6ae37da77f7514b 100644 (file)
@@ -962,6 +962,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;
+               }
        }
 
        /*