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

NFS: Fix open coded versions of nfs_set_cache_invalid()

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 fd6d3fee
...@@ -81,8 +81,9 @@ static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode *dir ...@@ -81,8 +81,9 @@ static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode *dir
spin_lock(&dir->i_lock); spin_lock(&dir->i_lock);
if (list_empty(&nfsi->open_files) && if (list_empty(&nfsi->open_files) &&
(nfsi->cache_validity & NFS_INO_DATA_INVAL_DEFER)) (nfsi->cache_validity & NFS_INO_DATA_INVAL_DEFER))
nfsi->cache_validity |= NFS_INO_INVALID_DATA | nfs_set_cache_invalid(dir,
NFS_INO_REVAL_FORCED; NFS_INO_INVALID_DATA |
NFS_INO_REVAL_FORCED);
list_add(&ctx->list, &nfsi->open_files); list_add(&ctx->list, &nfsi->open_files);
spin_unlock(&dir->i_lock); spin_unlock(&dir->i_lock);
return ctx; return ctx;
...@@ -1700,10 +1701,9 @@ static void nfs_drop_nlink(struct inode *inode) ...@@ -1700,10 +1701,9 @@ static void nfs_drop_nlink(struct inode *inode)
if (inode->i_nlink > 0) if (inode->i_nlink > 0)
drop_nlink(inode); drop_nlink(inode);
NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter(); NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter();
NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE nfs_set_cache_invalid(
| NFS_INO_INVALID_CTIME inode, NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_CTIME |
| NFS_INO_INVALID_OTHER NFS_INO_INVALID_OTHER | NFS_INO_REVAL_FORCED);
| NFS_INO_REVAL_FORCED;
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
} }
...@@ -1715,7 +1715,7 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode) ...@@ -1715,7 +1715,7 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode)
{ {
if (S_ISDIR(inode->i_mode)) if (S_ISDIR(inode->i_mode))
/* drop any readdir cache as it could easily be old */ /* drop any readdir cache as it could easily be old */
NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA; nfs_set_cache_invalid(inode, NFS_INO_INVALID_DATA);
if (dentry->d_flags & DCACHE_NFSFS_RENAMED) { if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {
nfs_complete_unlink(dentry, inode); nfs_complete_unlink(dentry, inode);
...@@ -2481,9 +2481,9 @@ int nfs_rename(struct user_namespace *mnt_userns, struct inode *old_dir, ...@@ -2481,9 +2481,9 @@ int nfs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
if (error == 0) { if (error == 0) {
spin_lock(&old_inode->i_lock); spin_lock(&old_inode->i_lock);
NFS_I(old_inode)->attr_gencount = nfs_inc_attr_generation_counter(); NFS_I(old_inode)->attr_gencount = nfs_inc_attr_generation_counter();
NFS_I(old_inode)->cache_validity |= NFS_INO_INVALID_CHANGE nfs_set_cache_invalid(old_inode, NFS_INO_INVALID_CHANGE |
| NFS_INO_INVALID_CTIME NFS_INO_INVALID_CTIME |
| NFS_INO_REVAL_FORCED; NFS_INO_REVAL_FORCED);
spin_unlock(&old_inode->i_lock); spin_unlock(&old_inode->i_lock);
} }
out: out:
......
...@@ -1067,8 +1067,8 @@ void nfs_inode_attach_open_context(struct nfs_open_context *ctx) ...@@ -1067,8 +1067,8 @@ void nfs_inode_attach_open_context(struct nfs_open_context *ctx)
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
if (list_empty(&nfsi->open_files) && if (list_empty(&nfsi->open_files) &&
(nfsi->cache_validity & NFS_INO_DATA_INVAL_DEFER)) (nfsi->cache_validity & NFS_INO_DATA_INVAL_DEFER))
nfsi->cache_validity |= NFS_INO_INVALID_DATA | nfs_set_cache_invalid(inode, NFS_INO_INVALID_DATA |
NFS_INO_REVAL_FORCED; NFS_INO_REVAL_FORCED);
list_add_tail_rcu(&ctx->list, &nfsi->open_files); list_add_tail_rcu(&ctx->list, &nfsi->open_files);
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
} }
......
...@@ -500,9 +500,9 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry) ...@@ -500,9 +500,9 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)
nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter(); NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter();
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);
d_move(dentry, sdentry); d_move(dentry, sdentry);
break; break;
......
...@@ -303,9 +303,9 @@ static void nfs_set_pageerror(struct address_space *mapping) ...@@ -303,9 +303,9 @@ static void nfs_set_pageerror(struct address_space *mapping)
nfs_zap_mapping(mapping->host, mapping); nfs_zap_mapping(mapping->host, mapping);
/* Force file size revalidation */ /* Force file size revalidation */
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
NFS_I(inode)->cache_validity |= NFS_INO_REVAL_FORCED | nfs_set_cache_invalid(inode, NFS_INO_REVAL_FORCED |
NFS_INO_REVAL_PAGECACHE | NFS_INO_REVAL_PAGECACHE |
NFS_INO_INVALID_SIZE; NFS_INO_INVALID_SIZE);
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
} }
...@@ -1604,7 +1604,7 @@ static int nfs_writeback_done(struct rpc_task *task, ...@@ -1604,7 +1604,7 @@ static int nfs_writeback_done(struct rpc_task *task,
/* Deal with the suid/sgid bit corner case */ /* Deal with the suid/sgid bit corner case */
if (nfs_should_remove_suid(inode)) { if (nfs_should_remove_suid(inode)) {
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
NFS_I(inode)->cache_validity |= NFS_INO_INVALID_OTHER; nfs_set_cache_invalid(inode, NFS_INO_INVALID_OTHER);
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
} }
return 0; return 0;
......
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