From patchwork Fri Feb 25 18:28:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 12760786 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02B6EC433F5 for ; Fri, 25 Feb 2022 18:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233335AbiBYSfS (ORCPT ); Fri, 25 Feb 2022 13:35:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233340AbiBYSfQ (ORCPT ); Fri, 25 Feb 2022 13:35:16 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 314611A9058 for ; Fri, 25 Feb 2022 10:34:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 732C6B8330F for ; Fri, 25 Feb 2022 18:34:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4927C340F0 for ; Fri, 25 Feb 2022 18:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645814079; bh=z4mH3Wad3B1ZlApHsjh3QycqAIVXV4F84PeYx1najEs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kBxmFQBJVl6krAiFF8f1gzTUY0EDJowBn3zmtPnVuqMV/P00t3UXPerYyhtea4FAL f9+uNhy+gWWWfMArHhEEZS4e1V/IUhXqD9WyKeROyHDvAFXI2THCP9/ZT0PayuLMrD KrsbBE2l6bs+HHIVN1neWDM+vpV+iBFIgfXo5nQO8QG3e6Fd3zDs7ElsKNyS8VNJZ/ +jcxcK+1CE0Vmb9u/GnAhK+eCyCeY2/3QTOw5l14Gjwl3ttXAsbG9NXxfSQap5gsmb IPT05+K0H0Mry/Tboh3OPgyR+eSoNStZUcp/1ECRNfWsEijRgNb+U4bCeKAsT6tfB4 zCh2ZLgUzGG1g== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH v8 08/24] NFS: If the cookie verifier changes, we must invalidate the page cache Date: Fri, 25 Feb 2022 13:28:13 -0500 Message-Id: <20220225182829.1236093-9-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220225182829.1236093-8-trondmy@kernel.org> References: <20220225182829.1236093-1-trondmy@kernel.org> <20220225182829.1236093-2-trondmy@kernel.org> <20220225182829.1236093-3-trondmy@kernel.org> <20220225182829.1236093-4-trondmy@kernel.org> <20220225182829.1236093-5-trondmy@kernel.org> <20220225182829.1236093-6-trondmy@kernel.org> <20220225182829.1236093-7-trondmy@kernel.org> <20220225182829.1236093-8-trondmy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust 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 --- fs/nfs/dir.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 8cab7edd7420..1ce24e255b2b 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -945,9 +945,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)