]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
nfs/vfs: discard d_exact_alias()
authorNeilBrown <neilb@suse.de>
Wed, 26 Feb 2025 06:18:31 +0000 (17:18 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 12:55:17 +0000 (13:55 +0100)
[ Upstream commit 3ff6c8707c9a0116d00982851ec1216a42053ace ]

d_exact_alias() is a descendent of d_add_unique() which was introduced
20 years ago mostly likely to work around problems with NFS servers of
the time.  It is now not used in several situations were it was
originally needed and there have been no reports of problems -
presumably the old NFS servers have been improved.  This only place it
is now use is in NFSv4 code and the old problematic servers are thought
to have been v2/v3 only.

There is no clear benefit in reusing a unhashed() dentry which happens
to have the same name as the dentry we are adding.

So this patch removes d_exact_alias() and the one place that it is used.

Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Link: https://lore.kernel.org/r/20250226062135.2043651-2-neilb@suse.de
Signed-off-by: Christian Brauner <brauner@kernel.org>
Stable-dep-of: 0f900f11002f ("NFS: Initialise verifiers for visible dentries in _nfs4_open_and_get_state")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/dcache.c
fs/nfs/nfs4proc.c
include/linux/dcache.h

index d7814142ba7db3ff0316033703beecf328953e74..6b29026d25cbc6a9f1d9a1ac34ad78a83f5e64ab 100644 (file)
@@ -2664,52 +2664,6 @@ void d_add(struct dentry *entry, struct inode *inode)
 }
 EXPORT_SYMBOL(d_add);
 
-/**
- * d_exact_alias - find and hash an exact unhashed alias
- * @entry: dentry to add
- * @inode: The inode to go with this dentry
- *
- * If an unhashed dentry with the same name/parent and desired
- * inode already exists, hash and return it.  Otherwise, return
- * NULL.
- *
- * Parent directory should be locked.
- */
-struct dentry *d_exact_alias(struct dentry *entry, struct inode *inode)
-{
-       struct dentry *alias;
-       unsigned int hash = entry->d_name.hash;
-
-       spin_lock(&inode->i_lock);
-       hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) {
-               /*
-                * Don't need alias->d_lock here, because aliases with
-                * d_parent == entry->d_parent are not subject to name or
-                * parent changes, because the parent inode i_mutex is held.
-                */
-               if (alias->d_name.hash != hash)
-                       continue;
-               if (alias->d_parent != entry->d_parent)
-                       continue;
-               if (!d_same_name(alias, entry->d_parent, &entry->d_name))
-                       continue;
-               spin_lock(&alias->d_lock);
-               if (!d_unhashed(alias)) {
-                       spin_unlock(&alias->d_lock);
-                       alias = NULL;
-               } else {
-                       dget_dlock(alias);
-                       __d_rehash(alias);
-                       spin_unlock(&alias->d_lock);
-               }
-               spin_unlock(&inode->i_lock);
-               return alias;
-       }
-       spin_unlock(&inode->i_lock);
-       return NULL;
-}
-EXPORT_SYMBOL(d_exact_alias);
-
 static void swap_names(struct dentry *dentry, struct dentry *target)
 {
        if (unlikely(dname_external(target))) {
index 6342d360732d291c246fe69942138f1dc53854fe..7fe71aaa18666c9eebc212a78b93395a41a9c81f 100644 (file)
@@ -3152,9 +3152,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
        if (d_really_is_negative(dentry)) {
                struct dentry *alias;
                d_drop(dentry);
-               alias = d_exact_alias(dentry, state->inode);
-               if (!alias)
-                       alias = d_splice_alias(igrab(state->inode), dentry);
+               alias = d_splice_alias(igrab(state->inode), dentry);
                /* d_splice_alias() can't fail here - it's a non-directory */
                if (alias) {
                        dput(ctx->dentry);
index 3d53a60145911ea1fb3d8427ace62bf4905f17ff..51cc601b863d031d7b7888097592d4283af96915 100644 (file)
@@ -242,7 +242,6 @@ extern struct dentry * d_splice_alias(struct inode *, struct dentry *);
 extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qstr *);
 extern bool d_same_name(const struct dentry *dentry, const struct dentry *parent,
                        const struct qstr *name);
-extern struct dentry * d_exact_alias(struct dentry *, struct inode *);
 extern struct dentry *d_find_any_alias(struct inode *inode);
 extern struct dentry * d_obtain_alias(struct inode *);
 extern struct dentry * d_obtain_root(struct inode *);