From: Trond Myklebust Date: Tue, 22 Feb 2022 21:23:12 +0000 (-0500) Subject: NFS: If the cookie verifier changes, we must invalidate the page cache X-Git-Tag: v5.18-rc1~64^2~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c34f05b754622f473b546fd19ad3a89bd65bd89;p=thirdparty%2Fkernel%2Flinux.git 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 --- diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 520dc3ec4aefd..9998d7d173678 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -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)