diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2019-11-04 22:30:52 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2019-11-15 13:49:04 -0500 |
commit | d41efb522e902364ab09c782d511c1bedc388ddd (patch) | |
tree | b68fc238833ef18e63add150a3217e82f0af450b /include | |
parent | 3e5aeec0e267d4422a4e740ce723549a3098a4d1 (diff) | |
download | lwn-d41efb522e902364ab09c782d511c1bedc388ddd.tar.gz lwn-d41efb522e902364ab09c782d511c1bedc388ddd.zip |
fs/namei.c: pull positivity check into follow_managed()
There are 4 callers; two proceed to check if result is positive and
fail with ENOENT if it isn't; one (in handle_lookup_down()) is
guaranteed to yield positive and one (in lookup_fast()) is _preceded_
by positivity check.
However, follow_managed() on a negative dentry is a (fairly cheap)
no-op on anything other than autofs. And negative autofs dentries
are never hashed, so lookup_fast() is not going to run into one
of those. Moreover, successful follow_managed() on a _positive_
dentry never yields a negative one (and we significantly rely upon
that in callers of lookup_fast()).
In other words, we can easily transpose the positivity check and
the call of follow_managed() in lookup_fast(). And that allows
to fold the positivity check *into* follow_managed(), simplifying
life for the code downstream of its calls.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/dcache.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 10090f11ab95..c1488cc84fd9 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -440,6 +440,11 @@ static inline bool d_is_negative(const struct dentry *dentry) return d_is_miss(dentry); } +static inline bool d_flags_negative(unsigned flags) +{ + return (flags & DCACHE_ENTRY_TYPE) == DCACHE_MISS_TYPE; +} + static inline bool d_is_positive(const struct dentry *dentry) { return !d_is_negative(dentry); |