Commit 1f3208b2 authored by Trond Myklebust's avatar Trond Myklebust

NFS: Add a cache validity flag argument to nfs_revalidate_inode()

Add an argument to nfs_revalidate_inode() to allow callers to specify
which attributes they need to check for validity.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 1f9f4328
...@@ -3006,7 +3006,7 @@ int nfs_permission(struct user_namespace *mnt_userns, ...@@ -3006,7 +3006,7 @@ int nfs_permission(struct user_namespace *mnt_userns,
if (mask & MAY_NOT_BLOCK) if (mask & MAY_NOT_BLOCK)
return -ECHILD; return -ECHILD;
res = nfs_revalidate_inode(NFS_SERVER(inode), inode); res = nfs_revalidate_inode(inode, NFS_INO_INVALID_OTHER);
if (res == 0) if (res == 0)
res = generic_permission(&init_user_ns, inode, mask); res = generic_permission(&init_user_ns, inode, mask);
goto out; goto out;
......
...@@ -169,11 +169,7 @@ nfs_get_parent(struct dentry *dentry) ...@@ -169,11 +169,7 @@ nfs_get_parent(struct dentry *dentry)
static u64 nfs_fetch_iversion(struct inode *inode) static u64 nfs_fetch_iversion(struct inode *inode)
{ {
struct nfs_server *server = NFS_SERVER(inode); nfs_revalidate_inode(inode, NFS_INO_INVALID_CHANGE);
if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_CHANGE |
NFS_INO_REVAL_PAGECACHE))
__nfs_revalidate_inode(server, inode);
return inode_peek_iversion_raw(inode); return inode_peek_iversion_raw(inode);
} }
......
...@@ -802,16 +802,6 @@ static void nfs_readdirplus_parent_cache_hit(struct dentry *dentry) ...@@ -802,16 +802,6 @@ static void nfs_readdirplus_parent_cache_hit(struct dentry *dentry)
dput(parent); dput(parent);
} }
static bool nfs_need_revalidate_inode(struct inode *inode)
{
if (NFS_I(inode)->cache_validity &
(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_LABEL))
return true;
if (nfs_attribute_cache_expired(inode))
return true;
return false;
}
static u32 nfs_get_valid_attrmask(struct inode *inode) static u32 nfs_get_valid_attrmask(struct inode *inode)
{ {
unsigned long cache_validity = READ_ONCE(NFS_I(inode)->cache_validity); unsigned long cache_validity = READ_ONCE(NFS_I(inode)->cache_validity);
...@@ -1004,7 +994,6 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync) ...@@ -1004,7 +994,6 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
{ {
struct nfs_inode *nfsi; struct nfs_inode *nfsi;
struct inode *inode; struct inode *inode;
struct nfs_server *server;
if (!(ctx->mode & FMODE_WRITE)) if (!(ctx->mode & FMODE_WRITE))
return; return;
...@@ -1020,10 +1009,10 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync) ...@@ -1020,10 +1009,10 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
return; return;
if (!list_empty(&nfsi->open_files)) if (!list_empty(&nfsi->open_files))
return; return;
server = NFS_SERVER(inode); if (NFS_SERVER(inode)->flags & NFS_MOUNT_NOCTO)
if (server->flags & NFS_MOUNT_NOCTO)
return; return;
nfs_revalidate_inode(server, inode); nfs_revalidate_inode(inode,
NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_SIZE);
} }
EXPORT_SYMBOL_GPL(nfs_close_context); EXPORT_SYMBOL_GPL(nfs_close_context);
...@@ -1278,16 +1267,16 @@ int nfs_attribute_cache_expired(struct inode *inode) ...@@ -1278,16 +1267,16 @@ int nfs_attribute_cache_expired(struct inode *inode)
/** /**
* nfs_revalidate_inode - Revalidate the inode attributes * nfs_revalidate_inode - Revalidate the inode attributes
* @server: pointer to nfs_server struct
* @inode: pointer to inode struct * @inode: pointer to inode struct
* @flags: cache flags to check
* *
* Updates inode attribute information by retrieving the data from the server. * Updates inode attribute information by retrieving the data from the server.
*/ */
int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) int nfs_revalidate_inode(struct inode *inode, unsigned long flags)
{ {
if (!nfs_need_revalidate_inode(inode)) if (!nfs_check_cache_invalid(inode, flags))
return NFS_STALE(inode) ? -ESTALE : 0; return NFS_STALE(inode) ? -ESTALE : 0;
return __nfs_revalidate_inode(server, inode); return __nfs_revalidate_inode(NFS_SERVER(inode), inode);
} }
EXPORT_SYMBOL_GPL(nfs_revalidate_inode); EXPORT_SYMBOL_GPL(nfs_revalidate_inode);
......
...@@ -65,7 +65,7 @@ struct posix_acl *nfs3_get_acl(struct inode *inode, int type) ...@@ -65,7 +65,7 @@ struct posix_acl *nfs3_get_acl(struct inode *inode, int type)
if (!nfs_server_capable(inode, NFS_CAP_ACLS)) if (!nfs_server_capable(inode, NFS_CAP_ACLS))
return ERR_PTR(-EOPNOTSUPP); return ERR_PTR(-EOPNOTSUPP);
status = nfs_revalidate_inode(server, inode); status = nfs_revalidate_inode(inode, NFS_INO_INVALID_CHANGE);
if (status < 0) if (status < 0)
return ERR_PTR(status); return ERR_PTR(status);
......
...@@ -5868,7 +5868,7 @@ static ssize_t nfs4_proc_get_acl(struct inode *inode, void *buf, size_t buflen) ...@@ -5868,7 +5868,7 @@ static ssize_t nfs4_proc_get_acl(struct inode *inode, void *buf, size_t buflen)
if (!nfs4_server_supports_acls(server)) if (!nfs4_server_supports_acls(server))
return -EOPNOTSUPP; return -EOPNOTSUPP;
ret = nfs_revalidate_inode(server, inode); ret = nfs_revalidate_inode(inode, NFS_INO_INVALID_CHANGE);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (NFS_I(inode)->cache_validity & NFS_INO_INVALID_ACL) if (NFS_I(inode)->cache_validity & NFS_INO_INVALID_ACL)
...@@ -7619,7 +7619,7 @@ static int nfs4_xattr_get_nfs4_user(const struct xattr_handler *handler, ...@@ -7619,7 +7619,7 @@ static int nfs4_xattr_get_nfs4_user(const struct xattr_handler *handler,
return -EACCES; return -EACCES;
} }
ret = nfs_revalidate_inode(NFS_SERVER(inode), inode); ret = nfs_revalidate_inode(inode, NFS_INO_INVALID_CHANGE);
if (ret) if (ret)
return ret; return ret;
...@@ -7650,7 +7650,7 @@ nfs4_listxattr_nfs4_user(struct inode *inode, char *list, size_t list_len) ...@@ -7650,7 +7650,7 @@ nfs4_listxattr_nfs4_user(struct inode *inode, char *list, size_t list_len)
return 0; return 0;
} }
ret = nfs_revalidate_inode(NFS_SERVER(inode), inode); ret = nfs_revalidate_inode(inode, NFS_INO_INVALID_CHANGE);
if (ret) if (ret)
return ret; return ret;
......
...@@ -386,7 +386,7 @@ extern void nfs_access_set_mask(struct nfs_access_entry *, u32); ...@@ -386,7 +386,7 @@ extern void nfs_access_set_mask(struct nfs_access_entry *, u32);
extern int nfs_permission(struct user_namespace *, struct inode *, int); extern int nfs_permission(struct user_namespace *, struct inode *, int);
extern int nfs_open(struct inode *, struct file *); extern int nfs_open(struct inode *, struct file *);
extern int nfs_attribute_cache_expired(struct inode *inode); extern int nfs_attribute_cache_expired(struct inode *inode);
extern int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode); extern int nfs_revalidate_inode(struct inode *inode, unsigned long flags);
extern int __nfs_revalidate_inode(struct nfs_server *, struct inode *); extern int __nfs_revalidate_inode(struct nfs_server *, struct inode *);
extern int nfs_clear_invalid_mapping(struct address_space *mapping); extern int nfs_clear_invalid_mapping(struct address_space *mapping);
extern bool nfs_mapping_need_revalidate_inode(struct inode *inode); extern bool nfs_mapping_need_revalidate_inode(struct inode *inode);
......
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