Commit 21c3ba7e authored by Trond Myklebust's avatar Trond Myklebust

NFS: Fix and clean up the access cache validity checking

The access cache needs to check whether or not the mode bits, ownership,
or ACL has changed or the cache has timed out.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent 9cdd1d3f
...@@ -2286,8 +2286,7 @@ static int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, str ...@@ -2286,8 +2286,7 @@ static int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, str
if (cache == NULL) if (cache == NULL)
goto out; goto out;
/* Found an entry, is our attribute cache valid? */ /* Found an entry, is our attribute cache valid? */
if (!nfs_attribute_cache_expired(inode) && if (!nfs_check_cache_invalid(inode, NFS_INO_INVALID_ACCESS))
!(nfsi->cache_validity & NFS_INO_INVALID_ATTR))
break; break;
err = -ECHILD; err = -ECHILD;
if (!may_block) if (!may_block)
...@@ -2335,12 +2334,12 @@ static int nfs_access_get_cached_rcu(struct inode *inode, struct rpc_cred *cred, ...@@ -2335,12 +2334,12 @@ static int nfs_access_get_cached_rcu(struct inode *inode, struct rpc_cred *cred,
cache = NULL; cache = NULL;
if (cache == NULL) if (cache == NULL)
goto out; goto out;
err = nfs_revalidate_inode_rcu(NFS_SERVER(inode), inode); if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_ACCESS))
if (err)
goto out; goto out;
res->jiffies = cache->jiffies; res->jiffies = cache->jiffies;
res->cred = cache->cred; res->cred = cache->cred;
res->mask = cache->mask; res->mask = cache->mask;
err = 0;
out: out:
rcu_read_unlock(); rcu_read_unlock();
return err; return err;
...@@ -2492,12 +2491,13 @@ EXPORT_SYMBOL_GPL(nfs_may_open); ...@@ -2492,12 +2491,13 @@ EXPORT_SYMBOL_GPL(nfs_may_open);
static int nfs_execute_ok(struct inode *inode, int mask) static int nfs_execute_ok(struct inode *inode, int mask)
{ {
struct nfs_server *server = NFS_SERVER(inode); struct nfs_server *server = NFS_SERVER(inode);
int ret; int ret = 0;
if (mask & MAY_NOT_BLOCK) if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_ACCESS)) {
ret = nfs_revalidate_inode_rcu(server, inode); if (mask & MAY_NOT_BLOCK)
else return -ECHILD;
ret = nfs_revalidate_inode(server, inode); ret = __nfs_revalidate_inode(server, inode);
}
if (ret == 0 && !execute_ok(inode)) if (ret == 0 && !execute_ok(inode))
ret = -EACCES; ret = -EACCES;
return ret; return ret;
......
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