Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp69610rdb; Mon, 18 Sep 2023 08:28:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGv+BjqqcT03iQyL6cIuWztxM4FQc7UpTg6PHYxFI15K02sUc4GUlZDt7Grlw+vlt/yn2tg X-Received: by 2002:a17:90a:cb0e:b0:274:748c:9c55 with SMTP id z14-20020a17090acb0e00b00274748c9c55mr6726834pjt.20.1695050908437; Mon, 18 Sep 2023 08:28:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695050908; cv=none; d=google.com; s=arc-20160816; b=IJYI/RxQFsKuJdManNAxLu31DXtBDPR0JSggZko8xYlUbupkrA9jZ4iyIawQyc1Y0B zg8V6aRivU69cykbAF2DWfJ2wSskVoQ7sGscuyHgo7jsiDNnaeF26LO6CCaExxRI2R8a Yc4x6Q3eQBw1BWaCF0Bmg9aE7PWY3RKDziM2NFsti/fHhJQVow7fsinezETfUjGJn0fX nFLn5X0n/Aq3Taire7L/LdhE2iglw4cot8H6mnBTQ9c3xlr49slHffhGqx8+LzJ6U7Gf +EL+o69dmbzA8PIVVF4w/y3dGY+CR9OtwHrlcwnmFSz23MnmBcRMTk5hSvpOcHHS1sCr 8DsQ== 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=8gItN5/k2Cc+na8DOeq6lDRAF7GwEWfmQwws0+SC0og=; fh=v8a13lpFSZWlL4AptTEJnmXnlqoWXhGCGCgvrcnCT9I=; b=IG64hL7hxb+4PLdbGhgRRgd7RYN8D5kGJMrYNzNzp/A510Um7uAZVieJj/ke+UY+n0 xIQi07elNba0Rrr4AsB1uGRh0Vo7iPHcyCPwvT7JvOf65PQrvjTQ2Va2+dITJQwWyX3r Kz5rNuK96gwAsu4VsVfutzso1V8htAio2PBlx7pUZ1VU9JtOws+C8mkWaAmNkUPwVy1q AmCvUG1GyM7nt4FYYlrAJ2fguNL+TTOX8ZIt3vM35zbImLuwIqmi6v8PDOPCuZQhk4ca A3dQYYbkF0IJ0aQQP18Z7ExUVYZuAoGpqjRkThlUYUsh9MJrn7W494yjPJbEkZYPwPsX g3rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GmkPLi5F; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id j10-20020a17090a734a00b002680e08a877si10078915pjs.186.2023.09.18.08.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 08:28:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GmkPLi5F; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id CD099808D6AD; Mon, 18 Sep 2023 08:22:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239727AbjIRPWV (ORCPT + 99 others); Mon, 18 Sep 2023 11:22:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239775AbjIRPWT (ORCPT ); Mon, 18 Sep 2023 11:22:19 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14F9A2119 for ; Mon, 18 Sep 2023 08:20:09 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09397C116B1; Mon, 18 Sep 2023 13:59:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045600; bh=Elr81gt1Uwkp0uU5QSI+l9l5F4aRXahecdoJHJRnVvk=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=GmkPLi5FAHVdQxEimz33asJBxFyuOxfs+2CbCUHHXROvpyOZjjbsGLYlgghGGR+m3 ez4zQQTUq0xc5HVzcOvOVpgGXpyjv+Z2bSeSfjr+QsMzhdhULE91MxaRHA7Cs+9Y1F E+KBsFrSReSpA3OkdwRBj7GX4qg4eLRNe85OiVcWpVG/vu7Wy7nZQKZCeN7MKdq2DK yKVGV9vqh8838I3/47vYx0A8/ocfdHrk6QoY3D3CcLSWlPU9EqOrYzZ2CbUlGeBPd1 Nq42boBY5AgvK63UpJhLTopwLm7hOO4glfSOSMxnxuEkauABISUmziCwUX0EYCunV1 E4MVZlxHJK2yg== Subject: [PATCH v1 30/52] NFSD: Add nfsd4_encode_fattr4_numlinks() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:59:59 -0400 Message-ID: <169504559906.133720.8071462922786084487.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=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:22:37 -0700 (PDT) From: Chuck Lever Refactor the encoder for FATTR4_NUMLINKS 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 91f5f154428b..e3d9ec44c817 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3188,6 +3188,12 @@ static __be32 nfsd4_encode_fattr4_mode(struct xdr_stream *xdr, return nfsd4_encode_mode4(xdr, args->stat.mode & S_IALLUGO); } +static __be32 nfsd4_encode_fattr4_numlinks(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_uint32_t(xdr, args->stat.nlink); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3472,10 +3478,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_NUMLINKS) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(args.stat.nlink); + status = nfsd4_encode_fattr4_numlinks(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval1 & FATTR4_WORD1_OWNER) { status = nfsd4_encode_user(xdr, rqstp, args.stat.uid);