From patchwork Mon Sep 18 13:59:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389796 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD0E3C46CA1 for ; Mon, 18 Sep 2023 15:19:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229485AbjIRPTz (ORCPT ); Mon, 18 Sep 2023 11:19:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229816AbjIRPTz (ORCPT ); Mon, 18 Sep 2023 11:19:55 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDA591B1 for ; Mon, 18 Sep 2023 08:17:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F6F2C116AA; Mon, 18 Sep 2023 13:59:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045549; bh=2tTiLWjSE0xTFsPSbpcVZBTqanE16fMKfgbZbzhmOI4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=scbRAqURoKU3q+/txUObmUjjEg4CG4/eWFVH8QNsJ/xnQupPLCmFEl7ZO8oJ7C6ZF xowMNHrW+MeVJLGaY7jLnAlZXGzit6jUp1ZnL5RENQyd+olbgmKZQFdJqL3YtTOKs0 1kAPfZbK27gr7hHUhxBYxZ/5YKeIe6URWriV0e3J1obHo/8rH9eBpy/Uft58p6yFTB 4c0k8fI9jONU0v0GmCNQec1u15LJGfAP+uh2oegwH+e6v9oA4lsMxfsG28dQi89aRj z/ysqtETBQ5+dXrPs/GRAQHD5aB5Ljcyt5nIQrZ7kiHVDdiEFZz2xuFJt2APdaH0NL dbGD99oeUUO/A== Subject: [PATCH v1 22/52] NFSD: Add nfsd4_encode_fattr4_files_total() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:59:08 -0400 Message-ID: <169504554835.133720.17294133416349563907.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 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Chuck Lever Refactor the encoder for FATTR4_FILES_TOTAL 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 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index ee5fd6ff12e0..e024742abc73 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3154,6 +3154,12 @@ static __be32 nfsd4_encode_fattr4_files_free(struct xdr_stream *xdr, return nfsd4_encode_uint64_t(xdr, args->statfs.f_ffree); } +static __be32 nfsd4_encode_fattr4_files_total(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_uint64_t(xdr, args->statfs.f_files); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3388,10 +3394,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_FILES_TOTAL) { - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - p = xdr_encode_hyper(p, (u64) args.statfs.f_files); + status = nfsd4_encode_fattr4_files_total(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_FS_LOCATIONS) { status = nfsd4_encode_fs_locations(xdr, rqstp, exp);