From: Erez Zadok <ezk@cs.sunysb.edu>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
viro@ftp.linux.org.uk, hch@infradead.org,
Erez Zadok <ezk@cs.sunysb.edu>
Subject: [PATCH 08/25] Unionfs: lower nameidata support for nfsv4
Date: Tue, 25 Sep 2007 23:09:47 -0400 [thread overview]
Message-ID: <11907762081789-git-send-email-ezk@cs.sunysb.edu> (raw)
In-Reply-To: <11907762042481-git-send-email-ezk@cs.sunysb.edu>
Pass nameidata structures as needed to the lower file system, support
LOOKUP_ACCESS/OPEN intents. This makes unionfs work on top of nfsv4.
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Acked-by: Josef 'Jeff' Sipek <jsipek@cs.sunysb.edu>
---
fs/unionfs/dentry.c | 11 +++++++++--
fs/unionfs/inode.c | 8 +++++++-
fs/unionfs/lookup.c | 20 +++++++++++++++++---
3 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index b21f1e3..52bcb18 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -156,8 +156,15 @@ static bool __unionfs_d_revalidate_one(struct dentry *dentry,
if (!lower_dentry || !lower_dentry->d_op
|| !lower_dentry->d_op->d_revalidate)
continue;
- if (!lower_dentry->d_op->d_revalidate(lower_dentry,
- &lowernd))
+ /*
+ * Don't pass nameidata to lower file system, because we
+ * don't want an arbitrary lower file being opened or
+ * returned to us: it may be useless to us because of the
+ * fanout nature of unionfs (cf. file/directory open-file
+ * invariants). We will open lower files as and when needed
+ * later on.
+ */
+ if (!lower_dentry->d_op->d_revalidate(lower_dentry, NULL))
valid = false;
}
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index f8b2c88..7ee4760 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -27,6 +27,7 @@ static int unionfs_create(struct inode *parent, struct dentry *dentry,
struct dentry *lower_parent_dentry = NULL;
char *name = NULL;
int valid = 0;
+ struct nameidata lower_nd;
unionfs_read_lock(dentry->d_sb);
unionfs_lock_dentry(dentry);
@@ -113,7 +114,12 @@ static int unionfs_create(struct inode *parent, struct dentry *dentry,
goto out;
}
- err = vfs_create(lower_parent_dentry->d_inode, lower_dentry, mode, nd);
+ err = init_lower_nd(&lower_nd, LOOKUP_CREATE);
+ if (err < 0)
+ goto out;
+ err = vfs_create(lower_parent_dentry->d_inode, lower_dentry, mode,
+ &lower_nd);
+ release_lower_nd(&lower_nd, err);
if (!err) {
err = PTR_ERR(unionfs_interpose(dentry, parent->i_sb, 0));
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index 963d622..2109714 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -583,6 +583,11 @@ void update_bstart(struct dentry *dentry)
* Inside that nd structure, this function may also return an allocated
* struct file (for open intents). The caller, when done with this nd, must
* kfree the intent file (using release_lower_nd).
+ *
+ * XXX: this code, and the callers of this code, should be redone using
+ * vfs_path_lookup() when (1) the nameidata structure is refactored into a
+ * separate intent-structure, and (2) open_namei() is broken into a VFS-only
+ * function and a method that other file systems can call.
*/
int init_lower_nd(struct nameidata *nd, unsigned int flags)
{
@@ -597,11 +602,16 @@ int init_lower_nd(struct nameidata *nd, unsigned int flags)
#endif /* ALLOC_LOWER_ND_FILE */
memset(nd, 0, sizeof(struct nameidata));
+ if (!flags)
+ return err;
switch (flags) {
case LOOKUP_CREATE:
- nd->flags = LOOKUP_CREATE;
- nd->intent.open.flags = FMODE_READ | FMODE_WRITE | O_CREAT;
+ nd->intent.open.flags |= O_CREAT;
+ /* fall through: shared code for create/open cases */
+ case LOOKUP_OPEN:
+ nd->flags = flags;
+ nd->intent.open.flags |= (FMODE_READ | FMODE_WRITE);
#ifdef ALLOC_LOWER_ND_FILE
file = kzalloc(sizeof(struct file), GFP_KERNEL);
if (!file) {
@@ -611,11 +621,15 @@ int init_lower_nd(struct nameidata *nd, unsigned int flags)
nd->intent.open.file = file;
#endif /* ALLOC_LOWER_ND_FILE */
break;
+ case LOOKUP_ACCESS:
+ nd->flags = flags;
+ break;
default:
/*
* We should never get here, for now.
* We can add new cases here later on.
*/
+ dprintk("unionfs: unknown nameidata flag 0x%x\n", flags);
BUG();
break;
}
@@ -627,7 +641,7 @@ void release_lower_nd(struct nameidata *nd, int err)
{
if (!nd->intent.open.file)
return;
- if (!err)
+ else if (!err)
release_open_intent(nd);
#ifdef ALLOC_LOWER_ND_FILE
kfree(nd->intent.open.file);
--
1.5.2.2
next prev parent reply other threads:[~2007-09-26 3:29 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-26 3:09 [GIT PULL -mm] 00/25 Unionfs updates/cleanups/fixes Erez Zadok
2007-09-26 3:09 ` [PATCH 01/25] Unionfs: Simplify unionfs_get_nlinks Erez Zadok
2007-09-26 3:09 ` [PATCH 02/25] Unionfs: Remove unused #defines Erez Zadok
2007-09-26 3:09 ` [PATCH 03/25] Unionfs: display informational messages only if debug is on Erez Zadok
2007-09-26 8:36 ` Jan Engelhardt
2007-09-26 14:01 ` Erez Zadok
2007-09-26 15:24 ` Jan Engelhardt
2007-09-26 15:28 ` Erez Zadok
2007-09-26 3:09 ` [PATCH 04/25] Unionfs: cache-coherency fixes Erez Zadok
2007-09-26 3:09 ` [PATCH 05/25] Unionfs: cast page->index loff_t before shifting Erez Zadok
2007-09-26 8:31 ` Christoph Hellwig
2007-09-26 13:44 ` Erez Zadok
2007-09-26 3:09 ` [PATCH 06/25] Unionfs: minor coding style updates Erez Zadok
2007-09-26 3:09 ` [PATCH 07/25] Unionfs: add lower nameidata debugging support Erez Zadok
2007-09-26 3:09 ` Erez Zadok [this message]
2007-09-26 3:09 ` [PATCH 09/25] Unionfs: add un/likely conditionals on common fileops Erez Zadok
2007-09-26 3:09 ` [PATCH 10/25] Unionfs: add un/likely conditionals on copyup ops Erez Zadok
2007-09-26 4:32 ` Kok, Auke
2007-09-26 13:40 ` Erez Zadok
2007-09-26 15:23 ` Kyle Moffett
2007-09-26 15:43 ` Erez Zadok
2007-09-26 16:47 ` Jan Engelhardt
2007-09-26 16:51 ` Erez Zadok
2007-09-26 18:34 ` Adrian Bunk
2007-09-26 3:09 ` [PATCH 11/25] Unionfs: add un/likely conditionals on debug ops Erez Zadok
2007-09-26 21:34 ` roel
2007-09-26 3:09 ` [PATCH 12/25] Unionfs: add un/likely conditionals on dentry ops Erez Zadok
2007-09-26 3:09 ` [PATCH 13/25] Unionfs: add un/likely conditionals on dir ops Erez Zadok
2007-09-26 21:40 ` roel
2007-09-27 14:28 ` Erez Zadok
2007-09-26 3:09 ` [PATCH 14/25] Unionfs: add un/likely conditionals on headers Erez Zadok
2007-09-26 3:09 ` [PATCH 15/25] Unionfs: add un/likely conditionals on fileops Erez Zadok
2007-09-26 3:09 ` [PATCH 16/25] Unionfs: add un/likely conditionals on inode ops Erez Zadok
2007-09-26 3:09 ` [PATCH 17/25] Unionfs: add un/likely conditionals on lookup ops Erez Zadok
2007-09-26 3:09 ` [PATCH 18/25] Unionfs: add un/likely conditionals on super ops Erez Zadok
2007-09-26 3:09 ` [PATCH 19/25] Unionfs: add un/likely conditionals on mmap ops Erez Zadok
2007-09-26 3:09 ` [PATCH 20/25] Unionfs: add un/likely conditionals on rename ops Erez Zadok
2007-09-26 3:10 ` [PATCH 21/25] Unionfs: add un/likely conditionals on readdir ops Erez Zadok
2007-09-26 3:10 ` [PATCH 22/25] Unionfs: add un/likely conditionals on common subr Erez Zadok
2007-09-26 3:10 ` [PATCH 23/25] Unionfs: add un/likely conditionals on unlink ops Erez Zadok
2007-09-26 3:10 ` [PATCH 24/25] Unionfs: add un/likely conditionals on xattr ops Erez Zadok
2007-09-26 3:10 ` [PATCH 25/25] Unionfs: use poison.h for safe poison pointers Erez Zadok
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=11907762081789-git-send-email-ezk@cs.sunysb.edu \
--to=ezk@cs.sunysb.edu \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ftp.linux.org.uk \
/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).