Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp138963rdb; Mon, 18 Sep 2023 10:17:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGkXw0/6lk8Rs98YDQhkURdiuLpsZgSi7Xzh3CqklnTUNNsJvM2WNd90IW59IRKT71/jgeZ X-Received: by 2002:a05:6a20:8f02:b0:13f:13cb:bc50 with SMTP id b2-20020a056a208f0200b0013f13cbbc50mr343883pzk.25.1695057468168; Mon, 18 Sep 2023 10:17:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695057468; cv=none; d=google.com; s=arc-20160816; b=I6f6JvPE9moeABxhb5WxsBySIEAfqvKqMnCHFfKTVCNciXMrqGAJCjQX3WPPGl8pEI Y78Go1ibneG4sPyOUfZ/8YLNKbtWPQlpwRNkUlhuJqvLtymA32cdC6jqx9OrhBtraWLd AeT1YeJWXpFDvqGaZp5w0oDaWqGe5L52EdLNrG9rn9Oo2zSbwfPY8Ywqd6a6xgazLnXV K6TPdR5X2pfDCfH5b5pL4PLP1mIkpe/X5h4zJYogQjw7I2zNJZH1tnrkazcmsy5WMo+R Rc6tMEgWofhPnUmTG+PpgghaUKR6ntRL4cQwybgPSLk/y+Nl08TJ31tpb1bUhkTsbh5K 7FJg== 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=6Ds4Nq7KXg28+0T5EM+xbG2Dfs9owvvGy93hm65YmLg=; fh=v8a13lpFSZWlL4AptTEJnmXnlqoWXhGCGCgvrcnCT9I=; b=IckCSzVJ6adUncfDvkzWkH10dVeh7CV0oMZwk0H0JNTOhF3spKseexyom5/Q0JnEL1 4eG0ZK9DUHCXpqYUO3dmaMQam+/8Vwhr42LOnG/aIL502j75YUafhxh9GQ2iFzpSd3at GmL5AdHZYdMkS5tJbDpJKBgfLXC+P23Bz8TpINmaODLT5mPpo/Ui5h37QRKKABYLXSE9 SDuT/1UWruaMfxJp4rO7GmFh1YwFUt26cO+Kd7DEJp6t2QBMJVHHnBxBcfTPQgiQav61 PHfUSwQnwaDwKVLCPfpsQ6XIh0kErh0afJyy0g7A4WgEAnY67qUaJf5FG9vjSS/PS2EB 2Uqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jesLm3b5; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.34 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. [23.128.96.34]) by mx.google.com with ESMTPS id 191-20020a6300c8000000b00573f7b6999csi388926pga.440.2023.09.18.10.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 10:17:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jesLm3b5; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.34 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 590EE826EB8A; Mon, 18 Sep 2023 09:37:17 -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 S229940AbjIRQhR (ORCPT + 99 others); Mon, 18 Sep 2023 12:37:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229959AbjIRQhF (ORCPT ); Mon, 18 Sep 2023 12:37:05 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFD8A10EC for ; Mon, 18 Sep 2023 09:32:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BE2AC116C8; Mon, 18 Sep 2023 14:00:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045644; bh=nz7M/7fJkXOEKpIQBL+96nYyjmhMOTogIENkPcpowQ8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=jesLm3b5ZD4i5szll0qSiOeV5f0yghCJAUQaishEfFg+UdOsmVS/UPnQHGFH2U94s iwqMci6x2LbByzTnyR1lzgYW9+CMhJAH8aPoW1+tq/5eznrTcwUIPGz5ks0IH0x+AB OvRKdYB+MmbaRqFESsZwmvPIESFE/nWGIeM4nJ1FTMcYCNJ6yIK3e7VjYfTZdZotD+ xxz3GAzjLXeNjzAQaPd8QLFDP6JCplmW0kYERl8Rwkp2QHpvFltgJ65hoXU79L3d11 6B9gStvVV8FukF4tXhuP7pO7+1LzV8//EemsH4cSWnn5VMk/md6ME/D++LTweAbfeY yoVVdO+fwo7gQ== Subject: [PATCH v1 37/52] NFSD: Add nfsd4_encode_fattr4_space_used() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:00:43 -0400 Message-ID: <169504564361.133720.14162626952512302812.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 09:37:18 -0700 (PDT) From: Chuck Lever Refactor the encoder for FATTR4_SPACE_USED 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 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 963fa2ccadd7..80be20217402 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3248,6 +3248,12 @@ static __be32 nfsd4_encode_fattr4_space_total(struct xdr_stream *xdr, return nfsd4_encode_uint64_t(xdr, total); } +static __be32 nfsd4_encode_fattr4_space_used(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_uint64_t(xdr, (u64)args->stat.blocks << 9); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3266,7 +3272,6 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, __be32 *p, *attrlen_p; int starting_len = xdr->buf->len; int attrlen_offset; - u64 dummy64; __be32 status; int err; #ifdef CONFIG_NFSD_V4_SECURITY_LABEL @@ -3567,11 +3572,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_SPACE_USED) { - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - dummy64 = (u64)args.stat.blocks << 9; - p = xdr_encode_hyper(p, dummy64); + status = nfsd4_encode_fattr4_space_used(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval1 & FATTR4_WORD1_TIME_ACCESS) { status = nfsd4_encode_nfstime4(xdr, &args.stat.atime);