NFS: Don't force a dcache revalidation if nfs_wcc_update_inode succeeds
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Thu, 27 Sep 2007 14:07:31 +0000 (10:07 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 9 Oct 2007 21:18:55 +0000 (17:18 -0400)
The reason is that if the weak cache consistency update was successful,
then we know that our client must be the only one that changed the
directory, and we've already updated the dcache to reflect the change.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/inode.c
fs/nfs/nfs4proc.c
include/linux/nfs_fs.h

index f1f6639f52b5fe839ec21ebf7c048f574350c724..7e73edc1751f57e41120fcd88f101b7850978797 100644 (file)
@@ -791,24 +791,18 @@ void nfs_end_data_update(struct inode *inode)
 static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 {
        struct nfs_inode *nfsi = NFS_I(inode);
-       unsigned long now = jiffies;
 
        /* If we have atomic WCC data, we may update some attributes */
        if ((fattr->valid & NFS_ATTR_WCC) != 0) {
-               if (timespec_equal(&inode->i_ctime, &fattr->pre_ctime)) {
+               if (timespec_equal(&inode->i_ctime, &fattr->pre_ctime))
                        memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime));
-                       nfsi->cache_change_attribute = now;
-               }
                if (timespec_equal(&inode->i_mtime, &fattr->pre_mtime)) {
                        memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime));
                        if (S_ISDIR(inode->i_mode))
                                nfsi->cache_validity |= NFS_INO_INVALID_DATA;
-                       nfsi->cache_change_attribute = now;
                }
-               if (inode->i_size == fattr->pre_size && nfsi->npages == 0) {
+               if (inode->i_size == fattr->pre_size && nfsi->npages == 0)
                        inode->i_size = fattr->size;
-                       nfsi->cache_change_attribute = now;
-               }
        }
 }
 
@@ -919,6 +913,7 @@ int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr)
        if (unlikely((fattr->valid & NFS_ATTR_FATTR) == 0)) {
                spin_lock(&inode->i_lock);
                nfsi->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
+               nfsi->cache_change_attribute = jiffies;
                spin_unlock(&inode->i_lock);
                goto out;
        }
index 0e366a31f63b1a9f4ab66df313ee6d4230dad93a..871c102d9bdff82adce7055d9f0e2feacb01a9aa 100644 (file)
@@ -208,9 +208,12 @@ static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo)
        struct nfs_inode *nfsi = NFS_I(dir);
 
        spin_lock(&dir->i_lock);
-       nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_DATA;
-       if (cinfo->before == nfsi->change_attr && cinfo->atomic)
+       if (cinfo->after != nfsi->change_attr) {
+               nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_DATA;
+               if (!cinfo->atomic || cinfo->before != nfsi->change_attr)
+                       nfsi->cache_change_attribute = jiffies;
                nfsi->change_attr = cinfo->after;
+       }
        spin_unlock(&dir->i_lock);
 }
 
index f45161363be238d05a1e6fb628eabd8873507760..fd2c5c8158cf5a3b55c7f0afc7ef7f6396e54518 100644 (file)
@@ -235,8 +235,10 @@ static inline void nfs_mark_for_revalidate(struct inode *inode)
 
        spin_lock(&inode->i_lock);
        nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS;
-       if (S_ISDIR(inode->i_mode))
+       if (S_ISDIR(inode->i_mode)) {
                nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_DATA;
+               nfsi->cache_change_attribute = jiffies;
+       }
        spin_unlock(&inode->i_lock);
 }
 
This page took 0.029906 seconds and 5 git commands to generate.