From: "Paolo 'Blaisorblade' Giarrusso" <blaisorblade@yahoo.it>
To: Antoine Martin <antoine@nagafix.co.uk>,
Al Viro <viro@zeniv.linux.org.uk>
Cc: Jeff Dike <jdike@addtoit.com>,
user-mode-linux-devel@lists.sourceforge.net,
LKML <linux-kernel@vger.kernel.org>
Subject: [uml-devel] [PATCH 11/12] HPPFS: add dentry_ops->d_revalidate
Date: Sun, 18 Sep 2005 16:10:07 +0200 [thread overview]
Message-ID: <20050918141006.31461.23599.stgit@zion.home.lan> (raw)
In-Reply-To: 200509181400.39120.blaisorblade@yahoo.it
From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
We might need to revalidate a dentry (for instance when a process dies), so
call the underlying d_revalidate if it is defined, on the underlying
dentry.
Also, when we find a dentry in the dcache, we must call d_revalidate
ourselves.
BUT: for now, this is done with a NULL nameidata (which is only safe by
chance, given the current code). While looking into this, I realized that
the nameidata handling in calls to the underlying FS are bogus. I'm going
to fix this in next patch.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---
fs/hppfs/hppfs_kern.c | 42 +++++++++++++++++++++++++++++++++++++-----
1 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/fs/hppfs/hppfs_kern.c b/fs/hppfs/hppfs_kern.c
--- a/fs/hppfs/hppfs_kern.c
+++ b/fs/hppfs/hppfs_kern.c
@@ -104,7 +104,22 @@ static char *dentry_name(struct dentry *
return(name);
}
+static int hppfs_d_revalidate(struct dentry * dentry, struct nameidata * nd)
+{
+ int (*d_revalidate)(struct dentry *, struct nameidata *);
+ struct dentry *proc_dentry;
+
+ proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
+ if (proc_dentry->d_op && proc_dentry->d_op->d_revalidate)
+ d_revalidate = proc_dentry->d_op->d_revalidate;
+ else
+ return 1; /* "Still valid" code */
+
+ return (*d_revalidate)(proc_dentry, nd);
+}
+
static struct dentry_operations hppfs_dentry_ops = {
+ .d_revalidate = hppfs_d_revalidate,
};
static int file_removed(struct dentry *dentry, const char *file)
@@ -157,7 +172,7 @@ static void hppfs_read_inode(struct inod
ino->i_blocks = proc_ino->i_blocks;
}
-static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
+static struct dentry *hppfs_lookup(struct inode *parent_ino, struct dentry *dentry,
struct nameidata *nd)
{
struct dentry *proc_dentry, *new, *parent;
@@ -171,10 +186,18 @@ static struct dentry *hppfs_lookup(struc
return(ERR_PTR(-ENOENT));
err = -ENOMEM;
- parent = HPPFS_I(ino)->proc_dentry;
+ parent = HPPFS_I(parent_ino)->proc_dentry;
+
+ /* This more or less matches fs/namei.c:real_lookup() - we don't have
+ * the fast path which looks up the dentry without the directory
+ * semaphore. Please keep in sync. */
+
+ /* XXX: The only difference is nameidata: we pass NULL instead of nd.
+ * Not normally allowed, would Oops if proc ever uses nd, and can Oops /
+ * leak entries if we pass the same nd we got. */
down(&parent->d_inode->i_sem);
proc_dentry = d_lookup(parent, &dentry->d_name);
- if(proc_dentry == NULL){
+ if (!proc_dentry) {
proc_dentry = d_alloc(parent, &dentry->d_name);
if(proc_dentry == NULL){
up(&parent->d_inode->i_sem);
@@ -186,13 +209,22 @@ static struct dentry *hppfs_lookup(struc
dput(proc_dentry);
proc_dentry = new;
}
+ up(&parent->d_inode->i_sem);
+ } else {
+ up(&parent->d_inode->i_sem);
+ if (proc_dentry->d_op && proc_dentry->d_op->d_revalidate) {
+ if (!proc_dentry->d_op->d_revalidate(proc_dentry, NULL) &&
+ !d_invalidate(proc_dentry)) {
+ dput(proc_dentry);
+ proc_dentry = ERR_PTR(-ENOENT);
+ }
+ }
}
- up(&parent->d_inode->i_sem);
if(IS_ERR(proc_dentry))
return(proc_dentry);
- inode = iget(ino->i_sb, 0);
+ inode = iget(parent_ino->i_sb, 0);
if(inode == NULL)
goto out_dput;
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
next reply other threads:[~2005-09-18 14:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-18 14:10 Paolo 'Blaisorblade' Giarrusso [this message]
2005-09-21 3:44 ` [uml-devel] Re: [PATCH 11/12] HPPFS: add dentry_ops->d_revalidate Al Viro
2005-10-06 18:07 ` Blaisorblade
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=20050918141006.31461.23599.stgit@zion.home.lan \
--to=blaisorblade@yahoo.it \
--cc=antoine@nagafix.co.uk \
--cc=jdike@addtoit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
--cc=viro@zeniv.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