Unionfs: remove whiteout of opened but unlinked file from readonly branch
authorErez Zadok <ezk@cs.sunysb.edu>
Sat, 30 Apr 2011 05:33:55 +0000 (01:33 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Fri, 12 Aug 2011 02:39:30 +0000 (22:39 -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 0a27fab5e9f350945fc036bfaf39da0d9033372f..24243adbe61affefabe28b23da35d8a6ece5cea6 100644 (file)
@@ -976,6 +976,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;
+               }
        }
 
        /*