Skip to content

Commit b6f80a2

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

3 files changed

Lines changed: 20 additions & 21 deletions

File tree

fs/nfs/inode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ void nfs_set_cache_invalid(struct inode *inode, unsigned long flags)
229229
if (flags & NFS_INO_INVALID_DATA)
230230
nfs_fscache_invalidate(inode);
231231
}
232+
EXPORT_SYMBOL_GPL(nfs_set_cache_invalid);
232233

233234
/*
234235
* Invalidate the local caches

fs/nfs/nfs42proc.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,15 @@ static ssize_t _nfs42_proc_copy(struct file *src,
357357
truncate_pagecache_range(dst_inode, pos_dst,
358358
pos_dst + res->write_res.count);
359359
spin_lock(&dst_inode->i_lock);
360-
NFS_I(dst_inode)->cache_validity |= (NFS_INO_REVAL_PAGECACHE |
361-
NFS_INO_REVAL_FORCED | NFS_INO_INVALID_SIZE |
362-
NFS_INO_INVALID_ATTR | NFS_INO_INVALID_DATA);
360+
nfs_set_cache_invalid(
361+
dst_inode, NFS_INO_REVAL_PAGECACHE | NFS_INO_REVAL_FORCED |
362+
NFS_INO_INVALID_SIZE | NFS_INO_INVALID_ATTR |
363+
NFS_INO_INVALID_DATA);
363364
spin_unlock(&dst_inode->i_lock);
364365
spin_lock(&src_inode->i_lock);
365-
NFS_I(src_inode)->cache_validity |= (NFS_INO_REVAL_PAGECACHE |
366-
NFS_INO_REVAL_FORCED | NFS_INO_INVALID_ATIME);
366+
nfs_set_cache_invalid(src_inode, NFS_INO_REVAL_PAGECACHE |
367+
NFS_INO_REVAL_FORCED |
368+
NFS_INO_INVALID_ATIME);
367369
spin_unlock(&src_inode->i_lock);
368370
status = res->write_res.count;
369371
out:

fs/nfs/nfs4proc.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,14 +1169,14 @@ int nfs4_call_sync(struct rpc_clnt *clnt,
11691169
static void
11701170
nfs4_inc_nlink_locked(struct inode *inode)
11711171
{
1172-
NFS_I(inode)->cache_validity |= NFS_INO_INVALID_OTHER;
1172+
nfs_set_cache_invalid(inode, NFS_INO_INVALID_OTHER);
11731173
inc_nlink(inode);
11741174
}
11751175

11761176
static void
11771177
nfs4_dec_nlink_locked(struct inode *inode)
11781178
{
1179-
NFS_I(inode)->cache_validity |= NFS_INO_INVALID_OTHER;
1179+
nfs_set_cache_invalid(inode, NFS_INO_INVALID_OTHER);
11801180
drop_nlink(inode);
11811181
}
11821182

@@ -1187,35 +1187,31 @@ nfs4_update_changeattr_locked(struct inode *inode,
11871187
{
11881188
struct nfs_inode *nfsi = NFS_I(inode);
11891189

1190-
nfsi->cache_validity |= NFS_INO_INVALID_CTIME
1191-
| NFS_INO_INVALID_MTIME
1192-
| cache_validity;
1190+
cache_validity |= NFS_INO_INVALID_CTIME | NFS_INO_INVALID_MTIME;
11931191

11941192
if (cinfo->atomic && cinfo->before == inode_peek_iversion_raw(inode)) {
11951193
nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE;
11961194
nfsi->attrtimeo_timestamp = jiffies;
11971195
} else {
11981196
if (S_ISDIR(inode->i_mode)) {
1199-
nfsi->cache_validity |= NFS_INO_INVALID_DATA;
1197+
cache_validity |= NFS_INO_INVALID_DATA;
12001198
nfs_force_lookup_revalidate(inode);
12011199
} else {
12021200
if (!NFS_PROTO(inode)->have_delegation(inode,
12031201
FMODE_READ))
1204-
nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE;
1202+
cache_validity |= NFS_INO_REVAL_PAGECACHE;
12051203
}
12061204

12071205
if (cinfo->before != inode_peek_iversion_raw(inode))
1208-
nfsi->cache_validity |= NFS_INO_INVALID_ACCESS |
1209-
NFS_INO_INVALID_ACL |
1210-
NFS_INO_INVALID_XATTR;
1206+
cache_validity |= NFS_INO_INVALID_ACCESS |
1207+
NFS_INO_INVALID_ACL |
1208+
NFS_INO_INVALID_XATTR;
12111209
}
12121210
inode_set_iversion_raw(inode, cinfo->after);
12131211
nfsi->read_cache_jiffies = timestamp;
12141212
nfsi->attr_gencount = nfs_inc_attr_generation_counter();
1213+
nfs_set_cache_invalid(inode, cache_validity);
12151214
nfsi->cache_validity &= ~NFS_INO_INVALID_CHANGE;
1216-
1217-
if (nfsi->cache_validity & NFS_INO_INVALID_DATA)
1218-
nfs_fscache_invalidate(inode);
12191215
}
12201216

12211217
void
@@ -5915,9 +5911,9 @@ static int __nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t bufl
59155911
* so mark the attribute cache invalid.
59165912
*/
59175913
spin_lock(&inode->i_lock);
5918-
NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE
5919-
| NFS_INO_INVALID_CTIME
5920-
| NFS_INO_REVAL_FORCED;
5914+
nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE |
5915+
NFS_INO_INVALID_CTIME |
5916+
NFS_INO_REVAL_FORCED);
59215917
spin_unlock(&inode->i_lock);
59225918
nfs_access_zap_cache(inode);
59235919
nfs_zap_acl_cache(inode);

0 commit comments

Comments
 (0)