Skip to contentSkip to conversation

NFS client attribute cache performance improvements

PATCH In review Trond Myklebust 3 participants 16 messages Dec 17, 2016 – Dec 19, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover NFS client attribute cache performance improvements

The following patchset makes the largest difference w.r.t. NFSv4, where we don't always ask for the full set of attributes from the server, however there are also some tidbits for NFSv3.

With this patchset, running xfstests over NFSv4.1 shows the following improvement in execution times:

Generic/074 now 264s, was 344s
Generic/075 now 15s was 26s
Generic/089 now 178s was 236s
Generic/112 now 14s was 25s
Generic/113 now 14s was 20s
Generic/127 now 206s was 223s
Generic/133 now 85s was 118s
Generic/247 now 27s was 43s

I saw no statistically significant performance regressions (and no functional regressions).

For nfsstats, the client shows a significant decrease in % GETATTR and % LOOKUP calls on the same workloads.

For 2 runs of xfstests, the numbers are:
GETATTR: now 1456511, was 2168740
LOOKUP: now 301073, was 545571
ACCESS: now 137211 was 139447

Trond Myklebust (9):
NFSv4: Don't invalidate the directory twice
NFSv4: Update the attribute cache info in update_changeattr
NFSv4: Don't discard the attributes returned by asynchronous
DELEGRETURN
NFS: Don't revalidate the file on close if we hold a delegation
NFS: Clean up cache validity checking
NFS: Only look at the change attribute cache state in
nfs_weak_revalidate()
NFS: Fix and clean up the access cache validity checking
NFS: Remove unused function nfs_revalidate_inode_rcu()
NFS: Clean up nfs_attribute_timeout()

 fs/nfs/dir.c           | 23 +++++++++--------
 fs/nfs/file.c          | 12 +--------
 fs/nfs/inode.c         | 68 ++++++++++++++++++++++++++++++--------------------
 fs/nfs/internal.h      |  1 +
 fs/nfs/nfs4proc.c      | 17 +++++++++----
 include/linux/nfs_fs.h |  2 --
 6 files changed, 67 insertions(+), 56 deletions(-)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/9 NFSv4: Don't invalidate the directory twice

If an operation that modified the directory raced with a GETATTR, then we don't need to invalidate the directory cache more than once.

---
 fs/nfs/nfs4proc.c | 3 +++
 1 file changed, 3 insertions(+)
fs/nfs/nfs4proc.c +3 -0
index d33242c8d95d..713932440e07 100644
@@ -1088,12 +1088,15 @@ static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo)
 	struct nfs_inode *nfsi = NFS_I(dir);
 
 	spin_lock(&dir->i_lock);
+	if (dir->i_version == cinfo->after)
+		goto out;
 	nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA;
 	if (!cinfo->atomic || cinfo->before != dir->i_version)
 		nfs_force_lookup_revalidate(dir);
 	dir->i_version = cinfo->after;
 	nfsi->attr_gencount = nfs_inc_attr_generation_counter();
 	nfs_fscache_invalidate(dir);
+out:
 	spin_unlock(&dir->i_lock);
 }
 
Signature · 1 line
2.9.3
#2 lore raw

PATCH 2/9 NFSv4: Update the attribute cache info in update_changeattr

If we successfully updated the change attribute, we should timestamp the cache. While we do know that the other attributes are not completely up to date, we have the NFS_INO_INVALID_ATTR flag that let us know that, so it is valid to say that the cache has not timed out.
We can also clear NFS_INO_REVAL_PAGECACHE, since our change attribute is now known to be valid.

Conversely, if the change attribute did not match, we should make sure to also revalidate the access and ACL caches.

---
 fs/nfs/nfs4proc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
fs/nfs/nfs4proc.c +8 -1
index 713932440e07..2e0816cb7136 100644
@@ -1091,8 +1091,15 @@ static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo)
 	if (dir->i_version == cinfo->after)
 		goto out;
 	nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA;
-	if (!cinfo->atomic || cinfo->before != dir->i_version)
+	if (cinfo->atomic && cinfo->before == dir->i_version) {
+		nfsi->cache_validity &= ~NFS_INO_REVAL_PAGECACHE;
+		nfsi->attrtimeo_timestamp = jiffies;
+	} else {
 		nfs_force_lookup_revalidate(dir);
+		if (cinfo->before != dir->i_version)
+			nfsi->cache_validity |= NFS_INO_INVALID_ACCESS |
+				NFS_INO_INVALID_ACL;
+	}
 	dir->i_version = cinfo->after;
 	nfsi->attr_gencount = nfs_inc_attr_generation_counter();
 	nfs_fscache_invalidate(dir);
Signature · 1 line
2.9.3
#3 lore raw

PATCH 3/9 NFSv4: Don't discard the attributes returned by asynchronous DELEGRETURN

DELEGRETURN will always carry a reference to the inode except when the latter is being freed, so let's ensure that we always use that inode information to ensure close-to-open cache consistency, even when the DELEGRETURN call is asynchronous.

---
 fs/nfs/nfs4proc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
fs/nfs/nfs4proc.c +1 -4
index 2e0816cb7136..58e3d5f627f2 100644
@@ -5702,6 +5702,7 @@ static void nfs4_delegreturn_release(void *calldata)
 		if (data->lr.roc)
 			pnfs_roc_release(&data->lr.arg, &data->lr.res,
 					data->res.lr_ret);
+		nfs_post_op_update_inode_force_wcc(inode, &data->fattr);
 		nfs_iput_and_deactive(inode);
 	}
 	kfree(calldata);
@@ -5790,10 +5791,6 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co
 	if (status != 0)
 		goto out;
 	status = data->rpc_status;
-	if (status == 0)
-		nfs_post_op_update_inode_force_wcc(inode, &data->fattr);
-	else
-		nfs_refresh_inode(inode, &data->fattr);
 out:
 	rpc_put_task(task);
 	return status;
Signature · 1 line
2.9.3
#4 lore raw

PATCH 4/9 NFS: Don't revalidate the file on close if we hold a delegation

If we're holding a delegation, we can skip sending the close-to-open GETATTR until we're returning that delegation.

---
 fs/nfs/inode.c | 2 ++
 1 file changed, 2 insertions(+)
fs/nfs/inode.c +2 -0
index 7de345fd8e1e..2fc237cd338e 100644
@@ -795,6 +795,8 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
 	if (!is_sync)
 		return;
 	inode = d_inode(ctx->dentry);
+	if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))
+		return;
 	nfsi = NFS_I(inode);
 	if (inode->i_mapping->nrpages == 0)
 		return;
Signature · 1 line
2.9.3
#5 lore raw

PATCH 5/9 NFS: Clean up cache validity checking

Consolidate the open-coded checking of NFS_I(inode)->cache_validity into a couple of helper functions.

---
 fs/nfs/file.c     | 12 +-----------
 fs/nfs/inode.c    | 43 ++++++++++++++++++++++++++++++++-----------
 fs/nfs/internal.h |  1 +
 3 files changed, 34 insertions(+), 22 deletions(-)
fs/nfs/file.c +1 -11
index 64c11f399b3d..599a602cb2fd 100644
@@ -101,21 +101,11 @@ EXPORT_SYMBOL_GPL(nfs_file_release);
 static int nfs_revalidate_file_size(struct inode *inode, struct file *filp)
 {
 	struct nfs_server *server = NFS_SERVER(inode);
-	struct nfs_inode *nfsi = NFS_I(inode);
-	const unsigned long force_reval = NFS_INO_REVAL_PAGECACHE|NFS_INO_REVAL_FORCED;
-	unsigned long cache_validity = nfsi->cache_validity;
-
-	if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ) &&
-	    (cache_validity & force_reval) != force_reval)
-		goto out_noreval;
 
 	if (filp->f_flags & O_DIRECT)
 		goto force_reval;
-	if (nfsi->cache_validity & NFS_INO_REVAL_PAGECACHE)
-		goto force_reval;
-	if (nfs_attribute_timeout(inode))
+	if (nfs_check_cache_invalid(inode, NFS_INO_REVAL_PAGECACHE))
 		goto force_reval;
-out_noreval:
 	return 0;
 force_reval:
 	return __nfs_revalidate_inode(server, inode);
fs/nfs/inode.c +32 -11

55 lines not on this page · raw message

fs/nfs/internal.h +1 -0
index 6b79c2ca9b9a..09ca5095c04e 100644
@@ -381,6 +381,7 @@ extern int nfs_drop_inode(struct inode *);
 extern void nfs_clear_inode(struct inode *);
 extern void nfs_evict_inode(struct inode *);
 void nfs_zap_acl_cache(struct inode *inode);
+extern bool nfs_check_cache_invalid(struct inode *, unsigned long);
 extern int nfs_wait_bit_killable(struct wait_bit_key *key, int mode);
 extern int nfs_wait_atomic_killable(atomic_t *p);
 
Signature · 1 line
2.9.3
#6 lore raw

PATCH 6/9 NFS: Only look at the change attribute cache state in nfs_weak_revalidate()

Just like in nfs_check_verifier(), we want to use nfs_mapping_need_revalidate_inode() to check our knowledge of the change attribute is up to date.

---
 fs/nfs/dir.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfs/dir.c +3 -2
index cb22a9f9ae7e..8f706f3e5c05 100644
@@ -1273,8 +1273,8 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
  */
 static int nfs_weak_revalidate(struct dentry *dentry, unsigned int flags)
 {
-	int error;
 	struct inode *inode = d_inode(dentry);
+	int error = 0;
 
 	/*
 	 * I believe we can only get a negative dentry here in the case of a
@@ -1293,7 +1293,8 @@ static int nfs_weak_revalidate(struct dentry *dentry, unsigned int flags)
 		return 0;
 	}
 
-	error = nfs_revalidate_inode(NFS_SERVER(inode), inode);
+	if (nfs_mapping_need_revalidate_inode(inode))
+		error = __nfs_revalidate_inode(NFS_SERVER(inode), inode);
 	dfprintk(LOOKUPCACHE, "NFS: %s: inode %lu is %s\n",
 			__func__, inode->i_ino, error ? "invalid" : "valid");
 	return !error;
Signature · 1 line
2.9.3
#7 lore raw

PATCH 7/9 NFS: Fix and clean up the access cache validity checking

The access cache needs to check whether or not the mode bits, ownership, or ACL has changed or the cache has timed out.

---
 fs/nfs/dir.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
fs/nfs/dir.c +9 -9
index 8f706f3e5c05..fad81041f5ab 100644
@@ -2286,8 +2286,7 @@ static int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, str
 		if (cache == NULL)
 			goto out;
 		/* Found an entry, is our attribute cache valid? */
-		if (!nfs_attribute_cache_expired(inode) &&
-		    !(nfsi->cache_validity & NFS_INO_INVALID_ATTR))
+		if (!nfs_check_cache_invalid(inode, NFS_INO_INVALID_ACCESS))
 			break;
 		err = -ECHILD;
 		if (!may_block)
@@ -2335,12 +2334,12 @@ static int nfs_access_get_cached_rcu(struct inode *inode, struct rpc_cred *cred,
 		cache = NULL;
 	if (cache == NULL)
 		goto out;
-	err = nfs_revalidate_inode_rcu(NFS_SERVER(inode), inode);
-	if (err)
+	if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_ACCESS))
 		goto out;
 	res->jiffies = cache->jiffies;
 	res->cred = cache->cred;
 	res->mask = cache->mask;
+	err = 0;
 out:
 	rcu_read_unlock();
 	return err;
@@ -2492,12 +2491,13 @@ EXPORT_SYMBOL_GPL(nfs_may_open);
 static int nfs_execute_ok(struct inode *inode, int mask)
 {
 	struct nfs_server *server = NFS_SERVER(inode);
-	int ret;
+	int ret = 0;
 
-	if (mask & MAY_NOT_BLOCK)
-		ret = nfs_revalidate_inode_rcu(server, inode);
-	else
-		ret = nfs_revalidate_inode(server, inode);
+	if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_ACCESS)) {
+		if (mask & MAY_NOT_BLOCK)
+			return -ECHILD;
+		ret = __nfs_revalidate_inode(server, inode);
+	}
 	if (ret == 0 && !execute_ok(inode))
 		ret = -EACCES;
 	return ret;
Signature · 1 line
2.9.3
#8 lore raw

PATCH 8/9 NFS: Remove unused function nfs_revalidate_inode_rcu()

---
 fs/nfs/inode.c         | 9 ---------
 include/linux/nfs_fs.h | 1 -
 2 files changed, 10 deletions(-)
fs/nfs/inode.c +0 -9
index e3194aa797f7..8224e96b5808 100644
@@ -1105,15 +1105,6 @@ int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
 }
 EXPORT_SYMBOL_GPL(nfs_revalidate_inode);
 
-int nfs_revalidate_inode_rcu(struct nfs_server *server, struct inode *inode)
-{
-	if (!(NFS_I(inode)->cache_validity &
-			(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_LABEL))
-			&& !nfs_attribute_cache_expired(inode))
-		return NFS_STALE(inode) ? -ESTALE : 0;
-	return -ECHILD;
-}
-
 static int nfs_invalidate_mapping(struct inode *inode, struct address_space *mapping)
 {
 	struct nfs_inode *nfsi = NFS_I(inode);
include/linux/nfs_fs.h +0 -1
index cb631973839a..fe2e7810ae80 100644
@@ -343,7 +343,6 @@ extern int nfs_open(struct inode *, struct file *);
 extern int nfs_attribute_timeout(struct inode *inode);
 extern int nfs_attribute_cache_expired(struct inode *inode);
 extern int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode);
-extern int nfs_revalidate_inode_rcu(struct nfs_server *server, struct inode *inode);
 extern int __nfs_revalidate_inode(struct nfs_server *, struct inode *);
 extern bool nfs_mapping_need_revalidate_inode(struct inode *inode);
 extern int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping);
Signature · 1 line
2.9.3
#9 lore raw

PATCH 9/9 NFS: Clean up nfs_attribute_timeout()

It can be made static.

---
 fs/nfs/inode.c         | 14 +++++++-------
 include/linux/nfs_fs.h |  1 -
 2 files changed, 7 insertions(+), 8 deletions(-)
fs/nfs/inode.c +7 -7
index 8224e96b5808..a0cd79646c1b 100644
@@ -160,6 +160,13 @@ int nfs_sync_mapping(struct address_space *mapping)
 	return ret;
 }
 
+static int nfs_attribute_timeout(struct inode *inode)
+{
+	struct nfs_inode *nfsi = NFS_I(inode);
+
+	return !time_in_range_open(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache_jiffies + nfsi->attrtimeo);
+}
+
 static bool nfs_check_cache_invalid_delegated(struct inode *inode, unsigned long flags)
 {
 	unsigned long cache_validity = READ_ONCE(NFS_I(inode)->cache_validity);
@@ -1076,13 +1083,6 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
 	return status;
 }
 
-int nfs_attribute_timeout(struct inode *inode)
-{
-	struct nfs_inode *nfsi = NFS_I(inode);
-
-	return !time_in_range_open(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache_jiffies + nfsi->attrtimeo);
-}
-
 int nfs_attribute_cache_expired(struct inode *inode)
 {
 	if (nfs_have_delegated_attributes(inode))
include/linux/nfs_fs.h +0 -1
index fe2e7810ae80..f1da8c8dd473 100644
@@ -340,7 +340,6 @@ extern void nfs_access_add_cache(struct inode *, struct nfs_access_entry *);
 extern void nfs_access_set_mask(struct nfs_access_entry *, u32);
 extern int nfs_permission(struct inode *, int);
 extern int nfs_open(struct inode *, struct file *);
-extern int nfs_attribute_timeout(struct inode *inode);
 extern int nfs_attribute_cache_expired(struct inode *inode);
 extern int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode);
 extern int __nfs_revalidate_inode(struct nfs_server *, struct inode *);
Signature · 1 line
2.9.3
#10 lore raw

Re: [PATCH 1/9] NFSv4: Don't invalidate the directory twice

In reply to Trond Myklebust

Hi Trond,

Quoted 2 lines · Trond Myklebust

If an operation that modified the directory raced with a GETATTR, then we don't need to invalidate the directory cache more than once.

This patch causes cthon basic tests to fail with:

./test6: readdir
./test6: (/nfs/all) unlinked 'file.0' dir entry read pass 1 ./test6: (/nfs/all) Test failed with 1 errors
basic tests failed

Thanks,
Anna

Quoted 27 lines
---
 fs/nfs/nfs4proc.c | 3 +++
 1 file changed, 3 insertions(+)
fs/nfs/nfs4proc.c +3 -0
index d33242c8d95d..713932440e07 100644
@@ -1088,12 +1088,15 @@ static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo)
 	struct nfs_inode *nfsi = NFS_I(dir);
 
 	spin_lock(&dir->i_lock);
+	if (dir->i_version == cinfo->after)
+		goto out;
 	nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA;
 	if (!cinfo->atomic || cinfo->before != dir->i_version)
 		nfs_force_lookup_revalidate(dir);
 	dir->i_version = cinfo->after;
 	nfsi->attr_gencount = nfs_inc_attr_generation_counter();
 	nfs_fscache_invalidate(dir);
+out:
 	spin_unlock(&dir->i_lock);
 }
 
#11 lore raw

Re: [PATCH 1/9] NFSv4: Don't invalidate the directory twice

V2hhdOKAmXMgdGhlIGZpbGVzeXN0ZW0geW914oCZcmUgdGVzdGluZyBvbj8NCg0KPiBPbiBEZWMg MTksIDIwMTYsIGF0IDExOjU0LCBBbm5hIFNjaHVtYWtlciA8c2NodW1ha2VyLmFubmFAZ21haWwu Y29tPiB3cm90ZToNCj4gDQo+IEhpIFRyb25kLA0KPiANCj4gT24gMTIvMTcvMjAxNiAwMToyNyBQ TSwgVHJvbmQgTXlr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p3rp7Lm7vv70r77+977+977+977+9e++/ve+/ve+/vSLvv73vv71ebu+/vXLvv73vv73v v71677+9Gu+/ve+/vWjvv73vv73vv73vv70m77+977+9Hu+/vUfvv73vv73vv71o77+9Ayjvv73p mo7vv73domoi77+977+9Gu+/vRtt77+977+977+977+977+9eu+/vd6W77+977+977+9Zu+/ve+/ ve+/vWjvv73vv73vv71+77+9be+/vQ0KDQo=

#13 lore raw

Re: [PATCH 1/9] NFSv4: Don't invalidate the directory twice

In reply to Trond Myklebust
Quoted 1 line · Trond Myklebust

What’s the filesystem you’re testing on?

I see this on xfs and ext4 but btrfs seems to work. What do you mean by timestamp resolution? I can't find the file in question in ls, but for another file stat tells me:

File: file.10

  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: fe31h/65073d    Inode: 1319795     Links: 1
Access: (0666/-rw-rw-rw-)  Uid: ( 1000/    anna)   Gid: (  100/   users)

Access: 2016-12-19 12:04:47.680033877 -0500
Modify: 2016-12-19 12:04:47.680033877 -0500
Change: 2016-12-19 12:04:47.680033877 -0500

I hope this helps!
Anna

Quoted 47 lines
Quoted 46 lines · Anna Schumaker

Hi Trond,

Quoted 2 lines · Trond Myklebust

If an operation that modified the directory raced with a GETATTR, then we don't need to invalidate the directory cache more than once.

This patch causes cthon basic tests to fail with:

./test6: readdir
./test6: (/nfs/all) unlinked 'file.0' dir entry read pass 1 ./test6: (/nfs/all) Test failed with 1 errors
basic tests failed

Thanks,
Anna

Quoted 27 lines

---
fs/nfs/nfs4proc.c | 3 +++

1 file changed, 3 insertions(+)
fs/nfs/nfs4proc.c +3 -0
index d33242c8d95d..713932440e07 100644
@@ -1088,12 +1088,15 @@ static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo)
 	struct nfs_inode *nfsi = NFS_I(dir);
 
 	spin_lock(&dir->i_lock);
+	if (dir->i_version == cinfo->after)
+		goto out;
 	nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA;
 	if (!cinfo->atomic || cinfo->before != dir->i_version)
 		nfs_force_lookup_revalidate(dir);
 	dir->i_version = cinfo->after;
 	nfsi->attr_gencount = nfs_inc_attr_generation_counter();
 	nfs_fscache_invalidate(dir);
+out:
 	spin_unlock(&dir->i_lock);
 }
 
#14 lore raw

Re: [PATCH 1/9] NFSv4: Don't invalidate the directory twice

DQo+IE9uIERlYyAxOSwgMjAxNiwgYXQgMTI6MDcsIEFubmEgU2NodW1ha2VyIDxzY2h1bWFrZXIu YW5uYUBnbWFpbC5jb20+IHdyb3RlOg0KPiANCj4gDQo+IA0KPiBPbiAxMi8xOS8yMDE2IDExOjU2 IEFNLCBUcm9uZCBNeWtsZWJ1c3Qgd3JvdGU6DQo+PiBXaGF04oCZcyB0aGUgZmlsZXN5c3RlbSB5 b3XigJlyZSB0ZXN0aW5nIG9uPw0KPiANCj4gSSBzZWUgdGhpcyBvbiB4ZnMgYW5kIGV4dDQgYnV0 IGJ0cmZzIHNlZW1zIHRvIHdvcmsuICBXaGF0IGRvIHlvdSBtZWFuIGJ5IHRpbWVzdGFtcCByZXNv bHV0aW9uPyAgSSBjYW4ndCBmaW5kIHRoZSBmaWxlIGluIHF1ZXN0aW9uIGluIGBsc2AsIGJ1dCBm b3IgYW5vdGhlciBmaWxlIGBzdGF0YCB0ZWxscyBtZToNCj4gDQo+ICBGaWxlOiBmaWxlLjEwDQo+ ICBTaXplOiAwICAgICAgICAgICAgICAgQmxvY2tzOiAwICAgICAgICAgIElPIEJsb2NrOiA0MDk2 ICAgcmVndWxhciBlbXB0eSBmaWxlDQo+IERldmljZTogZmUzMWgvNjUwNzNkICAgIElub2RlOiAx MzE5Nzk1ICAgICBMaW5rczogMQ0KPiBBY2Nlc3M6ICgwNjY2Ly1ydy1ydy1ydy0pICBVaWQ6ICgg MTAwMC8gICAgYW5uYSkgICBHaWQ6ICggIDEwMC8gICB1c2VycykNCj4gQWNjZXNzOiAyMDE2LTEy LTE5IDEyOjA0OjQ3LjY4MDAzMzg3NyAtMDUwMA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sb2NrKTsNCj4+Pj4gKwlpZiAoZGlyLT5p X3ZlcnNpb24gPT0gY2luZm8tPmFmdGVyKQ0KPj4+PiArCQlnb3RvIG91dDsNCj4+Pj4gCW5mc2kt PmNhY2hlX3ZhbGlkaXR5IHw9IE5GU19JTk9fSU5WQUxJRF9BVFRSfE5GU19JTk9fSU5WQUxJRF9E QVRBOw0KPj4+PiAJaWYgKCFjaW5mby0+YXRvbWljIHx8IGNpbmZvLT5iZWZvcmUgIT0gZGlyLT5p X3ZlcnNpb24pDQo+Pj4+IAkJbmZzX2ZvcmNlX2xvb2t1cF9yZXZhbGlkYXRlKGRpcik7DQo+Pj4+ IAlkaXItPmlfdmVyc2lvbiA9IGNpbmZvLT5hZnRlcjsNCj4+Pj4gCW5mc2ktPmF0dHJfZ2VuY291 bnQgPSBuZnNfaW5jX2F0dHJfZ2VuZXJhdGlvbl9jb3VudGVyKCk7DQo+Pj4+IAluZnNfZnNjYWNo ZV9pbnZhbGlkYXRlKGRpcik7DQo+Pj4+ICtvdXQ6DQo+Pj4+IAlzcGluX3VubG9jaygmZGlyLT5p X2xvY2spOw0KPj4+PiB9DQo+Pj4+IA0KPj4+PiANCj4+PiANCj4+IA0KPiANCg0K

#15 lore raw

Re: [PATCH 1/9] NFSv4: Don't invalidate the directory twice

Quoted 18 lines · Trond Myklebust
Quoted 10 lines · Anna Schumaker
Quoted 1 line · Trond Myklebust

What’s the filesystem you’re testing on?

I see this on xfs and ext4 but btrfs seems to work. What do you mean by timestamp resolution? I can't find the file in question in ls, but for another file stat tells me:

Quoted 7 lines

File: file.10
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fe31h/65073d Inode: 1319795 Links: 1
Access: (0666/-rw-rw-rw-) Uid: ( 1000/ anna) Gid: ( 100/ users)
Access: 2016-12-19 12:04:47.680033877 -0500
Modify: 2016-12-19 12:04:47.680033877 -0500
Change: 2016-12-19 12:04:47.680033877 -0500

Quoted 1 line

I mean that the timestamps appear to be unable to keep up with the volume of changes on the filesystem. If the cthon test is failing here, then it’s probably because the before/after change attributes are the same… Does wireshark show that the before/after change attributes on this directory are different?

Ah, that's what you mean. Yes, Wireshark does show the same values for before and after changeids.

Anna

Quoted 53 lines
Quoted 52 lines

I hope this helps!
Anna

Quoted 47 lines
Quoted 46 lines · Anna Schumaker

Hi Trond,

Quoted 2 lines · Trond Myklebust

If an operation that modified the directory raced with a GETATTR, then we don't need to invalidate the directory cache more than once.

This patch causes cthon basic tests to fail with:

./test6: readdir
./test6: (/nfs/all) unlinked 'file.0' dir entry read pass 1 ./test6: (/nfs/all) Test failed with 1 errors
basic tests failed

Thanks,
Anna

Quoted 27 lines

---
fs/nfs/nfs4proc.c | 3 +++

1 file changed, 3 insertions(+)
fs/nfs/nfs4proc.c +3 -0
index d33242c8d95d..713932440e07 100644
@@ -1088,12 +1088,15 @@ static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo)
 	struct nfs_inode *nfsi = NFS_I(dir);
 
 	spin_lock(&dir->i_lock);
+	if (dir->i_version == cinfo->after)
+		goto out;
 	nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA;
 	if (!cinfo->atomic || cinfo->before != dir->i_version)
 		nfs_force_lookup_revalidate(dir);
 	dir->i_version = cinfo->after;
 	nfsi->attr_gencount = nfs_inc_attr_generation_counter();
 	nfs_fscache_invalidate(dir);
+out:
 	spin_unlock(&dir->i_lock);
 }