NFS: Don't request readdirplus when revalidation was forced

If the revalidation was forced, due to the presence of a LOOKUP_EXCL or
a LOOKUP_REVAL flag, then readdirplus won't help. It also can't help
when we're doing a path component lookup.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
This commit is contained in:
Trond Myklebust 2022-02-19 10:06:05 -05:00
parent 2c2c336506
commit 0b3cc71b5a
1 changed files with 16 additions and 10 deletions

View File

@ -694,10 +694,13 @@ void nfs_readdir_record_entry_cache_miss(struct inode *dir)
}
}
static void nfs_lookup_advise_force_readdirplus(struct inode *dir)
static void nfs_lookup_advise_force_readdirplus(struct inode *dir,
unsigned int flags)
{
if (nfs_server_capable(dir, NFS_CAP_CASE_INSENSITIVE))
return;
if (flags & (LOOKUP_EXCL | LOOKUP_PARENT | LOOKUP_REVAL))
return;
nfs_readdir_record_entry_cache_miss(dir);
}
@ -1596,15 +1599,17 @@ nfs_lookup_revalidate_delegated(struct inode *dir, struct dentry *dentry,
return nfs_lookup_revalidate_done(dir, dentry, inode, 1);
}
static int
nfs_lookup_revalidate_dentry(struct inode *dir, struct dentry *dentry,
struct inode *inode)
static int nfs_lookup_revalidate_dentry(struct inode *dir,
struct dentry *dentry,
struct inode *inode, unsigned int flags)
{
struct nfs_fh *fhandle;
struct nfs_fattr *fattr;
unsigned long dir_verifier;
int ret;
trace_nfs_lookup_revalidate_enter(dir, dentry, flags);
ret = -ENOMEM;
fhandle = nfs_alloc_fhandle();
fattr = nfs_alloc_fattr_with_label(NFS_SERVER(inode));
@ -1625,6 +1630,10 @@ nfs_lookup_revalidate_dentry(struct inode *dir, struct dentry *dentry,
}
goto out;
}
/* Request help from readdirplus */
nfs_lookup_advise_force_readdirplus(dir, flags);
ret = 0;
if (nfs_compare_fh(NFS_FH(inode), fhandle))
goto out;
@ -1634,8 +1643,6 @@ nfs_lookup_revalidate_dentry(struct inode *dir, struct dentry *dentry,
nfs_setsecurity(inode, fattr);
nfs_set_verifier(dentry, dir_verifier);
/* set a readdirplus hint that we had a cache miss */
nfs_lookup_advise_force_readdirplus(dir);
ret = 1;
out:
nfs_free_fattr(fattr);
@ -1701,8 +1708,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
if (NFS_STALE(inode))
goto out_bad;
trace_nfs_lookup_revalidate_enter(dir, dentry, flags);
return nfs_lookup_revalidate_dentry(dir, dentry, inode);
return nfs_lookup_revalidate_dentry(dir, dentry, inode, flags);
out_valid:
return nfs_lookup_revalidate_done(dir, dentry, inode, 1);
out_bad:
@ -1896,7 +1902,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
goto out;
/* Notify readdir to use READDIRPLUS */
nfs_lookup_advise_force_readdirplus(dir);
nfs_lookup_advise_force_readdirplus(dir, flags);
no_entry:
res = d_splice_alias(inode, dentry);
@ -2159,7 +2165,7 @@ nfs4_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
reval_dentry:
if (flags & LOOKUP_RCU)
return -ECHILD;
return nfs_lookup_revalidate_dentry(dir, dentry, inode);
return nfs_lookup_revalidate_dentry(dir, dentry, inode, flags);
full_reval:
return nfs_do_lookup_revalidate(dir, dentry, flags);