Skip to contentSkip to conversation

NFS: Only change the cookie verifier if the directory page cache is empty

PATCH New [email protected] 1 participant 1 message Mar 17, 2021

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 NFS: Only change the cookie verifier if the directory page cache is empty

From: Trond Myklebust <[email protected]>

The cached NFSv3/v4 readdir cookies are associated with a verifier, which is checked by the server on subsequent calls to readdir, and is only expected to change when the cookies (and hence also the page cache contents) are considered invalid.
We therefore do have to store the verifier, but only when the page cache is empty.

Fixes b593c09f83a2 ("NFS: Improve handling of directory verifiers")
---
 fs/nfs/dir.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/nfs/dir.c +6 -1
index 2cf2a7d92faf..0cd7c59a6601 100644
@@ -929,7 +929,12 @@ static int find_and_lock_cache_page(struct nfs_readdir_descriptor *desc)
 			}
 			return res;
 		}
-		memcpy(nfsi->cookieverf, verf, sizeof(nfsi->cookieverf));
+		/*
+		 * Set the cookie verifier if the page cache was empty
+		 */
+		if (desc->page_index == 0)
+			memcpy(nfsi->cookieverf, verf,
+			       sizeof(nfsi->cookieverf));
 	}
 	res = nfs_readdir_search_array(desc);
 	if (res == 0) {
Signature · 1 line
2.30.2