Unionfs: handle partial copyup errors gracefully
authorErez Zadok <ezk@cs.sunysb.edu>
Fri, 7 Nov 2008 21:51:13 +0000 (16:51 -0500)
committerErez Zadok <ezk@cs.sunysb.edu>
Fri, 22 Nov 2013 23:56:12 +0000 (18:56 -0500)
Don't leave any dentries behind if copying up the inode (or setting its
permission, i.e., using TOMOYO) failed.

CC: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/copyup.c

index ae6ea2bea30e7cd581330c381ec71b9cc042e456..3b1ab73704b3dd015a9e1091532ad8e9edc3d5d5 100644 (file)
@@ -518,8 +518,17 @@ out_free:
                dput(old_lower_dentry);
        kfree(symbuf);
 
-       if (err)
+       if (err) {
+               /*
+                * if directory creation succeeded, but inode copyup failed,
+                * then purge new dentries.
+                */
+               if (dbstart(dentry) < old_bstart &&
+                   ibstart(dentry->d_inode) > dbstart(dentry))
+                       __clear(dentry, NULL, old_bstart, old_bend,
+                               unionfs_lower_dentry(dentry), dbstart(dentry));
                goto out;
+       }
        if (!S_ISDIR(dentry->d_inode->i_mode)) {
                unionfs_postcopyup_release(dentry);
                if (!unionfs_lower_inode(dentry->d_inode)) {