Skip to content

Commit ac46b3d

Browse files
Trond Myklebustamschuma-ntap
authored andcommitted
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: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent fd6d3fe commit ac46b3d

4 files changed

Lines changed: 19 additions & 19 deletions

File tree

fs/nfs/dir.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode *dir
8181
spin_lock(&dir->i_lock);
8282
if (list_empty(&nfsi->open_files) &&
8383
(nfsi->cache_validity & NFS_INO_DATA_INVAL_DEFER))
84-
nfsi->cache_validity |= NFS_INO_INVALID_DATA |
85-
NFS_INO_REVAL_FORCED;
84+
nfs_set_cache_invalid(dir,
85+
NFS_INO_INVALID_DATA |
86+
NFS_INO_REVAL_FORCED);
8687
list_add(&ctx->list, &nfsi->open_files);
8788
spin_unlock(&dir->i_lock);
8889
return ctx;
@@ -1700,10 +1701,9 @@ static void nfs_drop_nlink(struct inode *inode)
17001701
if (inode->i_nlink > 0)
17011702
drop_nlink(inode);
17021703
NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter();
1703-
NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE
1704-
| NFS_INO_INVALID_CTIME
1705-
| NFS_INO_INVALID_OTHER
1706-
| NFS_INO_REVAL_FORCED;
1704+
nfs_set_cache_invalid(
1705+
inode, NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_CTIME |
1706+
NFS_INO_INVALID_OTHER | NFS_INO_REVAL_FORCED);
17071707
spin_unlock(&inode->i_lock);
17081708
}
17091709

@@ -1715,7 +1715,7 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode)
17151715
{
17161716
if (S_ISDIR(inode->i_mode))
17171717
/* drop any readdir cache as it could easily be old */
1718-
NFS_I(inode)->cache_validity |= NFS_INO_INVALID_DATA;
1718+
nfs_set_cache_invalid(inode, NFS_INO_INVALID_DATA);
17191719

17201720
if (dentry->d_flags & DCACHE_NFSFS_RENAMED) {
17211721
nfs_complete_unlink(dentry, inode);
@@ -2481,9 +2481,9 @@ int nfs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
24812481
if (error == 0) {
24822482
spin_lock(&old_inode->i_lock);
24832483
NFS_I(old_inode)->attr_gencount = nfs_inc_attr_generation_counter();
2484-
NFS_I(old_inode)->cache_validity |= NFS_INO_INVALID_CHANGE
2485-
| NFS_INO_INVALID_CTIME
2486-
| NFS_INO_REVAL_FORCED;
2484+
nfs_set_cache_invalid(old_inode, NFS_INO_INVALID_CHANGE |
2485+
NFS_INO_INVALID_CTIME |
2486+
NFS_INO_REVAL_FORCED);
24872487
spin_unlock(&old_inode->i_lock);
24882488
}
24892489
out:

fs/nfs/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,8 +1067,8 @@ void nfs_inode_attach_open_context(struct nfs_open_context *ctx)
10671067
spin_lock(&inode->i_lock);
10681068
if (list_empty(&nfsi->open_files) &&
10691069
(nfsi->cache_validity & NFS_INO_DATA_INVAL_DEFER))
1070-
nfsi->cache_validity |= NFS_INO_INVALID_DATA |
1071-
NFS_INO_REVAL_FORCED;
1070+
nfs_set_cache_invalid(inode, NFS_INO_INVALID_DATA |
1071+
NFS_INO_REVAL_FORCED);
10721072
list_add_tail_rcu(&ctx->list, &nfsi->open_files);
10731073
spin_unlock(&inode->i_lock);
10741074
}

fs/nfs/unlink.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,9 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)
500500
nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
501501
spin_lock(&inode->i_lock);
502502
NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter();
503-
NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE
504-
| NFS_INO_INVALID_CTIME
505-
| NFS_INO_REVAL_FORCED;
503+
nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE |
504+
NFS_INO_INVALID_CTIME |
505+
NFS_INO_REVAL_FORCED);
506506
spin_unlock(&inode->i_lock);
507507
d_move(dentry, sdentry);
508508
break;

fs/nfs/write.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ static void nfs_set_pageerror(struct address_space *mapping)
303303
nfs_zap_mapping(mapping->host, mapping);
304304
/* Force file size revalidation */
305305
spin_lock(&inode->i_lock);
306-
NFS_I(inode)->cache_validity |= NFS_INO_REVAL_FORCED |
307-
NFS_INO_REVAL_PAGECACHE |
308-
NFS_INO_INVALID_SIZE;
306+
nfs_set_cache_invalid(inode, NFS_INO_REVAL_FORCED |
307+
NFS_INO_REVAL_PAGECACHE |
308+
NFS_INO_INVALID_SIZE);
309309
spin_unlock(&inode->i_lock);
310310
}
311311

@@ -1604,7 +1604,7 @@ static int nfs_writeback_done(struct rpc_task *task,
16041604
/* Deal with the suid/sgid bit corner case */
16051605
if (nfs_should_remove_suid(inode)) {
16061606
spin_lock(&inode->i_lock);
1607-
NFS_I(inode)->cache_validity |= NFS_INO_INVALID_OTHER;
1607+
nfs_set_cache_invalid(inode, NFS_INO_INVALID_OTHER);
16081608
spin_unlock(&inode->i_lock);
16091609
}
16101610
return 0;

0 commit comments

Comments
 (0)