From: Vivek Goyal <vgoyal@redhat.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Dharmendra Singh <dharamhans87@gmail.com>,
Bernd Schubert <bschubert@ddn.com>
Subject: Re: [RFC PATCH] vfs: allow ->atomic_open() on positive
Date: Thu, 19 May 2022 16:09:18 -0400 [thread overview]
Message-ID: <Yoaj7jhLpp34K9+v@redhat.com> (raw)
In-Reply-To: <YoZXro9PoYAPUeh5@miu.piliscsaba.redhat.com>
On Thu, May 19, 2022 at 04:43:58PM +0200, Miklos Szeredi wrote:
> Hi Al,
>
> Do you see anything bad with allowing ->atomic_open() to take a positive dentry
> and possibly invalidate it after it does the atomic LOOKUP/CREATE+OPEN?
>
> It looks wrong not to allow optimizing away the roundtrip associated with
> revalidation when we do allow optimizing away the roundtrip for the initial
> lookup in the same situation.
>
> Thanks,
> Miklos
>
>
> diff --git a/fs/namei.c b/fs/namei.c
> index 509657fdf4f5..d35b5cbf7f64 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -3267,7 +3267,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
> dput(dentry);
> dentry = NULL;
> }
> - if (dentry->d_inode) {
> + if (dentry->d_inode && !d_atomic_open(dentry)) {
> /* Cached positive dentry: will open in f_op->open */
> return dentry;
Hi Miklos,
I see that lookup_open() calls d_revalidate() first. So basically
idea is that fuse ->.d_revalidate will skip LOOKUP needed to make sure
dentry is still valid (Only if atomic lookup+open is implemented) and
return 1 claiming dentry is valid.
And later in ->atomic_open(), it will either open the file or
get an error and invalidate dentry. Hence will save one LOOKUP in
success case. Do I understand the intent right?
Thanks
Vivek
> }
> diff --git a/include/linux/dcache.h b/include/linux/dcache.h
> index f5bba51480b2..da681bdbc34e 100644
> --- a/include/linux/dcache.h
> +++ b/include/linux/dcache.h
> @@ -208,6 +208,7 @@ struct dentry_operations {
> #define DCACHE_NOKEY_NAME 0x02000000 /* Encrypted name encoded without key */
> #define DCACHE_OP_REAL 0x04000000
>
> +#define DCACHE_ATOMIC_OPEN 0x08000000 /* Always use ->atomic_open() to open this file */
> #define DCACHE_PAR_LOOKUP 0x10000000 /* being looked up (with parent locked shared) */
> #define DCACHE_DENTRY_CURSOR 0x20000000
> #define DCACHE_NORCU 0x40000000 /* No RCU delay for freeing */
> @@ -446,6 +447,11 @@ static inline bool d_is_positive(const struct dentry *dentry)
> return !d_is_negative(dentry);
> }
>
> +static inline bool d_atomic_open(const struct dentry *dentry)
> +{
> + return dentry->d_flags & DCACHE_ATOMIC_OPEN;
> +}
> +
> /**
> * d_really_is_negative - Determine if a dentry is really negative (ignoring fallthroughs)
> * @dentry: The dentry in question
>
next prev parent reply other threads:[~2022-05-19 20:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-19 14:43 [RFC PATCH] vfs: allow ->atomic_open() on positive Miklos Szeredi
2022-05-19 20:09 ` Vivek Goyal [this message]
2022-05-19 20:43 ` Bernd Schubert
2022-05-19 20:50 ` Vivek Goyal
2022-05-20 6:48 ` Miklos Szeredi
2022-05-20 4:07 ` Al Viro
2022-05-20 6:44 ` Miklos Szeredi
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=Yoaj7jhLpp34K9+v@redhat.com \
--to=vgoyal@redhat.com \
--cc=bschubert@ddn.com \
--cc=dharamhans87@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.