From: "Josef 'Jeff' Sipek" <jsipek@cs.sunysb.edu>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: akpm@linux-foundation.org, Erez Zadok <ezk@cs.sunysb.edu>,
"Josef 'Jeff' Sipek" <jsipek@cs.sunysb.edu>
Subject: [PATCH 10/16] Unionfs: merge find_new_branch_index and branch_id_to_idx into one function
Date: Sun, 17 Jun 2007 15:09:17 -0400 [thread overview]
Message-ID: <1182107364965-git-send-email-jsipek@cs.sunysb.edu> (raw)
In-Reply-To: <11821073632989-git-send-email-jsipek@cs.sunysb.edu>
From: Erez Zadok <ezk@cs.sunysb.edu>
Useful code cleanup and consolidation between the ODF code and non-ODF code.
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Signed-off-by: Josef 'Jeff' Sipek <jsipek@cs.sunysb.edu>
---
fs/unionfs/commonfops.c | 35 +++++++++--------------------------
fs/unionfs/fanout.h | 24 ++++++++++++++++++++++++
2 files changed, 33 insertions(+), 26 deletions(-)
diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 0222393..731e3a9 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -90,31 +90,6 @@ out:
}
/*
- * 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;
-}
-
-/*
* put all references held by upper struct file and free lower file pointer
* array
*/
@@ -130,8 +105,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 71052a3..0319835 100644
--- a/fs/unionfs/fanout.h
+++ b/fs/unionfs/fanout.h
@@ -55,6 +55,30 @@ 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;
+ for (i = 0; i < sbmax(sb); i++) {
+ 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;
+}
+
/* File to lower file. */
static inline struct file *unionfs_lower_file(const struct file *f)
{
--
1.5.2.rc1.165.gaf9b
next prev parent reply other threads:[~2007-06-17 19:14 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-17 19:09 [GIT PULL -mm] Unionfs cleanups, fixes, and mmap Josef 'Jeff' Sipek
2007-06-17 19:09 ` [PATCH 01/16] [PATCH] unionfs section mismatch Josef 'Jeff' Sipek
2007-06-17 19:09 ` [PATCH 02/16] Unionfs: Don't revalidate dropped dentries Josef 'Jeff' Sipek
2007-06-17 19:09 ` [PATCH 03/16] Unionfs: Retry lookup for different silly-renamed files Josef 'Jeff' Sipek
2007-06-17 19:09 ` [PATCH 04/16] Unionfs: Set lower inodes correctly after branch management succeeds Josef 'Jeff' Sipek
2007-06-17 19:09 ` [PATCH 05/16] Unionfs: call statfs on lower file system properly Josef 'Jeff' Sipek
2007-06-17 19:09 ` [PATCH 06/16] MAINTAINERS: Add Erez Zadok as a maintainer of Unionfs Josef 'Jeff' Sipek
2007-06-17 19:09 ` [PATCH 07/16] Unionfs: Add standard copyright comment to include/linux/union_fs.h Josef 'Jeff' Sipek
2007-06-17 19:09 ` [PATCH 08/16] Unionfs: Remove unnecessary #define Josef 'Jeff' Sipek
2007-06-17 19:09 ` [PATCH 09/16] Unionfs: mmap implementation Josef 'Jeff' Sipek
2007-06-17 19:09 ` Josef 'Jeff' Sipek [this message]
2007-06-17 19:09 ` [PATCH 11/16] Unionfs: Revalidate dentries passed to all inode/super operations Josef 'Jeff' Sipek
2007-06-17 19:09 ` [PATCH 12/16] Unionfs: Cleanup new_dentry_private_data Josef 'Jeff' Sipek
2007-06-17 19:09 ` [PATCH 13/16] Unionfs: Change free_dentry_private_info to take a struct dentry Josef 'Jeff' Sipek
2007-06-17 19:09 ` [PATCH 14/16] Unionfs: Add BUG_ONs to unionfs_lower_* Josef 'Jeff' Sipek
2007-06-17 19:09 ` [PATCH 15/16] Unionfs: Change the semantics of sb info's rwsem Josef 'Jeff' Sipek
2007-06-17 19:09 ` [PATCH 16/16] Unionfs: Remove superfluous check for NULL pointer Josef 'Jeff' Sipek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1182107364965-git-send-email-jsipek@cs.sunysb.edu \
--to=jsipek@cs.sunysb.edu \
--cc=akpm@linux-foundation.org \
--cc=ezk@cs.sunysb.edu \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®