commit 34c7444a572791aa43d479aad050806938dd950a
Author: Erez Zadok <[EMAIL PROTECTED]>
Date:   Mon Oct 1 00:06:05 2007 -0400

    Unionfs: fix bug when renaming directories on top of nfs2/3
    
    In 2.6.9, nfs2/3 cannot rename one dir to another, if the target dir exists:
    an EBUSY is returned.  So if we get that, we have to purge the lower inode
    and retry.
    
    Signed-off-by: Erez Zadok <[EMAIL PROTECTED]>

diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c
index 118bd57..cb2b429 100644
--- a/fs/unionfs/rename.c
+++ b/fs/unionfs/rename.c
@@ -122,6 +122,26 @@ static int __unionfs_rename(struct inode *old_dir, struct 
dentry *old_dentry,
 
        err = vfs_rename(lower_old_dir_dentry->d_inode, lower_old_dentry,
                         lower_new_dir_dentry->d_inode, lower_new_dentry);
+       /*
+        * In 2.6.9, nfs2/3 cannot rename one dir to another, if the target
+        * dir exists: an EBUSY is returned.  So if we get that, we have to
+        * purge the lower inode and retry.
+        */
+       if (err == -EBUSY &&
+           lower_new_dentry->d_inode &&
+           S_ISDIR(lower_new_dentry->d_inode->i_mode)) {
+               struct inode *inode = lower_new_dentry->d_inode;
+               if (lower_new_dentry->d_op && lower_new_dentry->d_op->d_iput)
+                       lower_new_dentry->d_op->d_iput(lower_new_dentry,
+                                                      inode);
+               else
+                       iput(inode);
+               lower_new_dentry->d_inode = NULL;
+               err = vfs_rename(lower_old_dir_dentry->d_inode,
+                                lower_old_dentry,
+                                lower_new_dir_dentry->d_inode,
+                                lower_new_dentry);
+       }
 
 out_unlock:
        unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs

Reply via email to