From patchwork Wed Feb 23 13:40:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Coddington X-Patchwork-Id: 12756946 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 5E036C433FE for ; Wed, 23 Feb 2022 13:41:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240996AbiBWNlJ (ORCPT ); Wed, 23 Feb 2022 08:41:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240976AbiBWNlI (ORCPT ); Wed, 23 Feb 2022 08:41:08 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2E3A0AC06B for ; Wed, 23 Feb 2022 05:40:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645623639; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fjTKGeI8OtqK7SBy1Z/zaXir5SneRCC72cv4gdc2uQI=; b=E6ETOLeCMF8dBIcby89h12Oks5Xhl7Urlq9952Q+Eh0WuklwQbCe6FL+dpFnnhAnGQiCdu lrSRhsj/sJ/ofOCu0LP2xOPnLnVA5h/YoUMitQjirnQ5sHQ4qHjRrGIhqdOt9p3BdEUiGi Sn2McQ7wqs4RlLort180ycXbRu+/rT4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-391-vdH1e-aVNYqmdLOxdHuEBw-1; Wed, 23 Feb 2022 08:40:38 -0500 X-MC-Unique: vdH1e-aVNYqmdLOxdHuEBw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D717FC80 for ; Wed, 23 Feb 2022 13:40:37 +0000 (UTC) Received: from bcodding.csb (ovpn-64-2.rdu2.redhat.com [10.10.64.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9F381073023 for ; Wed, 23 Feb 2022 13:40:36 +0000 (UTC) Received: by bcodding.csb (Postfix, from userid 24008) id 1622A10C3115; Wed, 23 Feb 2022 08:40:36 -0500 (EST) From: Benjamin Coddington To: linux-nfs@vger.kernel.org Subject: [PATCH v3 8/8] NFS: Revalidate the directory pagecache on every nfs_readdir() Date: Wed, 23 Feb 2022 08:40:35 -0500 Message-Id: In-Reply-To: <71835b457fb123f8e4d51ea9fb586e46016562ff.1645623510.git.bcodding@redhat.com> References: <5479c8c5be9cf3f387edac54f170461f8f7b89e2.1645623510.git.bcodding@redhat.com> <19ef38cda6b0eb6548c65c2bff7a4d4dd1baa122.1645623510.git.bcodding@redhat.com> <71835b457fb123f8e4d51ea9fb586e46016562ff.1645623510.git.bcodding@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Since there's no longer a significant performance penalty for dropping the pagecache, and because we want to ensure that the directory's change attribute is accurate before validating pagecache pages, revalidate the directory's mapping on every call to nfs_readdir(). Signed-off-by: Benjamin Coddington --- fs/nfs/dir.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index a570f14633ab..565ff26e1b52 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1271,11 +1271,9 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) * to either find the entry with the appropriate number or * revalidate the cookie. */ - if (ctx->pos == 0 || nfs_attribute_cache_expired(inode)) { - res = nfs_revalidate_mapping(inode, file->f_mapping); - if (res < 0) - goto out; - } + res = nfs_revalidate_mapping(inode, file->f_mapping); + if (res < 0) + goto out; res = -ENOMEM; desc = kzalloc(sizeof(*desc), GFP_KERNEL);