Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2627286pxp; Mon, 14 Mar 2022 00:58:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8GtTG+sAxZNPXur2cRTiczfIkoJzEJFEZwyZIuNk0ouJiHXhvmb5+ibP+5AEBypN0EnuB X-Received: by 2002:a17:903:110d:b0:14d:ca16:2c7 with SMTP id n13-20020a170903110d00b0014dca1602c7mr22311989plh.68.1647244727254; Mon, 14 Mar 2022 00:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647244727; cv=none; d=google.com; s=arc-20160816; b=sVPFJwTbdvIR5/b29yyNAu2ueCm4YkI3IhmPuIj/xzKtwYO87jlGL1N+FKWEidpWvF 0ZVi6r0PRJz34Awxoio4k3NcTrv8XvUrx8quwv9B429rrLHg8qZ7P5tYG10/1f53MZHv 2p9yA7ovtKhKweTGbxmh4XAPe9+XJ3DAsE0t/v6dsp50/ldy/fwalIdap+wT3+aQhXrV 2DUczGBec3y8VFxNS9LQmAczRtXG0EE9c/1FLcKiopKm1Xq1JA4cclZjnWAk7JY8e2lz uSaRSUHm9oQd9EUTP3MY+4UeTm9oX4aZTm9xqIvLgxMP4koLuWA+1HmsZ25uYBcMclT2 Xdhw== 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=XzQsr700Y03/FxXCXIoC1o26xIWMNfC9L7lg6QdUkOc=; b=XSfuiIW6CETYAenFmbOgJ8LppuWQFJD+HAHdgvn3ekAxjAQPPF1AutIs1MwohLV1dw hRfhAytcWZGtkx1f+V2Ee1OM8LZnaP6CcoHvKC6n1k340SwE7EpVuCVpNgG2fDagT4s5 Y5uXk4biYIwR+RbfUL23AKDSr4XAGNXyEWr+oMtsM+m8vN+O6AZRhe6JtJJoj1W6/76+ 82Mq9zEetcmcG7r/bG439ezY0utcrd6Utx8aidrgwYkKVbws9mD3r+ebA3nT1WdgQ2k6 IRPf1msQ5fuSGRn0vZLTCqMy6YMrOSkVX7V8K2d+H4L1hpE5O8sW8Xn1rAz4eEKdQHWx uH/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Lh3dapmS; 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 k18-20020a63ff12000000b00373e14b3b79si14888230pgi.74.2022.03.14.00.58.33; Mon, 14 Mar 2022 00:58:47 -0700 (PDT) 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=Lh3dapmS; 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 S235120AbiCMRNW (ORCPT + 99 others); Sun, 13 Mar 2022 13:13:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235118AbiCMRNT (ORCPT ); Sun, 13 Mar 2022 13:13:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A103D13A1E1 for ; Sun, 13 Mar 2022 10:12:11 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 219476122D for ; Sun, 13 Mar 2022 17:12:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B86CFC340F4 for ; Sun, 13 Mar 2022 17:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647191530; bh=DLK2UGtIautxGoPZbgLFz5UlZ4TdoRzxssBXUh6+AQU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Lh3dapmS9WnIXCq7Hzwn9NhY07r//oHE/ZGyb38p1+CX1McixYihwwdM4e57ypDKN KO7lV2Kb6PSGnGc+5ua2nyJ+qBu279mYzPB/RDAQdLE4Gfhl40JtYkIXf7zfflRGAs 9+FdD5uXrhgoqtoTafU3viOWlg2LvcyN2mf+7BxS2A2o+Rwo0yHn8LK+Zl4vf5mNar 387qM3McfqV2MBOEhR+AwU2kNLX+/PDzcpOjClNGzac0xJv5XabkJIXR1TeTguRm/q vf3kC4NP7DPNqqp5tai+vzWPbk31jssnDJabfWS411l1p/H5c/f32msQDV05T2LY1r Q+r4BAX8VhASQ== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH v10 18/26] NFS: Don't request readdirplus when revalidation was forced Date: Sun, 13 Mar 2022 13:05:49 -0400 Message-Id: <20220313170557.5940-19-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220313170557.5940-18-trondmy@kernel.org> References: <20220313170557.5940-1-trondmy@kernel.org> <20220313170557.5940-2-trondmy@kernel.org> <20220313170557.5940-3-trondmy@kernel.org> <20220313170557.5940-4-trondmy@kernel.org> <20220313170557.5940-5-trondmy@kernel.org> <20220313170557.5940-6-trondmy@kernel.org> <20220313170557.5940-7-trondmy@kernel.org> <20220313170557.5940-8-trondmy@kernel.org> <20220313170557.5940-9-trondmy@kernel.org> <20220313170557.5940-10-trondmy@kernel.org> <20220313170557.5940-11-trondmy@kernel.org> <20220313170557.5940-12-trondmy@kernel.org> <20220313170557.5940-13-trondmy@kernel.org> <20220313170557.5940-14-trondmy@kernel.org> <20220313170557.5940-15-trondmy@kernel.org> <20220313170557.5940-16-trondmy@kernel.org> <20220313170557.5940-17-trondmy@kernel.org> <20220313170557.5940-18-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 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 If the revalidation was forced, due to the presence of a LOOKUP_EXCL or a LOOKUP_REVAL flag, then readdirplus won't help. It also can't help when we're doing a path component lookup. Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index dcfc44411787..cf7974642a19 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -694,10 +694,13 @@ void nfs_readdir_record_entry_cache_miss(struct inode *dir) } } -static void nfs_lookup_advise_force_readdirplus(struct inode *dir) +static void nfs_lookup_advise_force_readdirplus(struct inode *dir, + unsigned int flags) { if (nfs_server_capable(dir, NFS_CAP_CASE_INSENSITIVE)) return; + if (flags & (LOOKUP_EXCL | LOOKUP_PARENT | LOOKUP_REVAL)) + return; nfs_readdir_record_entry_cache_miss(dir); } @@ -1596,15 +1599,17 @@ nfs_lookup_revalidate_delegated(struct inode *dir, struct dentry *dentry, return nfs_lookup_revalidate_done(dir, dentry, inode, 1); } -static int -nfs_lookup_revalidate_dentry(struct inode *dir, struct dentry *dentry, - struct inode *inode) +static int nfs_lookup_revalidate_dentry(struct inode *dir, + struct dentry *dentry, + struct inode *inode, unsigned int flags) { struct nfs_fh *fhandle; struct nfs_fattr *fattr; unsigned long dir_verifier; int ret; + trace_nfs_lookup_revalidate_enter(dir, dentry, flags); + ret = -ENOMEM; fhandle = nfs_alloc_fhandle(); fattr = nfs_alloc_fattr_with_label(NFS_SERVER(inode)); @@ -1625,6 +1630,10 @@ nfs_lookup_revalidate_dentry(struct inode *dir, struct dentry *dentry, } goto out; } + + /* Request help from readdirplus */ + nfs_lookup_advise_force_readdirplus(dir, flags); + ret = 0; if (nfs_compare_fh(NFS_FH(inode), fhandle)) goto out; @@ -1634,8 +1643,6 @@ nfs_lookup_revalidate_dentry(struct inode *dir, struct dentry *dentry, nfs_setsecurity(inode, fattr); nfs_set_verifier(dentry, dir_verifier); - /* set a readdirplus hint that we had a cache miss */ - nfs_lookup_advise_force_readdirplus(dir); ret = 1; out: nfs_free_fattr(fattr); @@ -1701,8 +1708,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry, if (NFS_STALE(inode)) goto out_bad; - trace_nfs_lookup_revalidate_enter(dir, dentry, flags); - return nfs_lookup_revalidate_dentry(dir, dentry, inode); + return nfs_lookup_revalidate_dentry(dir, dentry, inode, flags); out_valid: return nfs_lookup_revalidate_done(dir, dentry, inode, 1); out_bad: @@ -1896,7 +1902,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in goto out; /* Notify readdir to use READDIRPLUS */ - nfs_lookup_advise_force_readdirplus(dir); + nfs_lookup_advise_force_readdirplus(dir, flags); no_entry: res = d_splice_alias(inode, dentry); @@ -2159,7 +2165,7 @@ nfs4_do_lookup_revalidate(struct inode *dir, struct dentry *dentry, reval_dentry: if (flags & LOOKUP_RCU) return -ECHILD; - return nfs_lookup_revalidate_dentry(dir, dentry, inode); + return nfs_lookup_revalidate_dentry(dir, dentry, inode, flags); full_reval: return nfs_do_lookup_revalidate(dir, dentry, flags); -- 2.35.1