Skip to content

Commit 3ff6c87

Browse files
neilbrownbrauner
authored andcommitted
nfs/vfs: discard d_exact_alias()
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 <[email protected]> Signed-off-by: NeilBrown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent d082ecb commit 3ff6c87

File tree

3 files changed

+1
-50
lines changed

3 files changed

+1
-50
lines changed

fs/dcache.c

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2687,52 +2687,6 @@ void d_add(struct dentry *entry, struct inode *inode)
26872687
}
26882688
EXPORT_SYMBOL(d_add);
26892689

2690-
/**
2691-
* d_exact_alias - find and hash an exact unhashed alias
2692-
* @entry: dentry to add
2693-
* @inode: The inode to go with this dentry
2694-
*
2695-
* If an unhashed dentry with the same name/parent and desired
2696-
* inode already exists, hash and return it. Otherwise, return
2697-
* NULL.
2698-
*
2699-
* Parent directory should be locked.
2700-
*/
2701-
struct dentry *d_exact_alias(struct dentry *entry, struct inode *inode)
2702-
{
2703-
struct dentry *alias;
2704-
unsigned int hash = entry->d_name.hash;
2705-
2706-
spin_lock(&inode->i_lock);
2707-
hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) {
2708-
/*
2709-
* Don't need alias->d_lock here, because aliases with
2710-
* d_parent == entry->d_parent are not subject to name or
2711-
* parent changes, because the parent inode i_mutex is held.
2712-
*/
2713-
if (alias->d_name.hash != hash)
2714-
continue;
2715-
if (alias->d_parent != entry->d_parent)
2716-
continue;
2717-
if (!d_same_name(alias, entry->d_parent, &entry->d_name))
2718-
continue;
2719-
spin_lock(&alias->d_lock);
2720-
if (!d_unhashed(alias)) {
2721-
spin_unlock(&alias->d_lock);
2722-
alias = NULL;
2723-
} else {
2724-
dget_dlock(alias);
2725-
__d_rehash(alias);
2726-
spin_unlock(&alias->d_lock);
2727-
}
2728-
spin_unlock(&inode->i_lock);
2729-
return alias;
2730-
}
2731-
spin_unlock(&inode->i_lock);
2732-
return NULL;
2733-
}
2734-
EXPORT_SYMBOL(d_exact_alias);
2735-
27362690
static void swap_names(struct dentry *dentry, struct dentry *target)
27372691
{
27382692
if (unlikely(dname_external(target))) {

fs/nfs/nfs4proc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3153,9 +3153,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
31533153
if (d_really_is_negative(dentry)) {
31543154
struct dentry *alias;
31553155
d_drop(dentry);
3156-
alias = d_exact_alias(dentry, state->inode);
3157-
if (!alias)
3158-
alias = d_splice_alias(igrab(state->inode), dentry);
3156+
alias = d_splice_alias(igrab(state->inode), dentry);
31593157
/* d_splice_alias() can't fail here - it's a non-directory */
31603158
if (alias) {
31613159
dput(ctx->dentry);

include/linux/dcache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ extern struct dentry * d_splice_alias(struct inode *, struct dentry *);
253253
extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qstr *);
254254
extern bool d_same_name(const struct dentry *dentry, const struct dentry *parent,
255255
const struct qstr *name);
256-
extern struct dentry * d_exact_alias(struct dentry *, struct inode *);
257256
extern struct dentry *d_find_any_alias(struct inode *inode);
258257
extern struct dentry * d_obtain_alias(struct inode *);
259258
extern struct dentry * d_obtain_root(struct inode *);

0 commit comments

Comments
 (0)