commit 4e9c90eebd361e40b7cbca6db49f0648d31f0de0
Author: Erez_Zadok <[EMAIL PROTECTED]>
Date:   Fri May 25 16:36:08 2007 -0400

    unionfs: merge find_new_branch_index and branch_id_to_idx into one function
    
    Useful code cleanup and consolidation between the ODF code and non-ODF code.
    
    Signed-off-by: Erez Zadok <[EMAIL PROTECTED]>
    
    Conflicts:
    
        fs/unionfs/commonfops.c
        fs/unionfs/fanout.h

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index d560fe6..8ad5ed6 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -97,31 +97,6 @@ out:
        return err;
 }
 
-/*
- * Find new index of matching branch with an open file, since branches could
- * have been added/deleted causing the one with open files to shift.
- *
- * @file: current file whose branches may have changed
- * @bindex: index of branch within current file (could be old branch)
- * @new_sb: the new superblock which may have new branch IDs
- * Returns index of newly found branch (0 or greater), -1 otherwise.
- */
-static int find_new_branch_index(struct file *file, int bindex,
-                                struct super_block *new_sb)
-{
-       int old_branch_id = UNIONFS_F(file)->saved_branch_ids[bindex];
-       int i;
-
-       for (i = 0; i < sbmax(new_sb); i++)
-               if (old_branch_id == branch_id(new_sb, i))
-                       return i;
-       /*
-        * XXX: maybe we should BUG_ON if not found new branch index?
-        * (really that should never happen).
-        */
-       return -1;
-}
-
 /* Same as copyup_deleted_file, but with rename instead of copyup
  */
 int unionfs_silly_rename(struct dentry *dentry, struct dentry *hidden_dentry)
@@ -203,8 +178,16 @@ static void cleanup_file(struct file *file)
 
        for (bindex = bstart; bindex <= bend; bindex++) {
                if (unionfs_lower_file_idx(file, bindex)) {
+                       /*
+                        * Find new index of matching branch with an open
+                        * file, since branches could have been added or
+                        * deleted causing the one with open files to shift.
+                        */
                        int i;  /* holds (possibly) updated branch index */
-                       i = find_new_branch_index(file, bindex, sb);
+                       int old_bid;
+
+                       old_bid = UNIONFS_F(file)->saved_branch_ids[bindex];
+                       i = branch_id_to_idx(sb, old_bid);
                        if (i < 0)
                                printk(KERN_ERR "unionfs: no superblock for "
                                       "file %p\n", file);
diff --git a/fs/unionfs/fanout.h b/fs/unionfs/fanout.h
index 7db29b7..acbe053 100644
--- a/fs/unionfs/fanout.h
+++ b/fs/unionfs/fanout.h
@@ -55,6 +55,15 @@ static inline void new_branch_id(struct super_block *sb, int 
index)
        set_branch_id(sb, index, ++UNIONFS_SB(sb)->high_branch_id);
 }
 
+/*
+ * Find new index of matching branch with an existing superblock a a known
+ * (possibly old) id.  This is needed because branches could have been
+ * added/deleted causing the branchs of any open files to shift.
+ *
+ * @sb: the new superblock which may have new/different branch IDs
+ * @id: the old/existing id we're looking for
+ * Returns index of newly found branch (0 or greater), -1 otherwise.
+ */
 static inline int branch_id_to_idx(struct super_block *sb, int id)
 {
        int i;
@@ -62,6 +71,11 @@ static inline int branch_id_to_idx(struct super_block *sb, 
int id)
                if (branch_id(sb, i) == id)
                        return i;
        }
+       /*
+        * XXX: maybe we should BUG_ON if not found new branch index?
+        * (really that should never happen).
+        */
+       printk(KERN_WARNING "unionfs: cannot find branch with id %d\n", id);
        return -1;
 }
 
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs

Reply via email to