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 21/21] Unionfs: Correctly decrement refcounts of mnt's upon branch management
Date: Wed, 23 May 2007 20:36:11 -0400 [thread overview]
Message-ID: <11799669742009-git-send-email-jsipek@cs.sunysb.edu> (raw)
In-Reply-To: <11799669712090-git-send-email-jsipek@cs.sunysb.edu>
From: Erez Zadok <ezk@cs.sunysb.edu>
The old logic was broken in one place, which another place tried to "fix"
incorrectly. Also added detailed comments to explain the new/correct logic.
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Signed-off-by: Josef 'Jeff' Sipek <jsipek@cs.sunysb.edu>
---
fs/unionfs/commonfops.c | 17 ++++++++++++-----
fs/unionfs/dentry.c | 18 +++++++++++++-----
2 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 69d9c87..83001aa 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -135,14 +135,21 @@ static void cleanup_file(struct file *file)
"file %p\n", file);
else {
unionfs_read_lock(sb);
+ /* decrement count of open files */
branchput(sb, i);
unionfs_read_unlock(sb);
- /* XXX: is it OK to use sb->s_root here? */
- unionfs_mntput(sb->s_root, i);
- /* mntget b/c fput below will call mntput */
- unionfs_mntget(sb->s_root, bindex);
+ /*
+ * fput will perform an mntput for us on the
+ * correct branch. Although we're using the
+ * file's old branch configuration, bindex,
+ * which is the old index, correctly points
+ * to the right branch in the file's branch
+ * list. In other words, we're going to
+ * mntput the correct branch even if
+ * branches have been added/removed.
+ */
+ fput(unionfs_lower_file_idx(file, bindex));
}
- fput(unionfs_lower_file_idx(file, bindex));
}
}
diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index 95cea3b..db0ef43 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -258,14 +258,22 @@ out_this:
/* finally, lock this dentry and revalidate it */
verify_locked(dentry);
dgen = atomic_read(&UNIONFS_D(dentry)->generation);
- saved_bstart = dbstart(dentry);
- saved_bend = dbend(dentry);
valid = __unionfs_d_revalidate_one(dentry, nd);
- if (valid && chain_len > 0 && sbgen != dgen) {
- for (bindex = saved_bstart; bindex <= saved_bend; bindex++)
+ /*
+ * If __unionfs_d_revalidate_one() succeeded above, then it will
+ * have incremented the refcnt of the mnt's, but also the branch
+ * indices of the dentry will have been updated (to take into
+ * account any branch insertions/deletion. So the current
+ * dbstart/dbend match the current, and new, indices of the mnts
+ * which __unionfs_d_revalidate_one has incremented. Note: the "if"
+ * test below does not depend on whether chain_len was 0 or greater.
+ */
+ if (valid && sbgen != dgen)
+ for (bindex = dbstart(dentry);
+ bindex <= dbend(dentry);
+ bindex++)
unionfs_mntput(dentry, bindex);
- }
out_free:
/* unlock/dput all dentries in chain and return status */
--
1.5.2.rc1.165.gaf9b
prev parent reply other threads:[~2007-05-24 0:36 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-24 0:35 [GIT PULL -mm] Unionfs cleanups and fixes Josef 'Jeff' Sipek
2007-05-24 0:35 ` [PATCH 01/21] Unionfs: Tiny documentation fixups Josef 'Jeff' Sipek
2007-05-24 0:35 ` [PATCH 02/21] Unionfs: Coding style fixes Josef 'Jeff' Sipek
2007-05-24 0:35 ` [PATCH 03/21] Unionfs: Every printk should prefix with "unionfs: " consistently Josef 'Jeff' Sipek
2007-05-24 0:35 ` [PATCH 04/21] Unionfs: Add missing copyright notices Josef 'Jeff' Sipek
2007-05-24 0:35 ` [PATCH 05/21] Unionfs: Cleanup of strings and comments Josef 'Jeff' Sipek
2007-05-24 0:35 ` [PATCH 06/21] Unionfs: Added numerous comments Josef 'Jeff' Sipek
2007-05-24 0:35 ` [PATCH 07/21] Unionfs: Consistent pointer declaration spacing Josef 'Jeff' Sipek
2007-05-24 0:35 ` [PATCH 08/21] Unionfs: Rename Unionfs's double_lock_dentry to avoid confusion Josef 'Jeff' Sipek
2007-05-24 0:35 ` [PATCH 09/21] Unionfs: Rename our "do_rename" to __unionfs_rename Josef 'Jeff' Sipek
2007-05-24 0:36 ` [PATCH 10/21] Unionfs: Move unionfs_query_file to commonfops.c Josef 'Jeff' Sipek
2007-05-24 0:36 ` [PATCH 11/21] Unionfs: Combine unionfs_write with __unionfs_write Josef 'Jeff' Sipek
2007-05-24 0:36 ` [PATCH 12/21] Unionfs: Prefix external functions with 'extern' properly Josef 'Jeff' Sipek
2007-05-24 0:36 ` [PATCH 13/21] Unionfs: Don't leak resources when copyup fails partially Josef 'Jeff' Sipek
2007-05-24 0:36 ` [PATCH 14/21] Unionfs: Call realloc unconditionally Josef 'Jeff' Sipek
2007-05-24 0:36 ` [PATCH 15/21] Unionfs: Use krealloc instead of open-coding the functionality Josef 'Jeff' Sipek
2007-05-24 0:36 ` [PATCH 16/21] Unionfs: Disallow setting leftmost branch to readonly Josef 'Jeff' Sipek
2007-05-24 0:36 ` [PATCH 17/21] Unionfs: Documentation update regarding overlapping branches and new lookup code Josef 'Jeff' Sipek
2007-05-24 0:36 ` [PATCH 18/21] Unionfs: Remove defunct unionfs_put_inode super op Josef 'Jeff' Sipek
2007-05-24 0:36 ` [PATCH 19/21] Unionfs: Actually catch bad use of unionfs_mnt{get,put} Josef 'Jeff' Sipek
2007-05-24 0:36 ` [PATCH 20/21] Unionfs: Removed a trailing whitespace Josef 'Jeff' Sipek
2007-05-24 0:36 ` Josef 'Jeff' Sipek [this message]
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=11799669742009-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;
as well as URLs for NNTP newsgroup(s).