mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
dcache: touch up predicts in __d_lookup_rcu()
Rationale is that if the parent dentry is the same and the length is the
same, then you have to be unlucky for the name to not match.
At the same time the dentry was literally just found on the hash, so you
have to be even more unlucky to determine it is unhashed.
While here add commentary while d_unhashed() is necessary. It was
already removed once and brought back in:
2e321806b6 ("Revert "vfs: remove unnecessary d_unhashed() check from __d_lookup_rcu"")
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Link: https://patch.msgid.link/20251127131526.4137768-1-mjguzik@gmail.com
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
committed by
Christian Brauner
parent
003a660730
commit
ca0d620b0a
15
fs/dcache.c
15
fs/dcache.c
@@ -2300,11 +2300,20 @@ struct dentry *__d_lookup_rcu(const struct dentry *parent,
|
||||
seq = raw_seqcount_begin(&dentry->d_seq);
|
||||
if (dentry->d_parent != parent)
|
||||
continue;
|
||||
if (d_unhashed(dentry))
|
||||
continue;
|
||||
if (dentry->d_name.hash_len != hashlen)
|
||||
continue;
|
||||
if (dentry_cmp(dentry, str, hashlen_len(hashlen)) != 0)
|
||||
if (unlikely(dentry_cmp(dentry, str, hashlen_len(hashlen)) != 0))
|
||||
continue;
|
||||
/*
|
||||
* Check for the dentry being unhashed.
|
||||
*
|
||||
* As tempting as it is, we *can't* skip it because of a race window
|
||||
* between us finding the dentry before it gets unhashed and loading
|
||||
* the sequence counter after unhashing is finished.
|
||||
*
|
||||
* We can at least predict on it.
|
||||
*/
|
||||
if (unlikely(d_unhashed(dentry)))
|
||||
continue;
|
||||
*seqp = seq;
|
||||
return dentry;
|
||||
|
||||
Reference in New Issue
Block a user