Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp512495pxm; Fri, 25 Feb 2022 12:37:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXfSFzZQKg3NXJvr7fElR+HU8/TCcCePW16qOj5eBJRlP3HsSJ9slgu1KumGfSn0F2K2fO X-Received: by 2002:aa7:cb18:0:b0:413:3a7a:b5d6 with SMTP id s24-20020aa7cb18000000b004133a7ab5d6mr8806633edt.254.1645821441208; Fri, 25 Feb 2022 12:37:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645821441; cv=none; d=google.com; s=arc-20160816; b=ex+qfYP3sapx144dsA1WBHNedS4xKjTtFWFcA52rlJIkoL7w1PWQxqKLvq/pgwNR7M kOpyChuPnFI+5oAOP0jFqBwUcdIlLgE2EFfZOYK31Rh+ujHAOglkgnOb6WczVOYofEr2 EtgJQ/r4wLAJBdtvJGm9gsv6LSWH6RpVI896kN9CEEPHJChcjNo5xNRijvCST3MX6Nwx BBWhQ1l53INB2HZK2RCgGqiK3Ssvw0TXkg6qBR2MBQFuKGF84iY2+fZ+8QbJaIneCqc2 PDlq+tZIohqwhYU7aAvOSqFXZLAjhQwYRfHrf0k9mnUmXpwxFcWeACoCOLu5HdcWQll5 hpdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=DDHTkf+CycfYddnor/UrvivSXJ3ZWx7zqiUX+4naTnQ=; b=wEiXj3TTHVhCRVOMxc0/xI/ZwqNa5V6yuRxj41FWXwxi0B120awvEbHSPMV0F2JJIn iNb4C/sKhkoySanJxL+OqvOUlNLTz+serezkLXwNxNpxbf++obEywN8LVIuwyO9wtKmd rdOnnbhcqCR87KBv5QwilghedtADodG9x72lXiNX33MBmEPiNgf7Y3gQ1uhvMhMLfQWk pR8yQTar7mZO6Fv2f4K53EZt+iWBwy34NNPCFNzZHNnjPyt3CwcCfDcKC1mEt78HtJeB 28dLehlJgK3dZ/zIhmU5aQtqRt8YT8xHL3d1ewADUpq5zKot53UtHavUvWsp9FKasiX9 S+Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kBxmFQBJ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d7-20020a50e407000000b0040faed1f086si2531049edm.388.2022.02.25.12.36.47; Fri, 25 Feb 2022 12:37:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kBxmFQBJ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233335AbiBYSfS (ORCPT + 99 others); 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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) -- 2.35.1