From: Miklos Szeredi <miklos@szeredi.hu>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Vivek Goyal <vgoyal@redhat.com>,
Dharmendra Singh <dharamhans87@gmail.com>,
Bernd Schubert <bschubert@ddn.com>
Subject: [RFC PATCH] vfs: allow ->atomic_open() on positive
Date: Thu, 19 May 2022 16:43:58 +0200 [thread overview]
Message-ID: <YoZXro9PoYAPUeh5@miu.piliscsaba.redhat.com> (raw)
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;
}
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 reply other threads:[~2022-05-19 14:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-19 14:43 Miklos Szeredi [this message]
2022-05-19 20:09 ` [RFC PATCH] vfs: allow ->atomic_open() on positive Vivek Goyal
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=YoZXro9PoYAPUeh5@miu.piliscsaba.redhat.com \
--to=miklos@szeredi.hu \
--cc=bschubert@ddn.com \
--cc=dharamhans87@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=vgoyal@redhat.com \
--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;
as well as URLs for NNTP newsgroup(s).