Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2043830pxb; Fri, 29 Jan 2021 11:28:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwD/gy2IhsbbbKMpCSiUjMtrmwznW7pDF9t00Wd9NyWRceMZJG7O5JPRVkrix1WD0IuPzZq X-Received: by 2002:a17:906:1c42:: with SMTP id l2mr6201064ejg.390.1611948515960; Fri, 29 Jan 2021 11:28:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611948515; cv=none; d=google.com; s=arc-20160816; b=dyn7UNmcGO9FUHr9f+GrhGu14szCl/DEWOp93kgVLRosJYpoeev/DcaaO3SZkNb3ED SrqPnmIKSgnIIppV/Je5QUVnEktFymlczg3eaG6yo1+ObHBsLZ2yAROSS3tw/ISSUvP0 36IcqM822bPcwMq8CMOCwUK2OJWyFfpL2ojVkSLJibS7KkjkxfxukFMIBVJ71BA9xb3t Yw48cHZfTcOz9D1H60Sru6BVzy5ouGYcwDb6YfZXibjoLp7F2rKfbk5pInhRESYcKf/a 4dySEoNpDQC9vvEvx8L9F0Z2BWQZeVyqGA4I+kE95SBs8JiQuu9obhjCkOrrtfXcR943 QkPg== 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=Czt3r+DII0qD79e+XDEsUiPQlCPOuV8iSW4i1vozb+8=; b=bZjUEazSXbCqBUmon+vO5+2WWo5J0G8IHImt1kIEtdbfxM+jbm0vX++Vs34goaXNR9 eQ2MMgtISGr/wHJZwt//JUIdM+Am8dAWCrQCZs2+AgVGaYQ6wf0hdXnP2+1cffoB7sUO axaPmCbyvEKxX4+egEVAwL/Xr8uLJYFnBAOerh3DnQv6P0Bv+7+FLd0okI35N+ABGSiu AP+aYutp4uGGlLrhCw+eqggOjtIlEWNeGS8L/tDcvxrWOWrTGQtE6+gLogwTpCUG6eR4 j/+92scCPTpXTr1yHG6O7QbL0Adn8UXMdDFo4ljtSYLv0tHoKuSOB/pkKmmX0NP2+jK0 J9bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=cMQpszRG; 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 f25si5198475ejc.384.2021.01.29.11.28.11; Fri, 29 Jan 2021 11:28:35 -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=cMQpszRG; 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 S232995AbhA2T1S (ORCPT + 99 others); Fri, 29 Jan 2021 14:27:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232855AbhA2T1R (ORCPT ); Fri, 29 Jan 2021 14:27:17 -0500 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07F07C061574; Fri, 29 Jan 2021 11:27:02 -0800 (PST) Received: by fieldses.org (Postfix, from userid 2815) id 7A2254163; Fri, 29 Jan 2021 14:27:01 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 7A2254163 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1611948421; bh=Czt3r+DII0qD79e+XDEsUiPQlCPOuV8iSW4i1vozb+8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cMQpszRGMhwbbGuK/BZ9DB3fryZxvUhKKBw3H85anxYNPA8OVrSPULJsKsHwHgFYh anIOtEZeNVlWSQ9PVxujP+gOSotRy2Ind+fOTw08so9petmb704BQsF2/zE8Pnt1fZ YmbpBpsLyoq9E3zx3CStYrN6jWfnAD+woZJs17yg= Date: Fri, 29 Jan 2021 14:27:01 -0500 From: "J. Bruce Fields" To: Christoph Hellwig Cc: "J. Bruce Fields" , linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Trond Myklebust , Anna Schumaker , Chuck Lever Subject: [PATCH 2/2 v2] nfsd: skip some unnecessary stats in the v4 case Message-ID: <20210129192701.GD8033@fieldses.org> References: <1611084297-27352-1-git-send-email-bfields@redhat.com> <1611084297-27352-3-git-send-email-bfields@redhat.com> <20210120084638.GA3678536@infradead.org> <20210121202756.GA13298@pick.fieldses.org> <20210122082059.GA119852@infradead.org> <20210129192629.GC8033@fieldses.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210129192629.GC8033@fieldses.org> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: "J. Bruce Fields" In the typical case of v4 and an i_version-supporting filesystem, we can skip a stat which is only required to fake up a change attribute from ctime. Signed-off-by: J. Bruce Fields --- fs/nfsd/nfs3xdr.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 821db21ba072..8bcda5274089 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -252,6 +252,11 @@ encode_wcc_data(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp) return encode_post_op_attr(rqstp, p, fhp); } +static bool fs_supports_change_attribute(struct super_block *sb) +{ + return sb->s_flags & SB_I_VERSION || sb->s_export_op->fetch_iversion; +} + /* * Fill in the pre_op attr for the wcc data */ @@ -260,24 +265,25 @@ 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_no_wcc || fhp->fh_pre_saved) return; inode = d_inode(fhp->fh_dentry); - err = fh_getattr(fhp, &stat); - if (err) { - /* Grab the times from inode anyway */ - stat.mtime = inode->i_mtime; - stat.ctime = inode->i_ctime; - stat.size = inode->i_size; + if (fs_supports_change_attribute(inode->i_sb) || !v4) { + __be32 err = fh_getattr(fhp, &stat); + if (err) { + /* Grab the times from inode anyway */ + stat.mtime = inode->i_mtime; + stat.ctime = inode->i_ctime; + stat.size = inode->i_size; + } + fhp->fh_pre_mtime = stat.mtime; + fhp->fh_pre_ctime = stat.ctime; + fhp->fh_pre_size = stat.size; } if (v4) fhp->fh_pre_change = nfsd4_change_attribute(&stat, inode); - fhp->fh_pre_mtime = stat.mtime; - fhp->fh_pre_ctime = stat.ctime; - fhp->fh_pre_size = stat.size; fhp->fh_pre_saved = true; } @@ -288,7 +294,6 @@ 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_no_wcc) return; @@ -296,12 +301,15 @@ void fill_post_wcc(struct svc_fh *fhp) if (fhp->fh_post_saved) printk("nfsd: inode locked twice during operation.\n"); - err = fh_getattr(fhp, &fhp->fh_post_attr); - if (err) { - fhp->fh_post_saved = false; - fhp->fh_post_attr.ctime = inode->i_ctime; - } else - fhp->fh_post_saved = true; + fhp->fh_post_saved = true; + + if (fs_supports_change_attribute(inode->i_sb) || !v4) { + __be32 err = fh_getattr(fhp, &fhp->fh_post_attr); + if (err) { + fhp->fh_post_saved = false; + fhp->fh_post_attr.ctime = inode->i_ctime; + } + } if (v4) fhp->fh_post_change = nfsd4_change_attribute(&fhp->fh_post_attr, inode); -- 2.29.2