Unionfs: lock parent dentry branch config in write
authorErez Zadok <ezk@cs.sunysb.edu>
Wed, 23 Apr 2008 23:05:59 +0000 (19:05 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Fri, 12 Aug 2011 02:38:12 +0000 (22:38 -0400)
Ensure that branch configuration is available to file_revalidate should a
copyup be required.

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

index 09f594d946777a9b0387fc9f471602aaa778f36a..9b5fc584a037481bfe92c4314ac36b120f5f9e89 100644 (file)
@@ -55,7 +55,9 @@ static ssize_t unionfs_write(struct file *file, const char __user *buf,
 
        unionfs_read_lock(dentry->d_sb, UNIONFS_SMUTEX_PARENT);
        unionfs_lock_dentry(dentry, UNIONFS_DMUTEX_CHILD);
-       err = unionfs_file_revalidate(file, true);
+       if (dentry != dentry->d_parent)
+               unionfs_lock_dentry(dentry->d_parent, UNIONFS_DMUTEX_PARENT);
+       err = unionfs_file_revalidate_locked(file, true);
        if (unlikely(err))
                goto out;
 
@@ -72,6 +74,8 @@ static ssize_t unionfs_write(struct file *file, const char __user *buf,
        }
 
 out:
+       if (dentry != dentry->d_parent)
+               unionfs_unlock_dentry(dentry->d_parent);
        unionfs_unlock_dentry(dentry);
        unionfs_read_unlock(dentry->d_sb);
        return err;