Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1232540pxb; Thu, 4 Mar 2021 06:42:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3kePL/Y9Ho8qhbRaMByWUSBVmt3uHeMZSpwpEYSlVdULHR7WZT1HnO7/mybTKqWrZPogS X-Received: by 2002:a05:6402:2215:: with SMTP id cq21mr4775176edb.281.1614868943995; Thu, 04 Mar 2021 06:42:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614868943; cv=none; d=google.com; s=arc-20160816; b=0hMH6chGvgaHwUTIQpLzT/+4nddbFqyUy/k7+cTTWOpb6fTlzurMHZkvG8TDut3um3 IviGCorR6WSSPwlncsyjhXTDiW9Y/3M4XpzPlcA2uzauBB7uBKZuEdWIYK3+0h6vVOQj BP2XYHMhX+jmBYY34irkcQGhnW/ZVEewFQeR4MSJ9CxEQJZUgg713aLutSUWWbauymTB nFR/cVg4BRmWw/ciXBg3dv8V2GFSvJ4nhyJX3TYBu5iSk81ASDeK8evht1t/YR4iLUJV FBWXnDN5duwhvxt5Mx8qgIorw82/gQrvhwrsjk2gjXx5cfHbuBS/aP6+cTCmtHeL2kIA jHdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=hDq43FgTjMQqVeHa2y9bAHKINabF4wyv9pW3HHBaFu0=; b=sIaI2udCtptHaxfj9t1CuBQFl8k/Rmmtmq6+dmDwbUEp9CnHJ/ebzBHyX8WvTGx2xS uHtsI65OczxiIK9l9FLffTHUiTMaSKI9rzx/xfWLTjiwugt+RGD2Dx+Vd+3M35FUoTw1 lX/eZQ442PVok2CR4n5Y2hWFoGXTRRX/0/Jz4g+FbuOkI4bMhLF8bqnPp8U9r22aLQai tCMnuccGgi9K7puLLQjSDAMf0c3gcU1mNbGjLWqCi0oAKaUdb7qSkrNcfVJMSEpieEPr Tn/ONV1OkXwyRrIKb3xDOs01hnrsb9UFU8kE0nCDdhipR1+cIx+WKvTHBRdD9hGHLgHq ZKqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=qdlEEufM; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e6si17748758ejb.459.2021.03.04.06.41.51; Thu, 04 Mar 2021 06:42:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=qdlEEufM; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232364AbhCDD4z (ORCPT + 99 others); Wed, 3 Mar 2021 22:56:55 -0500 Received: from smtp-fw-4101.amazon.com ([72.21.198.25]:63784 "EHLO smtp-fw-4101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232934AbhCDD4s (ORCPT ); Wed, 3 Mar 2021 22:56:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1614830209; x=1646366209; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=hDq43FgTjMQqVeHa2y9bAHKINabF4wyv9pW3HHBaFu0=; b=qdlEEufMTiyjsWHFjZStk7o/Txok7GfvBOqpwtSFSsFqV2nvCGbMCcRk o3recBfvoZV7RMOkIvjSWcNni+jmR0QoBzTAmp+9mtXRueqpuBpleCZtn Lu/JoPzMAaIwCAHBuS3iOVzepRdmWHNEaRr7QAB6EvtkX+Wc72Sgd6e6w I=; X-IronPort-AV: E=Sophos;i="5.81,221,1610409600"; d="scan'208";a="89715014" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2c-4e7c8266.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 04 Mar 2021 03:56:07 +0000 Received: from EX13MTAUEE002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-2c-4e7c8266.us-west-2.amazon.com (Postfix) with ESMTPS id C4311A253C; Thu, 4 Mar 2021 03:56:06 +0000 (UTC) Received: from EX13D30UEE001.ant.amazon.com (10.43.62.85) by EX13MTAUEE002.ant.amazon.com (10.43.62.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 4 Mar 2021 03:56:06 +0000 Received: from EX13MTAUEE002.ant.amazon.com (10.43.62.24) by EX13D30UEE001.ant.amazon.com (10.43.62.85) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 4 Mar 2021 03:56:06 +0000 Received: from dev-dsk-gerardu-1d-3da90cb4.us-east-1.amazon.com (10.200.231.78) by mail-relay.amazon.com (10.43.62.224) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 4 Mar 2021 03:56:06 +0000 Received: by dev-dsk-gerardu-1d-3da90cb4.us-east-1.amazon.com (Postfix, from userid 5408343) id 55B924A3; Thu, 4 Mar 2021 03:56:06 +0000 (UTC) Date: Thu, 4 Mar 2021 03:56:06 +0000 From: Geert Jansen To: CC: Subject: Re: [PATCH 1/2] NFS: Don't revalidate the directory permissions on a lookup failure Message-ID: <20210304035605.GA13323@dev-dsk-gerardu-1d-3da90cb4.us-east-1.amazon.com> References: <20210303042836.200413-1-trondmy@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20210303042836.200413-1-trondmy@kernel.org> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Tue, Mar 02, 2021 at 11:28:35PM -0500, trondmy@kernel.org wrote: > From: Trond Myklebust > > There should be no reason to expect the directory permissions to change > just because the directory contents changed or a negative lookup timed > out. So let's avoid doing a full call to nfs_mark_for_revalidate() in > that case. > Furthermore, if this is a negative dentry, and we haven't actually done > a new lookup, then we have no reason yet to believe the directory has > changed at all. So let's remove the gratuitous directory inode > invalidation altogether when called from > nfs_lookup_revalidate_negative(). Thanks! I tested this patch and 2/2 from this series, and I can confirm that it addresses the issue that we were seeing. Tested-by: Geert Jansen > Reported-by: Geert Jansen > Fixes: 5ceb9d7fdaaf ("NFS: Refactor nfs_lookup_revalidate()") > Signed-off-by: Trond Myklebust > --- > fs/nfs/dir.c | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) > > diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c > index 19a9f434442f..6350873cb8bd 100644 > --- a/fs/nfs/dir.c > +++ b/fs/nfs/dir.c > @@ -1401,6 +1401,15 @@ int nfs_lookup_verify_inode(struct inode *inode, unsigned int flags) > goto out; > } > > +static void nfs_mark_dir_for_revalidate(struct inode *inode) > +{ > + struct nfs_inode *nfsi = NFS_I(inode); > + > + spin_lock(&inode->i_lock); > + nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE; > + spin_unlock(&inode->i_lock); > +} > + > /* > * We judge how long we want to trust negative > * dentries by looking at the parent inode mtime. > @@ -1435,7 +1444,6 @@ nfs_lookup_revalidate_done(struct inode *dir, struct dentry *dentry, > __func__, dentry); > return 1; > case 0: > - nfs_mark_for_revalidate(dir); > if (inode && S_ISDIR(inode->i_mode)) { > /* Purge readdir caches. */ > nfs_zap_caches(inode); > @@ -1525,6 +1533,8 @@ nfs_lookup_revalidate_dentry(struct inode *dir, struct dentry *dentry, > nfs_free_fattr(fattr); > nfs_free_fhandle(fhandle); > nfs4_label_free(label); > + if (!ret) > + nfs_mark_dir_for_revalidate(dir); > return nfs_lookup_revalidate_done(dir, dentry, inode, ret); > } > > @@ -1567,7 +1577,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry, > error = nfs_lookup_verify_inode(inode, flags); > if (error) { > if (error == -ESTALE) > - nfs_zap_caches(dir); > + nfs_mark_dir_for_revalidate(dir); > goto out_bad; > } > nfs_advise_use_readdirplus(dir); > @@ -2064,7 +2074,7 @@ nfs_add_or_obtain(struct dentry *dentry, struct nfs_fh *fhandle, > dput(parent); > return d; > out_error: > - nfs_mark_for_revalidate(dir); > + nfs_mark_dir_for_revalidate(dir); > d = ERR_PTR(error); > goto out; > } > -- > 2.29.2 >