Commit 0b3cc71b authored by Trond Myklebust's avatar Trond Myklebust

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: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 2c2c3365
...@@ -694,10 +694,13 @@ void nfs_readdir_record_entry_cache_miss(struct inode *dir) ...@@ -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)) if (nfs_server_capable(dir, NFS_CAP_CASE_INSENSITIVE))
return; return;
if (flags & (LOOKUP_EXCL | LOOKUP_PARENT | LOOKUP_REVAL))
return;
nfs_readdir_record_entry_cache_miss(dir); nfs_readdir_record_entry_cache_miss(dir);
} }
...@@ -1596,15 +1599,17 @@ nfs_lookup_revalidate_delegated(struct inode *dir, struct dentry *dentry, ...@@ -1596,15 +1599,17 @@ nfs_lookup_revalidate_delegated(struct inode *dir, struct dentry *dentry,
return nfs_lookup_revalidate_done(dir, dentry, inode, 1); return nfs_lookup_revalidate_done(dir, dentry, inode, 1);
} }
static int static int nfs_lookup_revalidate_dentry(struct inode *dir,
nfs_lookup_revalidate_dentry(struct inode *dir, struct dentry *dentry, struct dentry *dentry,
struct inode *inode) struct inode *inode, unsigned int flags)
{ {
struct nfs_fh *fhandle; struct nfs_fh *fhandle;
struct nfs_fattr *fattr; struct nfs_fattr *fattr;
unsigned long dir_verifier; unsigned long dir_verifier;
int ret; int ret;
trace_nfs_lookup_revalidate_enter(dir, dentry, flags);
ret = -ENOMEM; ret = -ENOMEM;
fhandle = nfs_alloc_fhandle(); fhandle = nfs_alloc_fhandle();
fattr = nfs_alloc_fattr_with_label(NFS_SERVER(inode)); fattr = nfs_alloc_fattr_with_label(NFS_SERVER(inode));
...@@ -1625,6 +1630,10 @@ nfs_lookup_revalidate_dentry(struct inode *dir, struct dentry *dentry, ...@@ -1625,6 +1630,10 @@ nfs_lookup_revalidate_dentry(struct inode *dir, struct dentry *dentry,
} }
goto out; goto out;
} }
/* Request help from readdirplus */
nfs_lookup_advise_force_readdirplus(dir, flags);
ret = 0; ret = 0;
if (nfs_compare_fh(NFS_FH(inode), fhandle)) if (nfs_compare_fh(NFS_FH(inode), fhandle))
goto out; goto out;
...@@ -1634,8 +1643,6 @@ nfs_lookup_revalidate_dentry(struct inode *dir, struct dentry *dentry, ...@@ -1634,8 +1643,6 @@ nfs_lookup_revalidate_dentry(struct inode *dir, struct dentry *dentry,
nfs_setsecurity(inode, fattr); nfs_setsecurity(inode, fattr);
nfs_set_verifier(dentry, dir_verifier); nfs_set_verifier(dentry, dir_verifier);
/* set a readdirplus hint that we had a cache miss */
nfs_lookup_advise_force_readdirplus(dir);
ret = 1; ret = 1;
out: out:
nfs_free_fattr(fattr); nfs_free_fattr(fattr);
...@@ -1701,8 +1708,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry, ...@@ -1701,8 +1708,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
if (NFS_STALE(inode)) if (NFS_STALE(inode))
goto out_bad; goto out_bad;
trace_nfs_lookup_revalidate_enter(dir, dentry, flags); return nfs_lookup_revalidate_dentry(dir, dentry, inode, flags);
return nfs_lookup_revalidate_dentry(dir, dentry, inode);
out_valid: out_valid:
return nfs_lookup_revalidate_done(dir, dentry, inode, 1); return nfs_lookup_revalidate_done(dir, dentry, inode, 1);
out_bad: out_bad:
...@@ -1896,7 +1902,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in ...@@ -1896,7 +1902,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
goto out; goto out;
/* Notify readdir to use READDIRPLUS */ /* Notify readdir to use READDIRPLUS */
nfs_lookup_advise_force_readdirplus(dir); nfs_lookup_advise_force_readdirplus(dir, flags);
no_entry: no_entry:
res = d_splice_alias(inode, dentry); res = d_splice_alias(inode, dentry);
...@@ -2159,7 +2165,7 @@ nfs4_do_lookup_revalidate(struct inode *dir, struct dentry *dentry, ...@@ -2159,7 +2165,7 @@ nfs4_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
reval_dentry: reval_dentry:
if (flags & LOOKUP_RCU) if (flags & LOOKUP_RCU)
return -ECHILD; return -ECHILD;
return nfs_lookup_revalidate_dentry(dir, dentry, inode); return nfs_lookup_revalidate_dentry(dir, dentry, inode, flags);
full_reval: full_reval:
return nfs_do_lookup_revalidate(dir, dentry, flags); return nfs_do_lookup_revalidate(dir, dentry, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment