Commit cc7f2dae authored by Trond Myklebust's avatar Trond Myklebust

NFS: Don't store NFS_INO_REVAL_FORCED

NFS_INO_REVAL_FORCED is intended to tell us that the cache needs
revalidation despite the fact that we hold a delegation. We shouldn't
need to store it anymore, though.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 1301e421
...@@ -481,6 +481,22 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, ...@@ -481,6 +481,22 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred,
if (freeme == NULL) if (freeme == NULL)
goto out; goto out;
add_new: add_new:
/*
* If we didn't revalidate the change attribute before setting
* the delegation, then pre-emptively ask for a full attribute
* cache revalidation.
*/
spin_lock(&inode->i_lock);
if (NFS_I(inode)->cache_validity & NFS_INO_INVALID_CHANGE)
nfs_set_cache_invalid(inode,
NFS_INO_INVALID_ATIME | NFS_INO_INVALID_CTIME |
NFS_INO_INVALID_MTIME | NFS_INO_INVALID_SIZE |
NFS_INO_INVALID_BLOCKS | NFS_INO_INVALID_NLINK |
NFS_INO_INVALID_OTHER | NFS_INO_INVALID_DATA |
NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL |
NFS_INO_INVALID_XATTR);
spin_unlock(&inode->i_lock);
list_add_tail_rcu(&delegation->super_list, &server->delegations); list_add_tail_rcu(&delegation->super_list, &server->delegations);
rcu_assign_pointer(nfsi->delegation, delegation); rcu_assign_pointer(nfsi->delegation, delegation);
delegation = NULL; delegation = NULL;
...@@ -488,11 +504,6 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred, ...@@ -488,11 +504,6 @@ int nfs_inode_set_delegation(struct inode *inode, const struct cred *cred,
atomic_long_inc(&nfs_active_delegations); atomic_long_inc(&nfs_active_delegations);
trace_nfs4_set_delegation(inode, type); trace_nfs4_set_delegation(inode, type);
spin_lock(&inode->i_lock);
if (NFS_I(inode)->cache_validity & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME))
NFS_I(inode)->cache_validity |= NFS_INO_REVAL_FORCED;
spin_unlock(&inode->i_lock);
out: out:
spin_unlock(&clp->cl_lock); spin_unlock(&clp->cl_lock);
if (delegation != NULL) if (delegation != NULL)
......
...@@ -84,8 +84,7 @@ int nfs4_inode_make_writeable(struct inode *inode); ...@@ -84,8 +84,7 @@ int nfs4_inode_make_writeable(struct inode *inode);
static inline int nfs_have_delegated_attributes(struct inode *inode) static inline int nfs_have_delegated_attributes(struct inode *inode)
{ {
return NFS_PROTO(inode)->have_delegation(inode, FMODE_READ) && return NFS_PROTO(inode)->have_delegation(inode, FMODE_READ);
!(NFS_I(inode)->cache_validity & NFS_INO_REVAL_FORCED);
} }
#endif #endif
...@@ -200,21 +200,19 @@ void nfs_set_cache_invalid(struct inode *inode, unsigned long flags) ...@@ -200,21 +200,19 @@ void nfs_set_cache_invalid(struct inode *inode, unsigned long flags)
if (have_delegation) { if (have_delegation) {
if (!(flags & NFS_INO_REVAL_FORCED)) if (!(flags & NFS_INO_REVAL_FORCED))
flags &= ~(NFS_INO_INVALID_MODE | flags &= ~(NFS_INO_INVALID_MODE |
NFS_INO_INVALID_OTHER); NFS_INO_INVALID_OTHER |
flags &= ~(NFS_INO_INVALID_CHANGE NFS_INO_INVALID_XATTR);
| NFS_INO_INVALID_SIZE flags &= ~(NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_SIZE);
| NFS_INO_INVALID_XATTR);
} else if (flags & NFS_INO_REVAL_PAGECACHE) } else if (flags & NFS_INO_REVAL_PAGECACHE)
flags |= NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_SIZE; flags |= NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_SIZE;
flags &= ~NFS_INO_REVAL_PAGECACHE;
if (!nfs_has_xattr_cache(nfsi)) if (!nfs_has_xattr_cache(nfsi))
flags &= ~NFS_INO_INVALID_XATTR; flags &= ~NFS_INO_INVALID_XATTR;
if (flags & NFS_INO_INVALID_DATA) if (flags & NFS_INO_INVALID_DATA)
nfs_fscache_invalidate(inode); nfs_fscache_invalidate(inode);
if (inode->i_mapping->nrpages == 0) if (inode->i_mapping->nrpages == 0)
flags &= ~(NFS_INO_INVALID_DATA|NFS_INO_DATA_INVAL_DEFER); flags &= ~(NFS_INO_INVALID_DATA|NFS_INO_DATA_INVAL_DEFER);
flags &= ~(NFS_INO_REVAL_PAGECACHE | NFS_INO_REVAL_FORCED);
nfsi->cache_validity |= flags; nfsi->cache_validity |= flags;
} }
EXPORT_SYMBOL_GPL(nfs_set_cache_invalid); EXPORT_SYMBOL_GPL(nfs_set_cache_invalid);
...@@ -560,9 +558,6 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st ...@@ -560,9 +558,6 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st
} else if (fattr->size != 0) } else if (fattr->size != 0)
nfs_set_cache_invalid(inode, NFS_INO_INVALID_BLOCKS); nfs_set_cache_invalid(inode, NFS_INO_INVALID_BLOCKS);
if (nfsi->cache_validity != 0)
nfsi->cache_validity |= NFS_INO_REVAL_FORCED;
nfs_setsecurity(inode, fattr, label); nfs_setsecurity(inode, fattr, label);
nfsi->attrtimeo = NFS_MINATTRTIMEO(inode); nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
...@@ -2032,7 +2027,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) ...@@ -2032,7 +2027,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
save_cache_validity & save_cache_validity &
(NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_CTIME | (NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_CTIME |
NFS_INO_INVALID_MTIME | NFS_INO_INVALID_SIZE | NFS_INO_INVALID_MTIME | NFS_INO_INVALID_SIZE |
NFS_INO_REVAL_FORCED); NFS_INO_INVALID_BLOCKS);
cache_revalidated = false; cache_revalidated = false;
} }
...@@ -2064,27 +2059,24 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) ...@@ -2064,27 +2059,24 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
attr_changed = true; attr_changed = true;
} }
} else { } else {
nfsi->cache_validity |= save_cache_validity & nfsi->cache_validity |=
(NFS_INO_INVALID_CHANGE save_cache_validity & NFS_INO_INVALID_CHANGE;
| NFS_INO_REVAL_FORCED);
cache_revalidated = false; cache_revalidated = false;
} }
if (fattr->valid & NFS_ATTR_FATTR_MTIME) { if (fattr->valid & NFS_ATTR_FATTR_MTIME) {
inode->i_mtime = fattr->mtime; inode->i_mtime = fattr->mtime;
} else if (server->caps & NFS_CAP_MTIME) { } else if (server->caps & NFS_CAP_MTIME) {
nfsi->cache_validity |= save_cache_validity & nfsi->cache_validity |=
(NFS_INO_INVALID_MTIME save_cache_validity & NFS_INO_INVALID_MTIME;
| NFS_INO_REVAL_FORCED);
cache_revalidated = false; cache_revalidated = false;
} }
if (fattr->valid & NFS_ATTR_FATTR_CTIME) { if (fattr->valid & NFS_ATTR_FATTR_CTIME) {
inode->i_ctime = fattr->ctime; inode->i_ctime = fattr->ctime;
} else if (server->caps & NFS_CAP_CTIME) { } else if (server->caps & NFS_CAP_CTIME) {
nfsi->cache_validity |= save_cache_validity & nfsi->cache_validity |=
(NFS_INO_INVALID_CTIME save_cache_validity & NFS_INO_INVALID_CTIME;
| NFS_INO_REVAL_FORCED);
cache_revalidated = false; cache_revalidated = false;
} }
...@@ -2115,19 +2107,16 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) ...@@ -2115,19 +2107,16 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
fattr->valid |= NFS_ATTR_FATTR_SPACE_USED; fattr->valid |= NFS_ATTR_FATTR_SPACE_USED;
} }
} else { } else {
nfsi->cache_validity |= save_cache_validity & nfsi->cache_validity |=
(NFS_INO_INVALID_SIZE save_cache_validity & NFS_INO_INVALID_SIZE;
| NFS_INO_REVAL_FORCED);
cache_revalidated = false; cache_revalidated = false;
} }
if (fattr->valid & NFS_ATTR_FATTR_ATIME) if (fattr->valid & NFS_ATTR_FATTR_ATIME)
inode->i_atime = fattr->atime; inode->i_atime = fattr->atime;
else if (server->caps & NFS_CAP_ATIME) { else if (server->caps & NFS_CAP_ATIME) {
nfsi->cache_validity |= save_cache_validity & nfsi->cache_validity |=
(NFS_INO_INVALID_ATIME save_cache_validity & NFS_INO_INVALID_ATIME;
| NFS_INO_REVAL_FORCED);
cache_revalidated = false; cache_revalidated = false;
} }
...@@ -2141,9 +2130,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) ...@@ -2141,9 +2130,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
attr_changed = true; attr_changed = true;
} }
} else if (server->caps & NFS_CAP_MODE) { } else if (server->caps & NFS_CAP_MODE) {
nfsi->cache_validity |= save_cache_validity & nfsi->cache_validity |=
(NFS_INO_INVALID_MODE save_cache_validity & NFS_INO_INVALID_MODE;
| NFS_INO_REVAL_FORCED);
cache_revalidated = false; cache_revalidated = false;
} }
...@@ -2155,9 +2143,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) ...@@ -2155,9 +2143,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
attr_changed = true; attr_changed = true;
} }
} else if (server->caps & NFS_CAP_OWNER) { } else if (server->caps & NFS_CAP_OWNER) {
nfsi->cache_validity |= save_cache_validity & nfsi->cache_validity |=
(NFS_INO_INVALID_OTHER save_cache_validity & NFS_INO_INVALID_OTHER;
| NFS_INO_REVAL_FORCED);
cache_revalidated = false; cache_revalidated = false;
} }
...@@ -2169,9 +2156,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) ...@@ -2169,9 +2156,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
attr_changed = true; attr_changed = true;
} }
} else if (server->caps & NFS_CAP_OWNER_GROUP) { } else if (server->caps & NFS_CAP_OWNER_GROUP) {
nfsi->cache_validity |= save_cache_validity & nfsi->cache_validity |=
(NFS_INO_INVALID_OTHER save_cache_validity & NFS_INO_INVALID_OTHER;
| NFS_INO_REVAL_FORCED);
cache_revalidated = false; cache_revalidated = false;
} }
...@@ -2183,9 +2169,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) ...@@ -2183,9 +2169,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
attr_changed = true; attr_changed = true;
} }
} else if (server->caps & NFS_CAP_NLINK) { } else if (server->caps & NFS_CAP_NLINK) {
nfsi->cache_validity |= save_cache_validity & nfsi->cache_validity |=
(NFS_INO_INVALID_NLINK save_cache_validity & NFS_INO_INVALID_NLINK;
| NFS_INO_REVAL_FORCED);
cache_revalidated = false; cache_revalidated = false;
} }
...@@ -2197,9 +2182,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) ...@@ -2197,9 +2182,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
} else if (fattr->valid & NFS_ATTR_FATTR_BLOCKS_USED) } else if (fattr->valid & NFS_ATTR_FATTR_BLOCKS_USED)
inode->i_blocks = fattr->du.nfs2.blocks; inode->i_blocks = fattr->du.nfs2.blocks;
else { else {
nfsi->cache_validity |= save_cache_validity & nfsi->cache_validity |=
(NFS_INO_INVALID_BLOCKS save_cache_validity & NFS_INO_INVALID_BLOCKS;
| NFS_INO_REVAL_FORCED);
cache_revalidated = false; cache_revalidated = false;
} }
......
...@@ -5477,10 +5477,7 @@ static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src, ...@@ -5477,10 +5477,7 @@ static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src,
if (cache_validity & NFS_INO_INVALID_BLOCKS) if (cache_validity & NFS_INO_INVALID_BLOCKS)
bitmask[1] |= FATTR4_WORD1_SPACE_USED; bitmask[1] |= FATTR4_WORD1_SPACE_USED;
if (nfs4_have_delegation(inode, FMODE_READ) && if (cache_validity & NFS_INO_INVALID_SIZE)
!(cache_validity & NFS_INO_REVAL_FORCED))
bitmask[0] &= ~FATTR4_WORD0_SIZE;
else if (cache_validity & NFS_INO_INVALID_SIZE)
bitmask[0] |= FATTR4_WORD0_SIZE; bitmask[0] |= FATTR4_WORD0_SIZE;
for (i = 0; i < NFS4_BITMASK_SZ; i++) for (i = 0; i < NFS4_BITMASK_SZ; i++)
......
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