Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp69793rdb; Mon, 18 Sep 2023 08:28:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFu3ur+pVTed129EtpQX1nk+K+FUtJ31/wNw22kPzxjLji2+pMBgByv6qgIZftqZq7jWUTZ X-Received: by 2002:a17:90b:ed7:b0:26d:1eec:1fc4 with SMTP id gz23-20020a17090b0ed700b0026d1eec1fc4mr6837353pjb.19.1695050921375; Mon, 18 Sep 2023 08:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695050921; cv=none; d=google.com; s=arc-20160816; b=p4YLkRGDM6MoGf3yWtIj8dhAlscpwhKuQZ8utalqVeX+KpQ/B1dUqzdCz/K1Ca/oAT RqCH18Y+JmhkaBiYpk0YvuJMnqPtT8Hgf5Ts5ODrIuT9vl8RCCjcsQ5ZTXJmSB+GaWze 8erHCWDY1zaU79ZQ5iQKlqI8tFq10rU97+VgiIcKDdzRL9TZSLf6kYTUxwkhng5bml+B maEWl8rd9OP0exadRM5/zrbcZ7/te/oME0R72Yivr6NAienqdmfT6UE9a1EWsqh1Fd3x A2QKz92o9L9AG5yYbnMqUDPn15L8m/Yr1LjdGHvOzvUj6np47I5FPZ+l5X74o5Vf8bp6 TQAg== 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=BZ8cVR+68S7uFzA42kHfw0qrxmu6gc5Vsx7/oUTfluI=; fh=v8a13lpFSZWlL4AptTEJnmXnlqoWXhGCGCgvrcnCT9I=; b=q7k4holZSXj+q8wmSHEoExZ8xHB/WFqvvaAAc+YgH3wlWZHACHura1npvnz+1HkHE8 UzancGmGpUATpf25c/PjFKRunrT3aCQiqKk/kkfEXNzqqoQneTTa/IrIbmXCtT2OoD0d kB2FTwXoC5zJ7esp/+pfY3lJt1wJFrjtHXdI4uTM1ZO4rBePUV9Ss8WNYqjbUyTipong ezwbe2ouyYd0Fyyfa1XS4n8uNUCSpjS9sdpD2eNBYwtsVJYzTqB2W7kjspg15JX81x58 Adhv0PdnTKMeCFRnAl0mhfkuVTcheO2lMNPYXdGayhmjvc6gXgCZoYeH3snAUXqaZzPe rn2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vLameYeY; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id d9-20020a17090ab30900b00263bfa6e205si10401925pjr.50.2023.09.18.08.28.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 08:28:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vLameYeY; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 732EA81DE6B9; Mon, 18 Sep 2023 08:25:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230303AbjIRPZk (ORCPT + 99 others); Mon, 18 Sep 2023 11:25:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229594AbjIRPZk (ORCPT ); Mon, 18 Sep 2023 11:25:40 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BE00119 for ; Mon, 18 Sep 2023 08:23:52 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD52BC116B8; Mon, 18 Sep 2023 14:00:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045632; bh=0rA61je4MVgM+7olbkTsgnOxdL1bTPc/psNMqineibA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=vLameYeYZKkvr2FaL2F33anrv1iCF+5g5BozyuHTXjF6StmcIBN9O9A0gio/jphcv Z8Do6htFs1g8ebHkBOE1bZODoB/j35LV3KjkmA62AAdNurbNGNe2UEFV08jbSPz6GC KEP5okifcHp1wB6gsBvo7Hoj/LvUUjuU98JW1OQKpn6qLt2zCCo5wUE3szft5imyk7 nm18RBTY/8NRwtRUIDuiDeioRQcCWjcxFhu60LQYxmuiUgKInmvinhvyAUW2X5DcWb xKnDwt87dAvOhsvsfhkhQMOfDifLkvs3dn2zq7y/hw+Bxvl+3ub8tMbBUAc+4VIftu N9Ub6l4cMvORQ== Subject: [PATCH v1 35/52] NFSD: Add nfsd4_encode_fattr4_space_free() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:00:30 -0400 Message-ID: <169504563082.133720.7559115861114168422.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=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:25:42 -0700 (PDT) From: Chuck Lever Refactor the encoder for FATTR4_SPACE_FREE 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 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 42ce95b8db43..a9f99f07c904 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3232,6 +3232,14 @@ static __be32 nfsd4_encode_fattr4_space_avail(struct xdr_stream *xdr, return nfsd4_encode_uint64_t(xdr, avail); } +static __be32 nfsd4_encode_fattr4_space_free(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + u64 free = (u64)args->statfs.f_bfree * (u64)args->statfs.f_bsize; + + return nfsd4_encode_uint64_t(xdr, free); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3541,11 +3549,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_SPACE_FREE) { - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - dummy64 = (u64)args.statfs.f_bfree * (u64)args.statfs.f_bsize; - p = xdr_encode_hyper(p, dummy64); + status = nfsd4_encode_fattr4_space_free(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval1 & FATTR4_WORD1_SPACE_TOTAL) { p = xdr_reserve_space(xdr, 8);