NFS: If the cookie verifier changes, we must invalidate the page cache

Ensure that if the cookie verifier changes when we use the zero-valued
cookie, then we invalidate any cached pages.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
This commit is contained in:
Trond Myklebust 2022-02-22 16:23:12 -05:00
parent 580f236737
commit 6c34f05b75

View File

@ -990,9 +990,14 @@ static int find_and_lock_cache_page(struct nfs_readdir_descriptor *desc)
/*
* Set the cookie verifier if the page cache was empty
*/
if (desc->page_index == 0)
if (desc->last_cookie == 0 &&
memcmp(nfsi->cookieverf, verf, sizeof(nfsi->cookieverf))) {
memcpy(nfsi->cookieverf, verf,
sizeof(nfsi->cookieverf));
invalidate_inode_pages2_range(desc->file->f_mapping,
desc->page_index_max + 1,
-1);
}
}
res = nfs_readdir_search_array(desc);
if (res == 0)