NFS: Don't flush caches for a getattr that races with writeback
authorTrond Myklebust <trond.myklebust@primarydata.com>
Wed, 8 Jun 2016 01:44:08 +0000 (21:44 -0400)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Mon, 13 Jun 2016 16:36:02 +0000 (12:36 -0400)
If there were outstanding writes then chalk up the unexpected change
attribute on the server to them.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/inode.c

index 52e7d6869e3b2445dc6417875b3c753edb681ecc..60051e62d3f1fb6110aaa708f5efc7121d758fc7 100644 (file)
@@ -1729,12 +1729,15 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
                if (inode->i_version != fattr->change_attr) {
                        dprintk("NFS: change_attr change on server for file %s/%ld\n",
                                        inode->i_sb->s_id, inode->i_ino);
-                       invalid |= NFS_INO_INVALID_ATTR
-                               | NFS_INO_INVALID_DATA
-                               | NFS_INO_INVALID_ACCESS
-                               | NFS_INO_INVALID_ACL;
-                       if (S_ISDIR(inode->i_mode))
-                               nfs_force_lookup_revalidate(inode);
+                       /* Could it be a race with writeback? */
+                       if (nfsi->nrequests == 0) {
+                               invalid |= NFS_INO_INVALID_ATTR
+                                       | NFS_INO_INVALID_DATA
+                                       | NFS_INO_INVALID_ACCESS
+                                       | NFS_INO_INVALID_ACL;
+                               if (S_ISDIR(inode->i_mode))
+                                       nfs_force_lookup_revalidate(inode);
+                       }
                        inode->i_version = fattr->change_attr;
                }
        } else {