mirror of https://gitee.com/openkylin/linux.git
NFS: Fix a readdir/lookup inefficiency.
Make sure that nfs_readdir_lookup() handles negative dentries correctly. If d_lookup() returns a negative dentry, then we need to d_drop() that since readdir shows that it should be positive. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
parent
ccfeb50623
commit
df1d5d23d3
10
fs/nfs/dir.c
10
fs/nfs/dir.c
|
@ -1123,8 +1123,14 @@ static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc)
|
||||||
}
|
}
|
||||||
name.hash = full_name_hash(name.name, name.len);
|
name.hash = full_name_hash(name.name, name.len);
|
||||||
dentry = d_lookup(parent, &name);
|
dentry = d_lookup(parent, &name);
|
||||||
if (dentry != NULL)
|
if (dentry != NULL) {
|
||||||
return dentry;
|
/* Is this a positive dentry? */
|
||||||
|
if (dentry->d_inode != NULL)
|
||||||
|
return dentry;
|
||||||
|
/* No, so d_drop to allow one to be created */
|
||||||
|
d_drop(dentry);
|
||||||
|
dput(dentry);
|
||||||
|
}
|
||||||
if (!desc->plus || !(entry->fattr->valid & NFS_ATTR_FATTR))
|
if (!desc->plus || !(entry->fattr->valid & NFS_ATTR_FATTR))
|
||||||
return NULL;
|
return NULL;
|
||||||
/* Note: caller is already holding the dir->i_mutex! */
|
/* Note: caller is already holding the dir->i_mutex! */
|
||||||
|
|
Loading…
Reference in New Issue