vfs: allow ->atomic_open() on positive
RFC PATCH 1/1 vfs: allow ->atomic_open() on positive
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
fs/namei.c +1 -1
@@ -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; }
include/linux/dcache.h +6 -0
@@ -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
Quoted 18 lines · Miklos Szeredi
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,
Miklosfs/namei.c +0
-0
fs/namei.c static struct dentry *lookup_open(struct nameidata *nd, struct file *file, · line 3272
Quoted 7 lines
fs/namei.c +1
-1@@ -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
Quoted 26 lines
fs/namei.c +0
-0}include/linux/dcache.h +6
-0@@ -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
Quoted 29 lines · Vivek Goyal
Quoted 18 lines · Miklos Szeredi
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,
Miklosfs/namei.c +0
-0fs/namei.c static struct dentry *lookup_open(struct nameidata *nd, struct file *file, · line 3272
Quoted 7 lines
fs/namei.c +1
-1@@ -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,
Quoted 8 lines
I see that
lookup_open()callsd_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?
Yeah, I think Dharmendra and I had internally already debated over this. In order to reduce complexity for the patches we preferred to go without vfs modifications.
I assume the patch is a follow up to this comment
https://lore.kernel.org/all/[email protected]/T/#m8bd440ddea4c135688c829f34e93371e861ba9fa
Thanks,
Bernd
Quoted 37 lines · Bernd Schubert
Quoted 34 lines · Vivek Goyal
Quoted 18 lines · Miklos Szeredi
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,
Miklosfs/namei.c +0
-0fs/namei.c static struct dentry *lookup_open(struct nameidata *nd, struct file *file, · line 3272
Quoted 7 lines
fs/namei.c +1
-1@@ -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()callsd_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.
Quoted 7 lines
Quoted 3 lines
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?
Yeah, I think Dharmendra and I had internally already debated over this. In order to reduce complexity for the patches we preferred to go without vfs modifications.
Fair enough. It is not trivial to be able to see all the paths and make sure none of these paths is broken.
Quoted 4 lines
I assume the patch is a follow up to this comment
https://lore.kernel.org/all/[email protected]/T/#m8bd440ddea4c135688c829f34e93371e861ba9fa
Yes looks like. There are too many paths here and being able to wrap one's head around all the paths is not trivial. Thankfully miklos has summarized it here.
https://lore.kernel.org/all/[email protected]/T/#m90f64cd8c8fff70e2fba2b551ae01d0d47b3337e
Thanks
Vivek
Al Viro
maintainerQuoted 8 lines · Miklos Szeredi
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.
Details, please - what will your ->atomic_open() do in that case?
Quoted 4 lines · Al Viro
Quoted 2 lines · Miklos Szeredi
Hi Al,
Quoted 8 lines
Quoted 6 lines
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.
Details, please - what will your ->atomic_open() do in that case?
It will do an open-by-name or create-and-open depending on the flags. It will return whether the file was created or not.
If created, then the old positive is obviously stale, so it will be invalidated and a new one allocated.
If not created, then check whether it's the same inode (same as in ->d_revalidate()) and if not, invalidate & allocate new dentry.
Thanks,
Miklos
Quoted 30 lines · Vivek Goyal
Quoted 18 lines · Miklos Szeredi
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,
Miklosfs/namei.c +0
-0fs/namei.c static struct dentry *lookup_open(struct nameidata *nd, struct file *file, · line 3272
Quoted 7 lines
fs/namei.c +1
-1@@ -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,
Quoted 4 lines
I see that
lookup_open()callsd_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.
Yes.
Quoted 3 lines
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?
It should not fail in the stale dentry case either, just merge the revalidation into ->atomic_open().
Thanks,
Miklos