the same can seemingly be applied to rename, as a whiteout would presumambly have to be created in some situatins, but I don't see where that is? Since it didnt affect what I needed, didn't look too hard into it.

Yiannis Pericleous wrote:
Log Message:
-----------
applied shaya's optimization patch

Modified Files:
--------------
    unionfs:
        ChangeLog (r1.733 -> r1.734)
        inode.c (r1.276 -> r1.277)
        lookup.c (r1.51 -> r1.52)
        unlink.c (r1.44 -> r1.45)

Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/unionfs/unionfs/ChangeLog,v
retrieving revision 1.733
retrieving revision 1.734
diff -LChangeLog -LChangeLog -u -d -b -B -p -r1.733 -r1.734
--- ChangeLog
+++ ChangeLog
@@ -1,5 +1,13 @@
 2007-01-16 Yiannis Pericleous <[EMAIL PROTECTED]>
+ * inode.c: Shaya's optimization
+
+       * lookup.c: Shaya's optimization
+
+       * unlink.c: Shaya's optimization
+ +2007-01-16 Yiannis Pericleous <[EMAIL PROTECTED]>
+
        * misc/snapmerge: Another small bug fix
2007-01-16 Yiannis Pericleous <[EMAIL PROTECTED]>
Index: unlink.c
===================================================================
RCS file: /home/cvs/unionfs/unionfs/unlink.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -Lunlink.c -Lunlink.c -u -d -b -B -p -r1.44 -r1.45
--- unlink.c
+++ unlink.c
@@ -127,7 +127,7 @@ static int unionfs_unlink_whiteout(struc
                goto out;
if (err) {
-               if (dbstart(dentry) == 0)
+               if ((dbstart(dentry) == 0) || (dbstart(dentry) == 
dbopaque(dentry)))
                        goto out;
err = create_whiteout(dentry, dbstart(dentry) - 1);
@@ -329,6 +329,8 @@ int unionfs_rmdir(struct inode *dir, str
                err = unionfs_rmdir_first(dir, dentry, namelist);
                /* create whiteout */
                if (!err) {
+                       if ((dbstart(dentry) == 0) || (dbstart(dentry) == 
dbopaque(dentry)))
+                               goto out;
                        err = create_whiteout(dentry, dbstart(dentry));
                } else {
                        int new_err;
Index: lookup.c
===================================================================
RCS file: /home/cvs/unionfs/unionfs/lookup.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -Llookup.c -Llookup.c -u -d -b -B -p -r1.51 -r1.52
--- lookup.c
+++ lookup.c
@@ -117,6 +118,8 @@ struct dentry *unionfs_lookup_backend(st
                if (!S_ISDIR(hidden_dir_dentry->d_inode->i_mode))
                        continue;
+ if (bindex != bend) {
+
                /* Reuse the whiteout name because its value doesn't change. */
                if (!whname) {
                        whname = alloc_whname(name, namelen);
@@ -154,6 +157,7 @@ struct dentry *unionfs_lookup_backend(st
DPUT(wh_hidden_dentry);
                wh_hidden_dentry = NULL;
+               }
/* Now do regular lookup; lookup foo */
                hidden_dentry = LOOKUP_ONE_LEN(name, hidden_dir_dentry,
Index: inode.c
===================================================================
RCS file: /home/cvs/unionfs/unionfs/inode.c,v
retrieving revision 1.276
retrieving revision 1.277
diff -Linode.c -Linode.c -u -d -b -B -p -r1.276 -r1.277
--- inode.c
+++ inode.c
@@ -38,7 +38,7 @@ static int unionfs_create(struct inode *
        struct dentry *whiteout_dentry = NULL;
        struct dentry *new_hidden_dentry;
        struct dentry *hidden_parent_dentry = NULL;
-       int bindex = 0, bstart;
+       int bindex = 0, bstart, bend, bopaque;
        char *name = NULL;
print_entry_location();
@@ -47,8 +47,14 @@ static int unionfs_create(struct inode *
/* We start out in the leftmost branch. */
        bstart = dbstart(dentry);
+       bend = dbend(dentry);
+       bopaque = dbopaque(dentry);
        hidden_dentry = dtohd(dentry);
+ if ((bopaque != -1) && (bopaque < bend))
+               bend = bopaque;
+
+       if (bstart != bend) {
        /* check if whiteout exists in this branch, i.e. lookup .wh.foo first */
        name = alloc_whname(dentry->d_name.name, dentry->d_name.len);
        if (IS_ERR(name)) {
@@ -148,6 +154,7 @@ static int unionfs_create(struct inode *
                        goto out;
                }
        }
+       }
for (bindex = bstart; bindex >= 0; bindex--) {
                hidden_dentry = dtohd_index(dentry, bindex);
@@ -224,12 +231,20 @@ static int unionfs_link(struct dentry *o
        struct dentry *hidden_dir_dentry = NULL;
        struct dentry *whiteout_dentry;
        char *name = NULL;
+       int bstart, bend, bopaque;
print_entry_location();
        double_lock_dentry(new_dentry, old_dentry);
hidden_new_dentry = dtohd(new_dentry);
+       bstart = dbstart(new_dentry->d_parent);
+       bend = dbend(new_dentry->d_parent);
+       bopaque = dbopaque(new_dentry->d_parent);
+
+       if ((bopaque != -1) && (bopaque < bend))
+               bend = bopaque;
+ if (bstart != bend) {
        /* check if whiteout exists in the branch of new dentry, i.e. lookup
         * .wh.foo first. If present, delete it */
        name = alloc_whname(new_dentry->d_name.name, new_dentry->d_name.len);
@@ -268,6 +283,7 @@ static int unionfs_link(struct dentry *o
                if (err)
                        goto out;
        }
+       }
if (dbstart(old_dentry) != dbstart(new_dentry)) {
                hidden_new_dentry =
@@ -349,7 +365,7 @@ static int unionfs_symlink(struct inode struct dentry *whiteout_dentry = NULL;
        struct dentry *hidden_dir_dentry = NULL;
        umode_t mode;
-       int bindex = 0, bstart;
+       int bindex = 0, bstart, bend, bopaque;
        char *name = NULL;
print_entry_location(); @@ -358,9 +374,15 @@ static int unionfs_symlink(struct inode /* We start out in the leftmost branch. */
        bstart = dbstart(dentry);
+       bend = dbend(dentry);
+       bopaque = dbopaque(dentry);
+
+       if ((bopaque != -1) && (bopaque < bend))
+               bend = bopaque;
hidden_dentry = dtohd(dentry); + if (bstart != bend) {
        /* check if whiteout exists in this branch, i.e. lookup .wh.foo first. 
If present, delete it */
        name = alloc_whname(dentry->d_name.name, dentry->d_name.len);
        if (IS_ERR(name)) {
@@ -407,6 +429,7 @@ static int unionfs_symlink(struct inode bstart--;
                }
        }
+       }
/* deleted whiteout if it was present, now do a normal vfs_symlink() with
           possible recursive directory creation */
@@ -472,7 +495,7 @@ static int unionfs_mkdir(struct inode *p
        int err = 0;
        struct dentry *hidden_dentry = NULL, *whiteout_dentry = NULL;
        struct dentry *hidden_parent_dentry = NULL;
-       int bindex = 0, bstart;
+       int bindex = 0, bstart, bend, bopaque;
        char *name = NULL;
        int whiteout_unlinked = 0;
        struct sioq_args args;
@@ -481,9 +504,15 @@ static int unionfs_mkdir(struct inode *p
        lock_dentry(dentry);
        print_dentry("IN unionfs_mkdir", dentry);
        bstart = dbstart(dentry);
+       bend = dbend(dentry);
+       bopaque = dbopaque(dentry);
+
+       if ((bopaque != -1) && (bopaque < bend))
+               bend = bopaque;
hidden_dentry = dtohd(dentry); + if (bstart != bend) {
        // check if whiteout exists in this branch, i.e. lookup .wh.foo first
        name = alloc_whname(dentry->d_name.name, dentry->d_name.len);
        if (IS_ERR(name)) {
@@ -525,6 +554,7 @@ static int unionfs_mkdir(struct inode *p
                        whiteout_unlinked = 1;
                }
        }
+       }
for (bindex = bstart; bindex >= 0; bindex--) {
                hidden_dentry = dtohd_index(dentry, bindex);
@@ -606,7 +636,7 @@ static int unionfs_mknod(struct inode *d
        int err = 0;
        struct dentry *hidden_dentry = NULL, *whiteout_dentry = NULL;
        struct dentry *hidden_parent_dentry = NULL;
-       int bindex = 0, bstart;
+       int bindex = 0, bstart, bend, bopaque;
        char *name = NULL;
        int whiteout_unlinked = 0;
@@ -614,9 +644,15 @@ static int unionfs_mknod(struct inode *d
        lock_dentry(dentry);
        print_dentry("IN unionfs_mknod", dentry);
        bstart = dbstart(dentry);
+       bend = dbend(dentry);
+       bopaque = dbopaque(dentry);
+
+       if ((bopaque != -1) && (bopaque < bend))
+               bend = bopaque;
hidden_dentry = dtohd(dentry); + if (bstart != bend) {
        // check if whiteout exists in this branch, i.e. lookup .wh.foo first
        name = alloc_whname(dentry->d_name.name, dentry->d_name.len);
        if (IS_ERR(name)) {
@@ -654,6 +690,7 @@ static int unionfs_mknod(struct inode *d
                        bstart--;
                } else {
                        whiteout_unlinked = 1;
+                       }
                }
        }
_______________________________________________
unionfs-cvs mailing list
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs
_______________________________________________
unionfs mailing list
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs

Reply via email to