aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/inode.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-04-27 13:48:18 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-05-01 15:42:43 -0400
commitfee7fe196c41847c135cde41b0ec790f53ee6fcf (patch)
tree7c71c73ae1840551bdcd76dff1220b136c5fb2e4 /fs/nfs/inode.c
parent3a1556e8662cc425c433b463fcdae138908ca467 (diff)
NFS: Simplify the cache invalidation code
Now that NFSv2 and NFSv3 have simulated change attributes, instead of using all three of mtime, ctime and change attribute to manage data cache consistency, we can simplify the code to just use the change attribute. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r--fs/nfs/inode.c29
1 files changed, 3 insertions, 26 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 9d76c0bd1176..0d53113207e5 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -958,7 +958,7 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
958 958
959 /* Verify a few of the more important attributes */ 959 /* Verify a few of the more important attributes */
960 if ((fattr->valid & NFS_ATTR_FATTR_MTIME) && !timespec_equal(&inode->i_mtime, &fattr->mtime)) 960 if ((fattr->valid & NFS_ATTR_FATTR_MTIME) && !timespec_equal(&inode->i_mtime, &fattr->mtime))
961 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; 961 invalid |= NFS_INO_INVALID_ATTR;
962 962
963 if (fattr->valid & NFS_ATTR_FATTR_SIZE) { 963 if (fattr->valid & NFS_ATTR_FATTR_SIZE) {
964 cur_size = i_size_read(inode); 964 cur_size = i_size_read(inode);
@@ -1325,38 +1325,15 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
1325 invalid |= save_cache_validity; 1325 invalid |= save_cache_validity;
1326 1326
1327 if (fattr->valid & NFS_ATTR_FATTR_MTIME) { 1327 if (fattr->valid & NFS_ATTR_FATTR_MTIME) {
1328 /* NFSv2/v3: Check if the mtime agrees */ 1328 memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime));
1329 if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) {
1330 dprintk("NFS: mtime change on server for file %s/%ld\n",
1331 inode->i_sb->s_id, inode->i_ino);
1332 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA;
1333 if (S_ISDIR(inode->i_mode))
1334 nfs_force_lookup_revalidate(inode);
1335 memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime));
1336 }
1337 } else if (server->caps & NFS_CAP_MTIME) 1329 } else if (server->caps & NFS_CAP_MTIME)
1338 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR 1330 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
1339 | NFS_INO_INVALID_DATA
1340 | NFS_INO_REVAL_PAGECACHE
1341 | NFS_INO_REVAL_FORCED); 1331 | NFS_INO_REVAL_FORCED);
1342 1332
1343 if (fattr->valid & NFS_ATTR_FATTR_CTIME) { 1333 if (fattr->valid & NFS_ATTR_FATTR_CTIME) {
1344 /* If ctime has changed we should definitely clear access+acl caches */ 1334 memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime));
1345 if (!timespec_equal(&inode->i_ctime, &fattr->ctime)) {
1346 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
1347 /* and probably clear data for a directory too as utimes can cause
1348 * havoc with our cache.
1349 */
1350 if (S_ISDIR(inode->i_mode)) {
1351 invalid |= NFS_INO_INVALID_DATA;
1352 nfs_force_lookup_revalidate(inode);
1353 }
1354 memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime));
1355 }
1356 } else if (server->caps & NFS_CAP_CTIME) 1335 } else if (server->caps & NFS_CAP_CTIME)
1357 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR 1336 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
1358 | NFS_INO_INVALID_ACCESS
1359 | NFS_INO_INVALID_ACL
1360 | NFS_INO_REVAL_FORCED); 1337 | NFS_INO_REVAL_FORCED);
1361 1338
1362 /* Check if our cached file size is stale */ 1339 /* Check if our cached file size is stale */