Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp70253rdb; Mon, 18 Sep 2023 08:29:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFaLyLjrev6h3X9tE86EHTr2btMaxDLxJLpdoxesPMa+pp6ZAvn/+EsMRxax6GSS/0bKnSp X-Received: by 2002:a17:902:d2cd:b0:1c3:e5bf:a9f8 with SMTP id n13-20020a170902d2cd00b001c3e5bfa9f8mr12836424plc.19.1695050954302; Mon, 18 Sep 2023 08:29:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695050954; cv=none; d=google.com; s=arc-20160816; b=zZBT6+RJ+0CKmB2aBY2sYcxIEgGbuFXxCpTHQSC5fGWCjW+6usR0uxi/lm4lL/ZepX HsFx92lqmqSmhgpx3THe6vI8MLGBOylETly+aeO/QOIIBEeKRYADCC8KQjIqyDhAUphh puSs+0uVV7D7gFm1tVi0eI8i97+PU2QQOeSjcyPYpruEs+2xNJk78IF9+vAUFkgl2KN2 FfBrm7ogyICBUBmmJpdUCFzXHle+0/LvjmUVd3Cy4mTsDR4jt723k6JOpp6fy9Jl68FY FvT3lzbVWIrZhw9MmsPjWZKtN3mVL0KfX7VvF9EhnFPxWutKsAKCfdzoiRioW4WCStSf jvDg== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=3YYSYnd5owOTzYyU14JHKVk3KTzwKE4ak/13Oz1qEOc=; fh=v8a13lpFSZWlL4AptTEJnmXnlqoWXhGCGCgvrcnCT9I=; b=WFArhkm+gcJ/EFVB4sqwMX/Ae9N/4ntewlaK6H6E5Ow4vMUwWFIA51YT7nmXbexsNr A1cQxEffERIgG5FY/U9hK0Fh2/kiaTq3xSS4snTQtslQxX8GFSOmFQYFx4UTGIfOsTdV KSbVhC4STgX+yg+xpQv27Fuu5zRQJYKj8S+KKElmB+vQdVEQj1Cn8HYTVowIM6BzsFBe S4MAfsEv8UaoPM5qK5b5UKQxDd+BkfZYNYP+pe1w+wdAzjRqRX6h/nhfimgl9OV2JfiM uPHecpbd5js9X3HxR4usAHNSAWSyZ6WcjtP/y39x5H0ewmvgpTOfaG7vKPBE9XbP76/d Z2JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=h92miaQX; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id l4-20020a17090270c400b001befd0512ecsi7987130plt.314.2023.09.18.08.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 08:29:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=h92miaQX; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 4F52582289BB; Mon, 18 Sep 2023 08:23:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240708AbjIRPYA (ORCPT + 99 others); Mon, 18 Sep 2023 11:24:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240922AbjIRPX4 (ORCPT ); Mon, 18 Sep 2023 11:23:56 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF3B91FC9 for ; Mon, 18 Sep 2023 08:20:15 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A46B3C433BB; Mon, 18 Sep 2023 13:57:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045453; bh=GEsAEExO4y+S5I/UadBh8vwvamHfz4M2jAlEXh+qgVk=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=h92miaQXWtMtNT0TupCFi7FgGifGWeOeUh3ppXmAQQAHPuu6TGllZW3djpkjpogMi shMeo9u3rSJrfzlRQpf1bWMtmqi+4Ecz3lxBDfJGTyw0g8FL5mW09lXj9tdl2j6XZT 23Xz1avKVQbPI8azFj8E2/TTLL3VtS2ij8fam0hIrxVYF//xU7c4I6hlpRdIO4PTJ4 6P1hmIJxfUGbbMDScz85jnH/Uw0oK2c+VP/XVlIkmM+o2J9H6E1OHMcGXJU6h4hdg1 Oycmor35OYWW/h+y7Hp+iogdJ74pad+/df6ki2YA8B9HR8+QJffIWJvWNd/kjcMbOM 0p3R1AxSgxkcA== Subject: [PATCH v1 07/52] NFSD: Add nfsd4_encode_fattr4_supported_attrs() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:57:32 -0400 Message-ID: <169504545266.133720.1680333025960206097.stgit@manet.1015granger.net> In-Reply-To: <169504501081.133720.4162400017732492854.stgit@manet.1015granger.net> References: <169504501081.133720.4162400017732492854.stgit@manet.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:23:58 -0700 (PDT) From: Chuck Lever Refactor the encoder for FATTR4_SUPPORTED_ATTRS into a helper. In a subsequent patch, this helper will be called from a bitmask loop. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 91f3b03f297b..da5df33cac04 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2939,7 +2939,9 @@ nfsd4_encode_bitmap4(struct xdr_stream *xdr, u32 bmval0, u32 bmval1, u32 bmval2) } struct nfsd4_fattr_args { + struct svc_rqst *rqstp; struct svc_fh *fhp; + struct dentry *dentry; struct kstat stat; struct kstatfs statfs; struct nfs4_acl *acl; @@ -2959,6 +2961,22 @@ static __be32 nfsd4_encode_fattr4__false(struct xdr_stream *xdr, return nfsd4_encode_bool(xdr, false); } +static __be32 nfsd4_encode_fattr4_supported_attrs(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + struct nfsd4_compoundres *resp = args->rqstp->rq_resp; + u32 minorversion = resp->cstate.minorversion; + u32 supp[3]; + + memcpy(supp, nfsd_suppattrs[minorversion], sizeof(supp)); + if (!IS_POSIXACL(d_inode(args->dentry))) + supp[0] &= ~FATTR4_WORD0_ACL; + if (!args->contextsupport) + supp[2] &= ~FATTR4_WORD2_SECURITY_LABEL; + + return nfsd4_encode_bitmap4(xdr, supp[0], supp[1], supp[2]); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -2996,6 +3014,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, BUG_ON(bmval1 & NFSD_WRITEONLY_ATTRS_WORD1); BUG_ON(!nfsd_attrs_supported(minorversion, bmval)); + args.rqstp = rqstp; + args.dentry = dentry; + args.rdattr_err = 0; if (exp->ex_fslocs.migrated) { status = fattr_handle_absent_fs(&bmval0, &bmval1, &bmval2, @@ -3081,30 +3102,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out_resource; if (bmval0 & FATTR4_WORD0_SUPPORTED_ATTRS) { - u32 supp[3]; - - memcpy(supp, nfsd_suppattrs[minorversion], sizeof(supp)); - - if (!IS_POSIXACL(dentry->d_inode)) - supp[0] &= ~FATTR4_WORD0_ACL; - if (!args.contextsupport) - supp[2] &= ~FATTR4_WORD2_SECURITY_LABEL; - if (!supp[2]) { - p = xdr_reserve_space(xdr, 12); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(2); - *p++ = cpu_to_be32(supp[0]); - *p++ = cpu_to_be32(supp[1]); - } else { - p = xdr_reserve_space(xdr, 16); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(3); - *p++ = cpu_to_be32(supp[0]); - *p++ = cpu_to_be32(supp[1]); - *p++ = cpu_to_be32(supp[2]); - } + status = nfsd4_encode_fattr4_supported_attrs(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_TYPE) { p = xdr_reserve_space(xdr, 4);