commit f94df27fe448667d8598dd6e9e9d8f597a34c452
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date:   Mon Mar 26 14:19:43 2007 -0400

    small rename fix to do less copyups

diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c
index aa3de7a..730e96f 100644
--- a/fs/unionfs/rename.c
+++ b/fs/unionfs/rename.c
@@ -140,7 +140,7 @@ static int do_unionfs_rename(struct inode *old_dir,
        int local_err = 0;
        int eio = 0;
        int revert = 0;
-       int new_opaque;
+       int new_opaque, whiteout = 0;
 
        old_bstart = dbstart(old_dentry);
        old_bend = dbend(old_dentry);
@@ -150,6 +150,7 @@ static int do_unionfs_rename(struct inode *old_dir,
        new_bend = dbend(new_dentry);
        new_opaque = odf_get_opaque(new_dentry->d_parent->d_sb, 
new_dentry->d_parent);
 
+       /* if dst does not exist, set its start branch the same as src */
        if (new_bstart == new_bend &&  new_bstart == 0) {
                if (!unionfs_lower_dentry_idx(new_dentry, 0) ||
                    !unionfs_lower_dentry_idx(new_dentry, 0)->d_inode) {
@@ -166,7 +167,7 @@ static int do_unionfs_rename(struct inode *old_dir,
                if (err)
                        break;
        }
-       if (err)
+       if (err && bindex == old_bstart)
                do_copyup = 1;
        else if (new_bstart < old_bstart)
                do_copyup = 1;
@@ -174,6 +175,8 @@ static int do_unionfs_rename(struct inode *old_dir,
                do_copyup = 1;
        else
                revert = 1;
+       if (err)
+               whiteout = 1;
 
        /* only need to copyup if bstart is not 0 */
        if (do_copyup && old_bstart > 0) {      
@@ -212,7 +215,7 @@ static int do_unionfs_rename(struct inode *old_dir,
        err = odf_rename(old_dentry, new_dentry);
        BUG_ON(err);    /* odf should not fail */
 
-       if (do_copyup != 0) {
+       if (whiteout) {
                err = odf_create_wh(old_dentry);
                BUG_ON(err);
        }
@@ -331,7 +334,8 @@ int unionfs_rename(struct inode *old_dir, struct dentry 
*old_dentry,
                goto out;
 
        /* if the new dentry exists at branch 0 and is a whiteout
-        * or if it is a logically empty directory remove it */
+        * or if it is a logically empty directory remove it, 
+        * since it will cause us problems when we copyup */
        hidden = unionfs_lower_dentry_idx(new_dentry, 0);
        if (hidden && hidden->d_inode ) {
                if (UNIONFS_D(new_dentry)->odf_info->whiteout) {
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs

Reply via email to