aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@fys.uio.no>2005-10-17 06:02:00 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-17 17:47:16 -0400
commitb3c52da33ce95747b1bff86cce716d4f1397f14a (patch)
tree7958a929e5b9486bf0b5358776078c1bc71faf88 /fs/nfs
parent13b58ee51802a45d2b8853ffe0003d9fa768195c (diff)
[PATCH] NFS: Fix cache consistency races
If the data cache has been marked as potentially invalid by nfs_refresh_inode, we should invalidate it rather than assume that changes are due to our own activity. Also ensure that we always start with a valid cache before declaring it to be protected by a delegation. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/delegation.c4
-rw-r--r--fs/nfs/file.c3
-rw-r--r--fs/nfs/inode.c7
3 files changed, 8 insertions, 6 deletions
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index d7f7eb669d0..4a36839f0bb 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -85,6 +85,10 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
85 struct nfs_delegation *delegation; 85 struct nfs_delegation *delegation;
86 int status = 0; 86 int status = 0;
87 87
88 /* Ensure we first revalidate the attributes and page cache! */
89 if ((nfsi->cache_validity & (NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_ATTR)))
90 __nfs_revalidate_inode(NFS_SERVER(inode), inode);
91
88 delegation = nfs_alloc_delegation(); 92 delegation = nfs_alloc_delegation();
89 if (delegation == NULL) 93 if (delegation == NULL)
90 return -ENOMEM; 94 return -ENOMEM;
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index f6b9eda925c..6bdcfa95de9 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -137,7 +137,8 @@ static int nfs_revalidate_file(struct inode *inode, struct file *filp)
137 struct nfs_inode *nfsi = NFS_I(inode); 137 struct nfs_inode *nfsi = NFS_I(inode);
138 int retval = 0; 138 int retval = 0;
139 139
140 if ((nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE) || nfs_attribute_timeout(inode)) 140 if ((nfsi->cache_validity & (NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_ATTR))
141 || nfs_attribute_timeout(inode))
141 retval = __nfs_revalidate_inode(NFS_SERVER(inode), inode); 142 retval = __nfs_revalidate_inode(NFS_SERVER(inode), inode);
142 nfs_revalidate_mapping(inode, filp->f_mapping); 143 nfs_revalidate_mapping(inode, filp->f_mapping);
143 return 0; 144 return 0;
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 6922469d6fc..6be46d21c01 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1226,10 +1226,6 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
1226 loff_t cur_size, new_isize; 1226 loff_t cur_size, new_isize;
1227 int data_unstable; 1227 int data_unstable;
1228 1228
1229 /* Do we hold a delegation? */
1230 if (nfs_have_delegation(inode, FMODE_READ))
1231 return 0;
1232
1233 spin_lock(&inode->i_lock); 1229 spin_lock(&inode->i_lock);
1234 1230
1235 /* Are we in the process of updating data on the server? */ 1231 /* Are we in the process of updating data on the server? */
@@ -1350,7 +1346,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr, unsign
1350 nfsi->read_cache_jiffies = fattr->timestamp; 1346 nfsi->read_cache_jiffies = fattr->timestamp;
1351 1347
1352 /* Are we racing with known updates of the metadata on the server? */ 1348 /* Are we racing with known updates of the metadata on the server? */
1353 data_unstable = ! nfs_verify_change_attribute(inode, verifier); 1349 data_unstable = ! (nfs_verify_change_attribute(inode, verifier) ||
1350 (nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE));
1354 1351
1355 /* Check if our cached file size is stale */ 1352 /* Check if our cached file size is stale */
1356 new_isize = nfs_size_to_loff_t(fattr->size); 1353 new_isize = nfs_size_to_loff_t(fattr->size);