Commit b6f80a2e authored by Trond Myklebust's avatar Trond Myklebust Committed by Anna Schumaker

NFS: Fix open coded versions of nfs_set_cache_invalid() in NFSv4

nfs_set_cache_invalid() has code to handle delegations, and other
optimisations, so let's use it when appropriate.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent ac46b3d7
...@@ -229,6 +229,7 @@ void nfs_set_cache_invalid(struct inode *inode, unsigned long flags) ...@@ -229,6 +229,7 @@ void nfs_set_cache_invalid(struct inode *inode, unsigned long flags)
if (flags & NFS_INO_INVALID_DATA) if (flags & NFS_INO_INVALID_DATA)
nfs_fscache_invalidate(inode); nfs_fscache_invalidate(inode);
} }
EXPORT_SYMBOL_GPL(nfs_set_cache_invalid);
/* /*
* Invalidate the local caches * Invalidate the local caches
......
...@@ -357,13 +357,15 @@ static ssize_t _nfs42_proc_copy(struct file *src, ...@@ -357,13 +357,15 @@ static ssize_t _nfs42_proc_copy(struct file *src,
truncate_pagecache_range(dst_inode, pos_dst, truncate_pagecache_range(dst_inode, pos_dst,
pos_dst + res->write_res.count); pos_dst + res->write_res.count);
spin_lock(&dst_inode->i_lock); spin_lock(&dst_inode->i_lock);
NFS_I(dst_inode)->cache_validity |= (NFS_INO_REVAL_PAGECACHE | nfs_set_cache_invalid(
NFS_INO_REVAL_FORCED | NFS_INO_INVALID_SIZE | dst_inode, NFS_INO_REVAL_PAGECACHE | NFS_INO_REVAL_FORCED |
NFS_INO_INVALID_ATTR | NFS_INO_INVALID_DATA); NFS_INO_INVALID_SIZE | NFS_INO_INVALID_ATTR |
NFS_INO_INVALID_DATA);
spin_unlock(&dst_inode->i_lock); spin_unlock(&dst_inode->i_lock);
spin_lock(&src_inode->i_lock); spin_lock(&src_inode->i_lock);
NFS_I(src_inode)->cache_validity |= (NFS_INO_REVAL_PAGECACHE | nfs_set_cache_invalid(src_inode, NFS_INO_REVAL_PAGECACHE |
NFS_INO_REVAL_FORCED | NFS_INO_INVALID_ATIME); NFS_INO_REVAL_FORCED |
NFS_INO_INVALID_ATIME);
spin_unlock(&src_inode->i_lock); spin_unlock(&src_inode->i_lock);
status = res->write_res.count; status = res->write_res.count;
out: out:
......
...@@ -1169,14 +1169,14 @@ int nfs4_call_sync(struct rpc_clnt *clnt, ...@@ -1169,14 +1169,14 @@ int nfs4_call_sync(struct rpc_clnt *clnt,
static void static void
nfs4_inc_nlink_locked(struct inode *inode) nfs4_inc_nlink_locked(struct inode *inode)
{ {
NFS_I(inode)->cache_validity |= NFS_INO_INVALID_OTHER; nfs_set_cache_invalid(inode, NFS_INO_INVALID_OTHER);
inc_nlink(inode); inc_nlink(inode);
} }
static void static void
nfs4_dec_nlink_locked(struct inode *inode) nfs4_dec_nlink_locked(struct inode *inode)
{ {
NFS_I(inode)->cache_validity |= NFS_INO_INVALID_OTHER; nfs_set_cache_invalid(inode, NFS_INO_INVALID_OTHER);
drop_nlink(inode); drop_nlink(inode);
} }
...@@ -1187,35 +1187,31 @@ nfs4_update_changeattr_locked(struct inode *inode, ...@@ -1187,35 +1187,31 @@ nfs4_update_changeattr_locked(struct inode *inode,
{ {
struct nfs_inode *nfsi = NFS_I(inode); struct nfs_inode *nfsi = NFS_I(inode);
nfsi->cache_validity |= NFS_INO_INVALID_CTIME cache_validity |= NFS_INO_INVALID_CTIME | NFS_INO_INVALID_MTIME;
| NFS_INO_INVALID_MTIME
| cache_validity;
if (cinfo->atomic && cinfo->before == inode_peek_iversion_raw(inode)) { if (cinfo->atomic && cinfo->before == inode_peek_iversion_raw(inode)) {
nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE; nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE;
nfsi->attrtimeo_timestamp = jiffies; nfsi->attrtimeo_timestamp = jiffies;
} else { } else {
if (S_ISDIR(inode->i_mode)) { if (S_ISDIR(inode->i_mode)) {
nfsi->cache_validity |= NFS_INO_INVALID_DATA; cache_validity |= NFS_INO_INVALID_DATA;
nfs_force_lookup_revalidate(inode); nfs_force_lookup_revalidate(inode);
} else { } else {
if (!NFS_PROTO(inode)->have_delegation(inode, if (!NFS_PROTO(inode)->have_delegation(inode,
FMODE_READ)) FMODE_READ))
nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE; cache_validity |= NFS_INO_REVAL_PAGECACHE;
} }
if (cinfo->before != inode_peek_iversion_raw(inode)) if (cinfo->before != inode_peek_iversion_raw(inode))
nfsi->cache_validity |= NFS_INO_INVALID_ACCESS | cache_validity |= NFS_INO_INVALID_ACCESS |
NFS_INO_INVALID_ACL | NFS_INO_INVALID_ACL |
NFS_INO_INVALID_XATTR; NFS_INO_INVALID_XATTR;
} }
inode_set_iversion_raw(inode, cinfo->after); inode_set_iversion_raw(inode, cinfo->after);
nfsi->read_cache_jiffies = timestamp; nfsi->read_cache_jiffies = timestamp;
nfsi->attr_gencount = nfs_inc_attr_generation_counter(); nfsi->attr_gencount = nfs_inc_attr_generation_counter();
nfs_set_cache_invalid(inode, cache_validity);
nfsi->cache_validity &= ~NFS_INO_INVALID_CHANGE; nfsi->cache_validity &= ~NFS_INO_INVALID_CHANGE;
if (nfsi->cache_validity & NFS_INO_INVALID_DATA)
nfs_fscache_invalidate(inode);
} }
void void
...@@ -5915,9 +5911,9 @@ static int __nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t bufl ...@@ -5915,9 +5911,9 @@ static int __nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t bufl
* so mark the attribute cache invalid. * so mark the attribute cache invalid.
*/ */
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE |
| NFS_INO_INVALID_CTIME NFS_INO_INVALID_CTIME |
| NFS_INO_REVAL_FORCED; NFS_INO_REVAL_FORCED);
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
nfs_access_zap_cache(inode); nfs_access_zap_cache(inode);
nfs_zap_acl_cache(inode); nfs_zap_acl_cache(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