Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp520890pxu; Wed, 25 Nov 2020 08:52:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmUPDqCW5FhbBpTTBkycqyuKhZXbC89GAFtn+w1u7RN98scTn17S+ETilJqrCTrMuZc8ES X-Received: by 2002:a17:906:cc4c:: with SMTP id mm12mr3846841ejb.47.1606323148877; Wed, 25 Nov 2020 08:52:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606323148; cv=none; d=google.com; s=arc-20160816; b=yoQPdfA7DuULAb4+v41IlaKwV5c3cqOYBTIqJuE/ghJpcCjHkMgBYcoTN7mUfj/6rt vfJYNWdbu8jO/577JpYZP89dBqXa5PNRM8XuQAbBv4EjkArOutfLF4Zo7nTQoH1l/cde nzn4QdJ1B7jF77/PQHmGS/bH+O0MtyDvF5fbBjVeo1IzGEfNg2k9M9MrDHz2LcWtUUPJ wgxfX1ZI3txBDJ/kMTuLJs8qJUuxxODVKm3sFKkNAdU6jU+FQRhrEQM1iVp/ZfSrD6so JXE57yVMeihghYWdTuoit3DQmaIngTb3IbdYDXiA/tlbjrCTslSK7r43zj8M386Yitmw J8Sw== 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:dkim-filter; bh=79iQY6MryolhzKzOdz+x69Dy3Pn5pciH3/wt+E1DSFc=; b=ZZq0pMBB4ylRU0x7w3B7k+mvMZoUjAcM53bXQmWZkkzTXcTIvcQ6qF3OkTx8lSiHnV Tul5kcamQxjr6csjmoJ7r/i/uJmpvGX+5V7BcWNvtrDJyG1X/K09Jdz1ePm0BUxg8CSB QeumGvoLHti6P07h+HqqO1anuOyQofrDb1qW+xaeSAha6OXQ75Zsbng8+EOagwbd+B4m iQRKe/X9z4cD92YBI99JXrYJZDOHOVZ+sAbMpJhxepkI1AqtrcAIAjGfDpKaD8L7MK2A dAyv9WXlM+b/IF+u44owhBGRGDp8iMl23bm0YW8HXdWYQK4WlXuF553AfvDrT0GMNP7F Cz2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=y7+XaoF1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb31si1489563ejc.465.2020.11.25.08.51.58; Wed, 25 Nov 2020 08:52:28 -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=@fieldses.org header.s=default header.b=y7+XaoF1; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732478AbgKYQrk (ORCPT + 99 others); Wed, 25 Nov 2020 11:47:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732473AbgKYQrk (ORCPT ); Wed, 25 Nov 2020 11:47:40 -0500 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6002DC0613D4 for ; Wed, 25 Nov 2020 08:47:40 -0800 (PST) Received: by fieldses.org (Postfix, from userid 2815) id 5FEB86EAD; Wed, 25 Nov 2020 11:47:38 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 5FEB86EAD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1606322858; bh=79iQY6MryolhzKzOdz+x69Dy3Pn5pciH3/wt+E1DSFc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=y7+XaoF1Hhu4vgU27ihJpiQvcBD8Sj7A74qYwRShJ06uq19WIkLZU+yv7o/gcLvNu I1e6CHzN4y/EUvEvPaQ1Ii2DCnkT5BxsGnNTsqWVF4o1bHgqv1QpwXjxuxwrDSB6hW yckMN9g7LU9jV6GygE7j6vf5tZbZ/EaHFRRbJhMQ= Date: Wed, 25 Nov 2020 11:47:38 -0500 From: "J. Bruce Fields" To: Colin Ian King Cc: Chuck Lever , "linux-nfs@vger.kernel.org" Subject: Re: nfsd: skip some unnecessary stats in the v4 case Message-ID: <20201125164738.GA7049@fieldses.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, Nov 25, 2020 at 02:50:51PM +0000, Colin Ian King wrote: > Static analysis on today's linux-next has found an issue with the > following commit: Thanks! I'll probably do something like this. Though this still all seems slightly more complicated than necessary. --b. diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 8502a493be6d..7eb761801169 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -260,13 +260,12 @@ void fill_pre_wcc(struct svc_fh *fhp) struct inode *inode; struct kstat stat; bool v4 = (fhp->fh_maxsize == NFS4_FHSIZE); - __be32 err; if (fhp->fh_pre_saved) return; inode = d_inode(fhp->fh_dentry); if (!v4 || !inode->i_sb->s_export_op->fetch_iversion) { - err = fh_getattr(fhp, &stat); + __be32 err = fh_getattr(fhp, &stat); if (err) { /* Grab the times from inode anyway */ stat.mtime = inode->i_mtime; @@ -290,23 +289,23 @@ void fill_post_wcc(struct svc_fh *fhp) { bool v4 = (fhp->fh_maxsize == NFS4_FHSIZE); struct inode *inode = d_inode(fhp->fh_dentry); - __be32 err; if (fhp->fh_post_saved) printk("nfsd: inode locked twice during operation.\n"); + fhp->fh_post_saved = true; - if (!v4 || !inode->i_sb->s_export_op->fetch_iversion) - err = fh_getattr(fhp, &fhp->fh_post_attr); + if (!v4 || !inode->i_sb->s_export_op->fetch_iversion) { + __be32 err = fh_getattr(fhp, &fhp->fh_post_attr); + if (err) { + fhp->fh_post_saved = false; + /* set_change_info might still need this: */ + fhp->fh_post_attr.ctime = inode->i_ctime; + } + } if (v4) fhp->fh_post_change = nfsd4_change_attribute(&fhp->fh_post_attr, inode); - if (err) { - fhp->fh_post_saved = false; - /* Grab the ctime anyway - set_change_info might use it */ - fhp->fh_post_attr.ctime = inode->i_ctime; - } else - fhp->fh_post_saved = true; } /*