Commit 82e7ca13 authored by Trond Myklebust's avatar Trond Myklebust Committed by Anna Schumaker

NFS: Don't revalidate the directory permissions on a lookup failure

There should be no reason to expect the directory permissions to change
just because the directory contents changed or a negative lookup timed
out. So let's avoid doing a full call to nfs_mark_for_revalidate() in
that case.
Furthermore, if this is a negative dentry, and we haven't actually done
a new lookup, then we have no reason yet to believe the directory has
changed at all. So let's remove the gratuitous directory inode
invalidation altogether when called from
nfs_lookup_revalidate_negative().
Reported-by: default avatarGeert Jansen <gerardu@amazon.com>
Fixes: 5ceb9d7f ("NFS: Refactor nfs_lookup_revalidate()")
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent f0940f4b
...@@ -1401,6 +1401,15 @@ int nfs_lookup_verify_inode(struct inode *inode, unsigned int flags) ...@@ -1401,6 +1401,15 @@ int nfs_lookup_verify_inode(struct inode *inode, unsigned int flags)
goto out; goto out;
} }
static void nfs_mark_dir_for_revalidate(struct inode *inode)
{
struct nfs_inode *nfsi = NFS_I(inode);
spin_lock(&inode->i_lock);
nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE;
spin_unlock(&inode->i_lock);
}
/* /*
* We judge how long we want to trust negative * We judge how long we want to trust negative
* dentries by looking at the parent inode mtime. * dentries by looking at the parent inode mtime.
...@@ -1435,7 +1444,6 @@ nfs_lookup_revalidate_done(struct inode *dir, struct dentry *dentry, ...@@ -1435,7 +1444,6 @@ nfs_lookup_revalidate_done(struct inode *dir, struct dentry *dentry,
__func__, dentry); __func__, dentry);
return 1; return 1;
case 0: case 0:
nfs_mark_for_revalidate(dir);
if (inode && S_ISDIR(inode->i_mode)) { if (inode && S_ISDIR(inode->i_mode)) {
/* Purge readdir caches. */ /* Purge readdir caches. */
nfs_zap_caches(inode); nfs_zap_caches(inode);
...@@ -1525,6 +1533,13 @@ nfs_lookup_revalidate_dentry(struct inode *dir, struct dentry *dentry, ...@@ -1525,6 +1533,13 @@ nfs_lookup_revalidate_dentry(struct inode *dir, struct dentry *dentry,
nfs_free_fattr(fattr); nfs_free_fattr(fattr);
nfs_free_fhandle(fhandle); nfs_free_fhandle(fhandle);
nfs4_label_free(label); nfs4_label_free(label);
/*
* If the lookup failed despite the dentry change attribute being
* a match, then we should revalidate the directory cache.
*/
if (!ret && nfs_verify_change_attribute(dir, dentry->d_time))
nfs_mark_dir_for_revalidate(dir);
return nfs_lookup_revalidate_done(dir, dentry, inode, ret); return nfs_lookup_revalidate_done(dir, dentry, inode, ret);
} }
...@@ -1567,7 +1582,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry, ...@@ -1567,7 +1582,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
error = nfs_lookup_verify_inode(inode, flags); error = nfs_lookup_verify_inode(inode, flags);
if (error) { if (error) {
if (error == -ESTALE) if (error == -ESTALE)
nfs_zap_caches(dir); nfs_mark_dir_for_revalidate(dir);
goto out_bad; goto out_bad;
} }
nfs_advise_use_readdirplus(dir); nfs_advise_use_readdirplus(dir);
...@@ -2064,7 +2079,6 @@ nfs_add_or_obtain(struct dentry *dentry, struct nfs_fh *fhandle, ...@@ -2064,7 +2079,6 @@ nfs_add_or_obtain(struct dentry *dentry, struct nfs_fh *fhandle,
dput(parent); dput(parent);
return d; return d;
out_error: out_error:
nfs_mark_for_revalidate(dir);
d = ERR_PTR(error); d = ERR_PTR(error);
goto out; goto out;
} }
......
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