From patchwork Mon Sep 18 13:56:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13390037 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 72E41CD13D2 for ; Mon, 18 Sep 2023 16:25:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230075AbjIRQZp (ORCPT ); Mon, 18 Sep 2023 12:25:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230096AbjIRQZg (ORCPT ); Mon, 18 Sep 2023 12:25:36 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6356225478 for ; Mon, 18 Sep 2023 09:22:40 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BA9EC433BC; Mon, 18 Sep 2023 13:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045415; bh=i8hXbphYJz2dndu7u6xWLow0rclV/VusffseX/IlkW8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=QGlrgvmVUldLAYbJOSAyPebfLGD2zdgilvsWhBAeehKmGndJIMls+zZQTLgNybYP3 7qqG2wRHhhEZbHYWAYjWU+APuTErSDpDG4K+jLtWMMGQLSaL0Wfi6f1+xeTFCG0liq fGNf32P7nfFAikorEVjkSxPJoQt355iY9UOx8ner0/clF+D2xQhHWIZutl0Fe50tXr nsxxVjABepLeRD2PLTW/SGTcyJe0hb7kbjXY9G/lOydK/JjNzicXPg/Y1hsUWB4SnL LWRI4qmbkcoQagDKd2zhuVgzFNlXujBrUmWD3MwlFMExx4jRmOPPGvJEMwBsF17l8V sYQFQ/cmrqqDQ== Subject: [PATCH v1 01/52] NFSD: Add simple u32, u64, and bool encoders From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:56:54 -0400 Message-ID: <169504541407.133720.808437380691220899.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 The generic XDR encoders return a length or a negative errno. NFSv4 encoders want to know simply whether the encode ran out of stream buffer space. The return values for server-side encoding are either nfs_ok or nfserr_resource. So far I've found it adds a lot of duplicate code to try to use the generic XDR encoder utilities when encoding the simple data types in the NFSv4 operation encoders. Add a set of NFSv4-specific utilities that handle the basic XDR data types. These are added in xdr4.h so they might eventually be used by the callback server and pNFS driver encoders too. Signed-off-by: Chuck Lever --- fs/nfsd/xdr4.h | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 9d918a79dc16..5c3eb3691f8b 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -50,6 +50,117 @@ #define HAS_CSTATE_FLAG(c, f) ((c)->sid_flags & (f)) #define CLEAR_CSTATE_FLAG(c, f) ((c)->sid_flags &= ~(f)) +/** + * nfsd4_encode_bool - Encode an XDR bool type result + * @xdr: target XDR stream + * @val: boolean value to encode + * + * Return values: + * %nfs_ok: @val encoded; @xdr advanced to next position + * %nfserr_resource: stream buffer space exhausted + */ +static __always_inline __be32 +nfsd4_encode_bool(struct xdr_stream *xdr, bool val) +{ + __be32 *p = xdr_reserve_space(xdr, XDR_UNIT); + + if (unlikely(p == NULL)) + return nfserr_resource; + *p = val ? xdr_one : xdr_zero; + return nfs_ok; +} + +/** + * nfsd4_encode_uint32_t - Encode an XDR uint32_t type result + * @xdr: target XDR stream + * @val: integer value to encode + * + * Return values: + * %nfs_ok: @val encoded; @xdr advanced to next position + * %nfserr_resource: stream buffer space exhausted + */ +static __always_inline __be32 +nfsd4_encode_uint32_t(struct xdr_stream *xdr, u32 val) +{ + __be32 *p = xdr_reserve_space(xdr, XDR_UNIT); + + if (unlikely(p == NULL)) + return nfserr_resource; + *p = cpu_to_be32(val); + return nfs_ok; +} + +/** + * nfsd4_encode_uint64_t - Encode an XDR uint64_t type result + * @xdr: target XDR stream + * @val: integer value to encode + * + * Return values: + * %nfs_ok: @val encoded; @xdr advanced to next position + * %nfserr_resource: stream buffer space exhausted + */ +static __always_inline __be32 +nfsd4_encode_uint64_t(struct xdr_stream *xdr, u64 val) +{ + __be32 *p = xdr_reserve_space(xdr, XDR_UNIT * 2); + + if (unlikely(p == NULL)) + return nfserr_resource; + put_unaligned_be64(val, p); + return nfs_ok; +} + +/** + * nfsd4_encode_opaque_fixed - Encode a fixed-length XDR opaque type result + * @xdr: target XDR stream + * @data: pointer to data + * @size: length of data in bytes + * + * Return values: + * %nfs_ok: @data encoded; @xdr advanced to next position + * %nfserr_resource: stream buffer space exhausted + */ +static __always_inline __be32 +nfsd4_encode_opaque_fixed(struct xdr_stream *xdr, const void *data, + size_t size) +{ + __be32 *p = xdr_reserve_space(xdr, xdr_align_size(size)); + size_t pad = xdr_pad_size(size); + + if (unlikely(p == NULL)) + return nfserr_resource; + memcpy(p, data, size); + if (pad) + memset((char *)p + size, 0, pad); + return nfs_ok; +} + +/** + * nfsd4_encode_opaque - Encode a variable-length XDR opaque type result + * @xdr: target XDR stream + * @data: pointer to data + * @size: length of data in bytes + * + * Return values: + * %nfs_ok: @data encoded; @xdr advanced to next position + * %nfserr_resource: stream buffer space exhausted + */ +static __always_inline __be32 +nfsd4_encode_opaque(struct xdr_stream *xdr, const void *data, size_t size) +{ + size_t pad = xdr_pad_size(size); + __be32 *p; + + p = xdr_reserve_space(xdr, XDR_UNIT + xdr_align_size(size)); + if (unlikely(p == NULL)) + return nfserr_resource; + *p++ = cpu_to_be32(size); + memcpy(p, data, size); + if (pad) + memset((char *)p + size, 0, pad); + return nfs_ok; +} + struct nfsd4_compound_state { struct svc_fh current_fh; struct svc_fh save_fh; From patchwork Mon Sep 18 13:57:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13390040 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 580C3CD37B0 for ; Mon, 18 Sep 2023 16:27:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230111AbjIRQ1J (ORCPT ); Mon, 18 Sep 2023 12:27:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbjIRQ0u (ORCPT ); Mon, 18 Sep 2023 12:26:50 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC8BC282B4 for ; Mon, 18 Sep 2023 09:23:24 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4694C433B9; Mon, 18 Sep 2023 13:57:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045421; bh=k+6YGPIKS0IuMgfCBRoQFP48rCzx+pnWcxKtf7hp8f4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=HrJ0jriXuu0T/E+JaxTGrgp3sXyOc1igWvxIVPGpQCv1ZtZ48qI2zqRBqDpeEgOIg p5PHr0KlJLawSickuVK+ue5YhdsylYnbkAguyl2K7mFmgXnB2wJlLDZqNSk2gCelFZ o/QGtUwa8wRXr5hFdt6AxHPBKWQbEVxKd4bNJgS0qleHMxyF61lzExUGufn0EH/u1I Bq0mO2KxgGK4SL1oA7ojXdOh19ZyUKEbKT+m2u6yPNZonqOkAQvONz6ORWakijP6JL 0fdC6fX7W0GNliT4x1qPcibKCu+Xn2QC5WDtnOvF8pcTWUBLf5hXSwLcEEdsSnDWT2 rMvANJci2kI/A== Subject: [PATCH v1 02/52] NFSD: Rename nfsd4_encode_bitmap() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:57:00 -0400 Message-ID: <169504542064.133720.5075262919655124379.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 For alignment with the specification, the name of NFSD's encoder function should match the name of the XDR type. I've also replaced a few "naked integers" with symbolic constants that better reflect the usage of these values. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 2e40c74d2f72..84df0f36c15b 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2906,12 +2906,12 @@ static int nfsd4_get_mounted_on_ino(struct svc_export *exp, u64 *pino) } static __be32 -nfsd4_encode_bitmap(struct xdr_stream *xdr, u32 bmval0, u32 bmval1, u32 bmval2) +nfsd4_encode_bitmap4(struct xdr_stream *xdr, u32 bmval0, u32 bmval1, u32 bmval2) { __be32 *p; if (bmval2) { - p = xdr_reserve_space(xdr, 16); + p = xdr_reserve_space(xdr, XDR_UNIT * 4); if (!p) goto out_resource; *p++ = cpu_to_be32(3); @@ -2919,21 +2919,21 @@ nfsd4_encode_bitmap(struct xdr_stream *xdr, u32 bmval0, u32 bmval1, u32 bmval2) *p++ = cpu_to_be32(bmval1); *p++ = cpu_to_be32(bmval2); } else if (bmval1) { - p = xdr_reserve_space(xdr, 12); + p = xdr_reserve_space(xdr, XDR_UNIT * 3); if (!p) goto out_resource; *p++ = cpu_to_be32(2); *p++ = cpu_to_be32(bmval0); *p++ = cpu_to_be32(bmval1); } else { - p = xdr_reserve_space(xdr, 8); + p = xdr_reserve_space(xdr, XDR_UNIT * 2); if (!p) goto out_resource; *p++ = cpu_to_be32(1); *p++ = cpu_to_be32(bmval0); } - return 0; + return nfs_ok; out_resource: return nfserr_resource; } @@ -3046,7 +3046,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, } #endif /* CONFIG_NFSD_V4_SECURITY_LABEL */ - status = nfsd4_encode_bitmap(xdr, bmval0, bmval1, bmval2); + status = nfsd4_encode_bitmap4(xdr, bmval0, bmval1, bmval2); if (status) goto out; @@ -3443,7 +3443,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, supp[1] &= NFSD_SUPPATTR_EXCLCREAT_WORD1; supp[2] &= NFSD_SUPPATTR_EXCLCREAT_WORD2; - status = nfsd4_encode_bitmap(xdr, supp[0], supp[1], supp[2]); + status = nfsd4_encode_bitmap4(xdr, supp[0], supp[1], supp[2]); if (status) goto out; } @@ -3802,11 +3802,13 @@ nfsd4_encode_create(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_create *create = &u->create; struct xdr_stream *xdr = resp->xdr; + /* cinfo */ nfserr = nfsd4_encode_change_info4(xdr, &create->cr_cinfo); if (nfserr) return nfserr; - return nfsd4_encode_bitmap(xdr, create->cr_bmval[0], - create->cr_bmval[1], create->cr_bmval[2]); + /* attrset */ + return nfsd4_encode_bitmap4(xdr, create->cr_bmval[0], + create->cr_bmval[1], create->cr_bmval[2]); } static __be32 @@ -3944,8 +3946,8 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, if (xdr_stream_encode_u32(xdr, open->op_rflags) < 0) return nfserr_resource; - nfserr = nfsd4_encode_bitmap(xdr, open->op_bmval[0], open->op_bmval[1], - open->op_bmval[2]); + nfserr = nfsd4_encode_bitmap4(xdr, open->op_bmval[0], + open->op_bmval[1], open->op_bmval[2]); if (nfserr) return nfserr; @@ -4529,14 +4531,14 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr, break; case SP4_MACH_CRED: /* spo_must_enforce bitmap: */ - nfserr = nfsd4_encode_bitmap(xdr, + nfserr = nfsd4_encode_bitmap4(xdr, exid->spo_must_enforce[0], exid->spo_must_enforce[1], exid->spo_must_enforce[2]); if (nfserr) return nfserr; /* spo_must_allow bitmap: */ - nfserr = nfsd4_encode_bitmap(xdr, + nfserr = nfsd4_encode_bitmap4(xdr, exid->spo_must_allow[0], exid->spo_must_allow[1], exid->spo_must_allow[2]); From patchwork Mon Sep 18 13:57:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13390036 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 D7C4BC46CA1 for ; Mon, 18 Sep 2023 16:25:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230109AbjIRQZh (ORCPT ); Mon, 18 Sep 2023 12:25:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229975AbjIRQZd (ORCPT ); Mon, 18 Sep 2023 12:25:33 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 914872547C for ; Mon, 18 Sep 2023 09:22:40 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 035F5C433BA; Mon, 18 Sep 2023 13:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045428; bh=ivYlbbAmiVVZYNkuHJx1W3/ofNUn2OJQ7vClkjK6ed4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=MNUvVqK5CT7jzFctXirM01STWlsprXNaXTwz2HollLyjpnN5spA0OVyV22qs9rIDt BVKre+k/EFm9sdE+BshdjnUqcycAj6cWhUPSSHGcZtnvT5nfztef2RHVS8kQcrNqHK k1ASifW03pu+dP2F7GqZKspNyOsbPOa2qLIzj1gNjdzmi5hFfMJXjh885uZFyvtdAx XvG+mme5Qdve3QvoLlppRYVCfbClXL9c+rcWE/xHuT7G9HglQmUzy18PFF6P12dBB4 7jA7JYQcyxuJ5ucHUwcvfak+vlZ9nqGphmIjc4qeP3Lh31+ZCpGYS7uDQp6/kZwukw Wyp9UgIUo9ONQ== Subject: [PATCH v1 03/52] NFSD: Clean up nfsd4_encode_setattr() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:57:07 -0400 Message-ID: <169504542705.133720.14718638463977967182.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 De-duplicate the encoding of bitmap4 results in nfsd4_encode_setattr(). Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 84df0f36c15b..8715a43a70c4 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -4427,34 +4427,25 @@ nfsd4_encode_secinfo_no_name(struct nfsd4_compoundres *resp, __be32 nfserr, return nfsd4_do_encode_secinfo(xdr, secinfo->sin_exp); } -/* - * The SETATTR encode routine is special -- it always encodes a bitmap, - * regardless of the error status. - */ static __be32 nfsd4_encode_setattr(struct nfsd4_compoundres *resp, __be32 nfserr, union nfsd4_op_u *u) { struct nfsd4_setattr *setattr = &u->setattr; - struct xdr_stream *xdr = resp->xdr; - __be32 *p; + __be32 status; - p = xdr_reserve_space(xdr, 16); - if (!p) - return nfserr_resource; - if (nfserr) { - *p++ = cpu_to_be32(3); - *p++ = cpu_to_be32(0); - *p++ = cpu_to_be32(0); - *p++ = cpu_to_be32(0); - } - else { - *p++ = cpu_to_be32(3); - *p++ = cpu_to_be32(setattr->sa_bmval[0]); - *p++ = cpu_to_be32(setattr->sa_bmval[1]); - *p++ = cpu_to_be32(setattr->sa_bmval[2]); + switch (nfserr) { + case nfs_ok: + /* attrsset */ + status = nfsd4_encode_bitmap4(resp->xdr, setattr->sa_bmval[0], + setattr->sa_bmval[1], + setattr->sa_bmval[2]); + break; + default: + /* attrsset */ + status = nfsd4_encode_bitmap4(resp->xdr, 0, 0, 0); } - return nfserr; + return status != nfs_ok ? status : nfserr; } static __be32 From patchwork Mon Sep 18 13:57:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13390041 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 37F07C46CA1 for ; Mon, 18 Sep 2023 16:27:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229608AbjIRQ1K (ORCPT ); Mon, 18 Sep 2023 12:27:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229936AbjIRQ0u (ORCPT ); Mon, 18 Sep 2023 12:26:50 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEF32282B5 for ; Mon, 18 Sep 2023 09:23:24 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F33CC433B8; Mon, 18 Sep 2023 13:57:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045434; bh=8RjLv5ucsS4TqmmplCEXPAGLbBP2aoz/zfsx1GrO6T0=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=GykiXUoywDNxgXd2ebxQUiKvFNaNflvFLONCynpDWKaQRW9w/VcxSdgaHS+eu1Gss NruRe2AkbSemMX7Fqew71KHobqlowMRpTq7K0sDidzaht/QS5M0iL04Rt9q88GRtwq FPdROiMmQWgX6JVmKpa9cAkkZQzEixQJO/a5ONCR+xMUAAB3jA258LzU3moUujktNf IGDGcSOUsowLHIg9eEgaKo82fKav2rhbBTtzLqwX4KyterEjsGg3mVbJEeeRjWyLGA NNUYwGaJGMd/6p6pK/vxM41Yl6V8im+JHguwpJbila8iBggdD0CuNpeldUiIbRP0/z 8FuVfZt67RPDg== Subject: [PATCH v1 04/52] NFSD: Add struct nfsd4_fattr_args From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:57:13 -0400 Message-ID: <169504543339.133720.8022594504714835325.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 I'm about to split nfsd4_encode_fattr() into a number of smaller functions. Instead of passing a large number of arguments to each of the smaller functions, create a struct that can gather the common argument variables into something with a convenient handle on it. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 111 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 62 insertions(+), 49 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 8715a43a70c4..85466b959c51 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2938,6 +2938,15 @@ nfsd4_encode_bitmap4(struct xdr_stream *xdr, u32 bmval0, u32 bmval1, u32 bmval2) return nfserr_resource; } +struct nfsd4_fattr_args { + struct svc_fh *fhp; + struct kstat stat; + struct kstatfs statfs; + struct nfs4_acl *acl; + u32 rdattr_err; + bool contextsupport; +}; + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -2948,26 +2957,22 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, struct dentry *dentry, u32 *bmval, struct svc_rqst *rqstp, int ignore_crossmnt) { + struct nfsd4_fattr_args args; u32 bmval0 = bmval[0]; u32 bmval1 = bmval[1]; u32 bmval2 = bmval[2]; - struct kstat stat; struct svc_fh *tempfh = NULL; - struct kstatfs statfs; __be32 *p, *attrlen_p; int starting_len = xdr->buf->len; int attrlen_offset; u32 dummy; u64 dummy64; - u32 rdattr_err = 0; __be32 status; int err; - struct nfs4_acl *acl = NULL; #ifdef CONFIG_NFSD_V4_SECURITY_LABEL void *context = NULL; int contextlen; #endif - bool contextsupport = false; struct nfsd4_compoundres *resp = rqstp->rq_resp; u32 minorversion = resp->cstate.minorversion; struct path path = { @@ -2979,8 +2984,10 @@ 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.rdattr_err = 0; if (exp->ex_fslocs.migrated) { - status = fattr_handle_absent_fs(&bmval0, &bmval1, &bmval2, &rdattr_err); + status = fattr_handle_absent_fs(&bmval0, &bmval1, &bmval2, + &args.rdattr_err); if (status) goto out; } @@ -2990,19 +2997,20 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } - err = vfs_getattr(&path, &stat, + err = vfs_getattr(&path, &args.stat, STATX_BASIC_STATS | STATX_BTIME | STATX_CHANGE_COOKIE, AT_STATX_SYNC_AS_STAT); if (err) goto out_nfserr; - if (!(stat.result_mask & STATX_BTIME)) + + if (!(args.stat.result_mask & STATX_BTIME)) /* underlying FS does not offer btime so we can't share it */ bmval1 &= ~FATTR4_WORD1_TIME_CREATE; if ((bmval0 & (FATTR4_WORD0_FILES_AVAIL | FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_MAXNAME)) || (bmval1 & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE | FATTR4_WORD1_SPACE_TOTAL))) { - err = vfs_statfs(&path, &statfs); + err = vfs_statfs(&path, &args.statfs); if (err) goto out_nfserr; } @@ -3015,10 +3023,13 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, status = fh_compose(tempfh, exp, dentry, NULL); if (status) goto out; - fhp = tempfh; - } + args.fhp = tempfh; + } else + args.fhp = fhp; + + args.acl = NULL; if (bmval0 & FATTR4_WORD0_ACL) { - err = nfsd4_get_nfs4_acl(rqstp, dentry, &acl); + err = nfsd4_get_nfs4_acl(rqstp, dentry, &args.acl); if (err == -EOPNOTSUPP) bmval0 &= ~FATTR4_WORD0_ACL; else if (err == -EINVAL) { @@ -3028,6 +3039,8 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out_nfserr; } + args.contextsupport = false; + #ifdef CONFIG_NFSD_V4_SECURITY_LABEL if ((bmval2 & FATTR4_WORD2_SECURITY_LABEL) || bmval0 & FATTR4_WORD0_SUPPORTED_ATTRS) { @@ -3036,7 +3049,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, &context, &contextlen); else err = -EOPNOTSUPP; - contextsupport = (err == 0); + args.contextsupport = (err == 0); if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) { if (err == -EOPNOTSUPP) bmval2 &= ~FATTR4_WORD2_SECURITY_LABEL; @@ -3062,7 +3075,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, if (!IS_POSIXACL(dentry->d_inode)) supp[0] &= ~FATTR4_WORD0_ACL; - if (!contextsupport) + if (!args.contextsupport) supp[2] &= ~FATTR4_WORD2_SECURITY_LABEL; if (!supp[2]) { p = xdr_reserve_space(xdr, 12); @@ -3085,7 +3098,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, p = xdr_reserve_space(xdr, 4); if (!p) goto out_resource; - dummy = nfs4_file_type(stat.mode); + dummy = nfs4_file_type(args.stat.mode); if (dummy == NF4BAD) { status = nfserr_serverfault; goto out; @@ -3106,13 +3119,13 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, p = xdr_reserve_space(xdr, 8); if (!p) goto out_resource; - p = encode_change(p, &stat, d_inode(dentry), exp); + p = encode_change(p, &args.stat, d_inode(dentry), exp); } if (bmval0 & FATTR4_WORD0_SIZE) { p = xdr_reserve_space(xdr, 8); if (!p) goto out_resource; - p = xdr_encode_hyper(p, stat.size); + p = xdr_encode_hyper(p, args.stat.size); } if (bmval0 & FATTR4_WORD0_LINK_SUPPORT) { p = xdr_reserve_space(xdr, 4); @@ -3139,16 +3152,16 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, if (exp->ex_fslocs.migrated) { p = xdr_encode_hyper(p, NFS4_REFERRAL_FSID_MAJOR); p = xdr_encode_hyper(p, NFS4_REFERRAL_FSID_MINOR); - } else switch(fsid_source(fhp)) { + } else switch (fsid_source(args.fhp)) { case FSIDSOURCE_FSID: p = xdr_encode_hyper(p, (u64)exp->ex_fsid); p = xdr_encode_hyper(p, (u64)0); break; case FSIDSOURCE_DEV: *p++ = cpu_to_be32(0); - *p++ = cpu_to_be32(MAJOR(stat.dev)); + *p++ = cpu_to_be32(MAJOR(args.stat.dev)); *p++ = cpu_to_be32(0); - *p++ = cpu_to_be32(MINOR(stat.dev)); + *p++ = cpu_to_be32(MINOR(args.stat.dev)); break; case FSIDSOURCE_UUID: p = xdr_encode_opaque_fixed(p, exp->ex_uuid, @@ -3172,12 +3185,12 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, p = xdr_reserve_space(xdr, 4); if (!p) goto out_resource; - *p++ = cpu_to_be32(rdattr_err); + *p++ = cpu_to_be32(args.rdattr_err); } if (bmval0 & FATTR4_WORD0_ACL) { struct nfs4_ace *ace; - if (acl == NULL) { + if (args.acl == NULL) { p = xdr_reserve_space(xdr, 4); if (!p) goto out_resource; @@ -3188,9 +3201,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, p = xdr_reserve_space(xdr, 4); if (!p) goto out_resource; - *p++ = cpu_to_be32(acl->naces); + *p++ = cpu_to_be32(args.acl->naces); - for (ace = acl->aces; ace < acl->aces + acl->naces; ace++) { + for (ace = args.acl->aces; ace < args.acl->aces + args.acl->naces; ace++) { p = xdr_reserve_space(xdr, 4*3); if (!p) goto out_resource; @@ -3236,35 +3249,35 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, *p++ = cpu_to_be32(1); } if (bmval0 & FATTR4_WORD0_FILEHANDLE) { - p = xdr_reserve_space(xdr, fhp->fh_handle.fh_size + 4); + p = xdr_reserve_space(xdr, args.fhp->fh_handle.fh_size + 4); if (!p) goto out_resource; - p = xdr_encode_opaque(p, &fhp->fh_handle.fh_raw, - fhp->fh_handle.fh_size); + p = xdr_encode_opaque(p, &args.fhp->fh_handle.fh_raw, + args.fhp->fh_handle.fh_size); } if (bmval0 & FATTR4_WORD0_FILEID) { p = xdr_reserve_space(xdr, 8); if (!p) goto out_resource; - p = xdr_encode_hyper(p, stat.ino); + p = xdr_encode_hyper(p, args.stat.ino); } if (bmval0 & FATTR4_WORD0_FILES_AVAIL) { p = xdr_reserve_space(xdr, 8); if (!p) goto out_resource; - p = xdr_encode_hyper(p, (u64) statfs.f_ffree); + p = xdr_encode_hyper(p, (u64) args.statfs.f_ffree); } if (bmval0 & FATTR4_WORD0_FILES_FREE) { p = xdr_reserve_space(xdr, 8); if (!p) goto out_resource; - p = xdr_encode_hyper(p, (u64) statfs.f_ffree); + p = xdr_encode_hyper(p, (u64) args.statfs.f_ffree); } if (bmval0 & FATTR4_WORD0_FILES_TOTAL) { p = xdr_reserve_space(xdr, 8); if (!p) goto out_resource; - p = xdr_encode_hyper(p, (u64) statfs.f_files); + p = xdr_encode_hyper(p, (u64) args.statfs.f_files); } if (bmval0 & FATTR4_WORD0_FS_LOCATIONS) { status = nfsd4_encode_fs_locations(xdr, rqstp, exp); @@ -3293,7 +3306,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, p = xdr_reserve_space(xdr, 4); if (!p) goto out_resource; - *p++ = cpu_to_be32(statfs.f_namelen); + *p++ = cpu_to_be32(args.statfs.f_namelen); } if (bmval0 & FATTR4_WORD0_MAXREAD) { p = xdr_reserve_space(xdr, 8); @@ -3311,7 +3324,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, p = xdr_reserve_space(xdr, 4); if (!p) goto out_resource; - *p++ = cpu_to_be32(stat.mode & S_IALLUGO); + *p++ = cpu_to_be32(args.stat.mode & S_IALLUGO); } if (bmval1 & FATTR4_WORD1_NO_TRUNC) { p = xdr_reserve_space(xdr, 4); @@ -3323,15 +3336,15 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, p = xdr_reserve_space(xdr, 4); if (!p) goto out_resource; - *p++ = cpu_to_be32(stat.nlink); + *p++ = cpu_to_be32(args.stat.nlink); } if (bmval1 & FATTR4_WORD1_OWNER) { - status = nfsd4_encode_user(xdr, rqstp, stat.uid); + status = nfsd4_encode_user(xdr, rqstp, args.stat.uid); if (status) goto out; } if (bmval1 & FATTR4_WORD1_OWNER_GROUP) { - status = nfsd4_encode_group(xdr, rqstp, stat.gid); + status = nfsd4_encode_group(xdr, rqstp, args.stat.gid); if (status) goto out; } @@ -3339,44 +3352,44 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, p = xdr_reserve_space(xdr, 8); if (!p) goto out_resource; - *p++ = cpu_to_be32((u32) MAJOR(stat.rdev)); - *p++ = cpu_to_be32((u32) MINOR(stat.rdev)); + *p++ = cpu_to_be32((u32) MAJOR(args.stat.rdev)); + *p++ = cpu_to_be32((u32) MINOR(args.stat.rdev)); } if (bmval1 & FATTR4_WORD1_SPACE_AVAIL) { p = xdr_reserve_space(xdr, 8); if (!p) goto out_resource; - dummy64 = (u64)statfs.f_bavail * (u64)statfs.f_bsize; + dummy64 = (u64)args.statfs.f_bavail * (u64)args.statfs.f_bsize; p = xdr_encode_hyper(p, dummy64); } if (bmval1 & FATTR4_WORD1_SPACE_FREE) { p = xdr_reserve_space(xdr, 8); if (!p) goto out_resource; - dummy64 = (u64)statfs.f_bfree * (u64)statfs.f_bsize; + dummy64 = (u64)args.statfs.f_bfree * (u64)args.statfs.f_bsize; p = xdr_encode_hyper(p, dummy64); } if (bmval1 & FATTR4_WORD1_SPACE_TOTAL) { p = xdr_reserve_space(xdr, 8); if (!p) goto out_resource; - dummy64 = (u64)statfs.f_blocks * (u64)statfs.f_bsize; + dummy64 = (u64)args.statfs.f_blocks * (u64)args.statfs.f_bsize; p = xdr_encode_hyper(p, dummy64); } if (bmval1 & FATTR4_WORD1_SPACE_USED) { p = xdr_reserve_space(xdr, 8); if (!p) goto out_resource; - dummy64 = (u64)stat.blocks << 9; + dummy64 = (u64)args.stat.blocks << 9; p = xdr_encode_hyper(p, dummy64); } if (bmval1 & FATTR4_WORD1_TIME_ACCESS) { - status = nfsd4_encode_nfstime4(xdr, &stat.atime); + status = nfsd4_encode_nfstime4(xdr, &args.stat.atime); if (status) goto out; } if (bmval1 & FATTR4_WORD1_TIME_CREATE) { - status = nfsd4_encode_nfstime4(xdr, &stat.btime); + status = nfsd4_encode_nfstime4(xdr, &args.stat.btime); if (status) goto out; } @@ -3387,17 +3400,17 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, p = encode_time_delta(p, d_inode(dentry)); } if (bmval1 & FATTR4_WORD1_TIME_METADATA) { - status = nfsd4_encode_nfstime4(xdr, &stat.ctime); + status = nfsd4_encode_nfstime4(xdr, &args.stat.ctime); if (status) goto out; } if (bmval1 & FATTR4_WORD1_TIME_MODIFY) { - status = nfsd4_encode_nfstime4(xdr, &stat.mtime); + status = nfsd4_encode_nfstime4(xdr, &args.stat.mtime); if (status) goto out; } if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) { - u64 ino = stat.ino; + u64 ino = args.stat.ino; p = xdr_reserve_space(xdr, 8); if (!p) @@ -3432,7 +3445,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, p = xdr_reserve_space(xdr, 4); if (!p) goto out_resource; - *p++ = cpu_to_be32(stat.blksize); + *p++ = cpu_to_be32(args.stat.blksize); } #endif /* CONFIG_NFSD_PNFS */ if (bmval2 & FATTR4_WORD2_SUPPATTR_EXCLCREAT) { @@ -3473,7 +3486,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, if (context) security_release_secctx(context, contextlen); #endif /* CONFIG_NFSD_V4_SECURITY_LABEL */ - kfree(acl); + kfree(args.acl); if (tempfh) { fh_put(tempfh); kfree(tempfh); From patchwork Mon Sep 18 13:57:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13390038 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 ADB4BCD37B0 for ; Mon, 18 Sep 2023 16:25:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230116AbjIRQZx (ORCPT ); Mon, 18 Sep 2023 12:25:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229736AbjIRQZh (ORCPT ); Mon, 18 Sep 2023 12:25:37 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E47925AC0 for ; Mon, 18 Sep 2023 09:22:41 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D664CC433BD; Mon, 18 Sep 2023 13:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045441; bh=R55ntVJtfkDGm/0y9Z3qEMOVfy5bp/uRB+n3N+bC5Zg=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ixXEchfWn1Mq+ThHK16YFXR/5ak3yQwZ2o0xA683i2RKghUn/hvud8m271WvnV6/G YX9D3jTFM/ZJ9zIu3nxfD3HvrCF/wCgs6FdWFoJOXdXgGGgfVmRB0hn/LKxWOu+8XU 68pXgR7BqgKHIezpo//Fzwz7om1cqnerC5qUiWLDbBqCPkB/omwVypULfiu6XnBOrm 3jK906n3cF75ORl8TG+zJuuxCdp2k+71dYGXJf1VpGL4WuER/luOvuHhxI7Mr3ad89 VOEjyTPjyZ2/PQCaopdovTk/q3LhTR5dxreWQBaLzUPwueaNCeee6irsNRIKeL3TTe L4UoAghAg67aA== Subject: [PATCH v1 05/52] NFSD: Add nfsd4_encode_fattr4__true() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:57:19 -0400 Message-ID: <169504543984.133720.6869405794264080605.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 Add an encoding helper that encodes a single boolean "true" value. Attributes that always return "true" can use this helper. In a subsequent patch, this helper will be called from a bitmask loop, so it is given a standardized synopsis. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 55 ++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 85466b959c51..ba07e97c206b 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2947,6 +2947,12 @@ struct nfsd4_fattr_args { bool contextsupport; }; +static __be32 nfsd4_encode_fattr4__true(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_bool(xdr, true); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3128,16 +3134,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, p = xdr_encode_hyper(p, args.stat.size); } if (bmval0 & FATTR4_WORD0_LINK_SUPPORT) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(1); + status = nfsd4_encode_fattr4__true(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_SYMLINK_SUPPORT) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(1); + status = nfsd4_encode_fattr4__true(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_NAMED_ATTR) { p = xdr_reserve_space(xdr, 4); @@ -3225,10 +3229,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL : 0); } if (bmval0 & FATTR4_WORD0_CANSETTIME) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(1); + status = nfsd4_encode_fattr4__true(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_CASE_INSENSITIVE) { p = xdr_reserve_space(xdr, 4); @@ -3237,16 +3240,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, *p++ = cpu_to_be32(0); } if (bmval0 & FATTR4_WORD0_CASE_PRESERVING) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(1); + status = nfsd4_encode_fattr4__true(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_CHOWN_RESTRICTED) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(1); + status = nfsd4_encode_fattr4__true(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_FILEHANDLE) { p = xdr_reserve_space(xdr, args.fhp->fh_handle.fh_size + 4); @@ -3285,10 +3286,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_HOMOGENEOUS) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(1); + status = nfsd4_encode_fattr4__true(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_MAXFILESIZE) { p = xdr_reserve_space(xdr, 8); @@ -3327,10 +3327,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, *p++ = cpu_to_be32(args.stat.mode & S_IALLUGO); } if (bmval1 & FATTR4_WORD1_NO_TRUNC) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(1); + status = nfsd4_encode_fattr4__true(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval1 & FATTR4_WORD1_NUMLINKS) { p = xdr_reserve_space(xdr, 4); From patchwork Mon Sep 18 13:57:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13390035 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 CD0AECD37B0 for ; Mon, 18 Sep 2023 16:25:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229883AbjIRQZc (ORCPT ); Mon, 18 Sep 2023 12:25:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjIRQZa (ORCPT ); Mon, 18 Sep 2023 12:25:30 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1D2D25472 for ; Mon, 18 Sep 2023 09:22:39 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 488E3C433BF; Mon, 18 Sep 2023 13:57:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045447; bh=v8DyjZTKSK3Gu6mjjkXee8n4kS1b+G9Nl6vaA0VYFuk=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=cw0NONqSNuy5DmJC0E020Yh8el8daHlwV5Z04cKcQOd/oMlSH07sdhUs0iFpVthQs sNVXBLlipIrTstCa2z9SfTcPolDRTX8gWb5Fv2I0Mfh5+aIoL/wByB5cpSIXjTt5hQ dJUQ1XIsBGf4vItsU6BURpTGGl0LdpleizESa230J6QP3FQKCxOvJ8nelne1hmfKbz UUGnxe+nqNxlOaRvgwO+vwBwHlOxV31AwL6ieJ1XOpj5wCmvQPpluLpFneRranXaoE QYb7mq6X2IgjxTzilmBcRftALS/8p/2LtLVbwtc9Iifqzzhm3M4DGgZWsEOf5Li1Hy m+p45puf6lelA== Subject: [PATCH v1 06/52] NFSD: Add nfsd4_encode_fattr4__false() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:57:26 -0400 Message-ID: <169504544625.133720.5531415222277888990.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 Add an encoding helper that encodes a single boolean "false" value. Attributes that always return "false" can use this helper. In a subsequent patch, this helper will be called from a bitmask loop, so it is given a standardized synopsis. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index ba07e97c206b..91f3b03f297b 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2953,6 +2953,12 @@ static __be32 nfsd4_encode_fattr4__true(struct xdr_stream *xdr, return nfsd4_encode_bool(xdr, true); } +static __be32 nfsd4_encode_fattr4__false(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_bool(xdr, false); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3144,10 +3150,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_NAMED_ATTR) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(0); + status = nfsd4_encode_fattr4__false(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_FSID) { p = xdr_reserve_space(xdr, 16); @@ -3174,10 +3179,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, } } if (bmval0 & FATTR4_WORD0_UNIQUE_HANDLES) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(0); + status = nfsd4_encode_fattr4__false(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_LEASE_TIME) { p = xdr_reserve_space(xdr, 4); @@ -3234,10 +3238,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_CASE_INSENSITIVE) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(0); + status = nfsd4_encode_fattr4__false(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_CASE_PRESERVING) { status = nfsd4_encode_fattr4__true(xdr, &args); From patchwork Mon Sep 18 13:57:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389815 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 19902C46CA1 for ; Mon, 18 Sep 2023 15:23:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240708AbjIRPYA (ORCPT ); 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 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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); From patchwork Mon Sep 18 13:57:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13390107 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 69686C46CA1 for ; Mon, 18 Sep 2023 16:46:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230520AbjIRQqI (ORCPT ); Mon, 18 Sep 2023 12:46:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231126AbjIRQp4 (ORCPT ); Mon, 18 Sep 2023 12:45:56 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA7F02D49 for ; Mon, 18 Sep 2023 09:37:37 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0FFAC4163D; Mon, 18 Sep 2023 13:57:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045460; bh=qx9Amc4/EpzHEUVIFiDXrdm8bUDFLkxqj4++LgT6vLI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=qFM3zQSJYzUIdbtOgrMYzJ/oEITRolLjcysEdEDSSy2e/OR16p4/XpApmwiH5F9tu bvlKq442EwtcBnPsdGE4nf9uJNhHnVMOYsnd2jl4pe4JcnF8edd4vz/38G7Bze9KSO lWodNVS8UWqLKRtS0Mf6H0IBwpYSXdnbN+L4D/hbcv97pGeZScOMeNwmOGGTjB+0qh TXRrrklgRmUM2t310LsP/ycDrkBFgR/YTOQnNHCCtHIFv36b/4EM5cRAE28XEfqKiQ HLHoSulH3LcKcs17CNjVZWULeYRe851GSKAlsEX2x5r6xyWTFc0c1ZlmTlE7wPude3 VpN0nXvaVVJcA== Subject: [PATCH v1 08/52] NFSD: Add nfsd4_encode_fattr4_type() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:57:39 -0400 Message-ID: <169504545905.133720.14224781242740113631.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_TYPE into a helper. In a subsequent patch, this helper will be called from a bitmask loop. In addition, restructure the code so that byte-swapping is done on constant values rather than at run time. Run-time swapping can be costly on some platforms, and "type" is a frequently-requested attribute. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 63 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index da5df33cac04..c1dc6810f043 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2792,20 +2792,6 @@ static __be32 nfsd4_encode_fs_locations(struct xdr_stream *xdr, return 0; } -static u32 nfs4_file_type(umode_t mode) -{ - switch (mode & S_IFMT) { - case S_IFIFO: return NF4FIFO; - case S_IFCHR: return NF4CHR; - case S_IFDIR: return NF4DIR; - case S_IFBLK: return NF4BLK; - case S_IFLNK: return NF4LNK; - case S_IFREG: return NF4REG; - case S_IFSOCK: return NF4SOCK; - default: return NF4BAD; - } -} - static inline __be32 nfsd4_encode_aclname(struct xdr_stream *xdr, struct svc_rqst *rqstp, struct nfs4_ace *ace) @@ -2977,6 +2963,44 @@ static __be32 nfsd4_encode_fattr4_supported_attrs(struct xdr_stream *xdr, return nfsd4_encode_bitmap4(xdr, supp[0], supp[1], supp[2]); } +static __be32 nfsd4_encode_fattr4_type(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + __be32 *p; + + p = xdr_reserve_space(xdr, XDR_UNIT); + if (!p) + return nfserr_resource; + + switch (args->stat.mode & S_IFMT) { + case S_IFIFO: + *p = cpu_to_be32(NF4FIFO); + break; + case S_IFCHR: + *p = cpu_to_be32(NF4CHR); + break; + case S_IFDIR: + *p = cpu_to_be32(NF4DIR); + break; + case S_IFBLK: + *p = cpu_to_be32(NF4BLK); + break; + case S_IFLNK: + *p = cpu_to_be32(NF4LNK); + break; + case S_IFREG: + *p = cpu_to_be32(NF4REG); + break; + case S_IFSOCK: + *p = cpu_to_be32(NF4SOCK); + break; + default: + return nfserr_serverfault; + } + + return nfs_ok; +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -2995,7 +3019,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; - u32 dummy; u64 dummy64; __be32 status; int err; @@ -3107,15 +3130,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_TYPE) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - dummy = nfs4_file_type(args.stat.mode); - if (dummy == NF4BAD) { - status = nfserr_serverfault; + status = nfsd4_encode_fattr4_type(xdr, &args); + if (status != nfs_ok) goto out; - } - *p++ = cpu_to_be32(dummy); } if (bmval0 & FATTR4_WORD0_FH_EXPIRE_TYPE) { p = xdr_reserve_space(xdr, 4); From patchwork Mon Sep 18 13:57:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389792 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 E0131CD37B0 for ; Mon, 18 Sep 2023 15:18:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232269AbjIRPSu (ORCPT ); Mon, 18 Sep 2023 11:18:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232575AbjIRPSt (ORCPT ); Mon, 18 Sep 2023 11:18:49 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF1861A6 for ; Mon, 18 Sep 2023 08:17:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C553C43140; Mon, 18 Sep 2023 13:57:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045466; bh=yTYFgeQLf6mn8Ofiq0L4auswDUEn+UMSP1VMECXDKIU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=eW2Wkc/HbbuhsnU5dis/7ojANlfMU+tSkEGDWLUDl1wJVb3jsI4+FjIQtuZVSjOZd oTxujHzgQAbPwZRfDx3gyVLh1zV3I3TtmCQNy0m4zYhEDGmerPSCgpIZNLyH0PWb3m jO1R7RZLquA31Z9cbQmXtAggJLr6vZuhP0wl0pZo1wJ56nODZxwp9JfDGCFuVuFk/8 IWjBFfm0S6qYOBLwiCfyDxLtH+D/Ode6AshGN7J1bjeubBvBIA7O6ZXoKkwy2ahGhq uQ+VCAzgUix4BO+WV4ja71HRHhoU91y/ls6+/F6g27aHM/jw3bOjGe+8xX1BTauj6k x6oPWILSqO3wQ== Subject: [PATCH v1 09/52] NFSD: Add nfsd4_encode_fattr4_fh_expire_type() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:57:45 -0400 Message-ID: <169504546537.133720.11707175189232518946.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_FH_EXPIRE_TYPE 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 | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index c1dc6810f043..e7f1a856fb0b 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2927,6 +2927,7 @@ 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 svc_export *exp; struct dentry *dentry; struct kstat stat; struct kstatfs statfs; @@ -3001,6 +3002,17 @@ static __be32 nfsd4_encode_fattr4_type(struct xdr_stream *xdr, return nfs_ok; } +static __be32 nfsd4_encode_fattr4_fh_expire_type(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + u32 mask; + + mask = NFS4_FH_PERSISTENT; + if (!(args->exp->ex_flags & NFSEXP_NOSUBTREECHECK)) + mask |= NFS4_FH_VOL_RENAME; + return nfsd4_encode_uint32_t(xdr, mask); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3038,6 +3050,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, BUG_ON(!nfsd_attrs_supported(minorversion, bmval)); args.rqstp = rqstp; + args.exp = exp; args.dentry = dentry; args.rdattr_err = 0; @@ -3135,14 +3148,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_FH_EXPIRE_TYPE) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) - *p++ = cpu_to_be32(NFS4_FH_PERSISTENT); - else - *p++ = cpu_to_be32(NFS4_FH_PERSISTENT| - NFS4_FH_VOL_RENAME); + status = nfsd4_encode_fattr4_fh_expire_type(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_CHANGE) { p = xdr_reserve_space(xdr, 8); From patchwork Mon Sep 18 13:57:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389844 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 308F9C46CA1 for ; Mon, 18 Sep 2023 15:30:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229485AbjIRPah (ORCPT ); Mon, 18 Sep 2023 11:30:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229627AbjIRPae (ORCPT ); Mon, 18 Sep 2023 11:30:34 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80F23121 for ; Mon, 18 Sep 2023 08:28:39 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB35BC43215; Mon, 18 Sep 2023 13:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045472; bh=eXTZv14LOOiCHZd9ksCmHuQpOJzqOBb+PiU1sl4vLWU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=KJwUrL4GSNobr3CYUDf4IH8dk/uMPO/i2uHlrOMarNrkTQu7iTSK46k8iYiK3+QtT X8nl2qoQsO/rWYAHsSCRfo/GnYB1tnLPlbLhrgprmD/Z3zVtaNrYlnie7x5gIVSNae TgIXRU9UtiIeZHabcwLbTzTBuQa8O1uMKCQ5yMbfRT9jd3tABbOls2IJ4QD9mawPCa To0Qy3ZVnQELJy6ofka9DeEPZlcQaMfkZ5/I2gbln6LDzJ/UxG1304s1+1h7FTUYhL rLkvjX+ujQTnY+vgaP0/Cwe/mDP0Rb8nY1u0oXdXYe/tG/laRJZprvjDe848cmhOnF Wzz79YftBWm5A== Subject: [PATCH v1 10/52] NFSD: Add nfsd4_encode_fattr4_change() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:57:51 -0400 Message-ID: <169504547175.133720.14191467995288731906.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_CHANGE into a helper. In a subsequent patch, this helper will be called from a bitmask loop. The code is restructured a bit to use the modern xdr_stream flow, and the encoded cinfo value is made const so that callers of the encoders can be passed a const cinfo. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 56 +++++++++++++++++++++++++++------------------- fs/nfsd/nfsfh.c | 2 +- fs/nfsd/nfsfh.h | 3 ++ fs/nfsd/xdr4.h | 2 ++ include/linux/iversion.h | 2 +- 5 files changed, 39 insertions(+), 26 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index e7f1a856fb0b..3149cfcdac35 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2530,17 +2530,6 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) return true; } -static __be32 *encode_change(__be32 *p, struct kstat *stat, struct inode *inode, - struct svc_export *exp) -{ - if (exp->ex_flags & NFSEXP_V4ROOT) { - *p++ = cpu_to_be32(convert_to_wallclock(exp->cd->flush_time)); - *p++ = 0; - } else - p = xdr_encode_hyper(p, nfsd4_change_attribute(stat, inode)); - return p; -} - static __be32 nfsd4_encode_nfstime4(struct xdr_stream *xdr, struct timespec64 *tv) { @@ -2581,15 +2570,17 @@ static __be32 *encode_time_delta(__be32 *p, struct inode *inode) } static __be32 -nfsd4_encode_change_info4(struct xdr_stream *xdr, struct nfsd4_change_info *c) +nfsd4_encode_change_info4(struct xdr_stream *xdr, const struct nfsd4_change_info *c) { - if (xdr_stream_encode_bool(xdr, c->atomic) < 0) - return nfserr_resource; - if (xdr_stream_encode_u64(xdr, c->before_change) < 0) - return nfserr_resource; - if (xdr_stream_encode_u64(xdr, c->after_change) < 0) - return nfserr_resource; - return nfs_ok; + __be32 status; + + status = nfsd4_encode_bool(xdr, c->atomic); + if (status != nfs_ok) + return status; + status = nfsd4_encode_changeid4(xdr, c->before_change); + if (status != nfs_ok) + return status; + return nfsd4_encode_changeid4(xdr, c->after_change); } /* Encode as an array of strings the string given with components @@ -3013,6 +3004,26 @@ static __be32 nfsd4_encode_fattr4_fh_expire_type(struct xdr_stream *xdr, return nfsd4_encode_uint32_t(xdr, mask); } +static __be32 nfsd4_encode_fattr4_change(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + const struct svc_export *exp = args->exp; + u64 c; + + if (unlikely(exp->ex_flags & NFSEXP_V4ROOT)) { + u32 flush_time = convert_to_wallclock(exp->cd->flush_time); + + if (xdr_stream_encode_u32(xdr, flush_time) != XDR_UNIT) + return nfserr_resource; + if (xdr_stream_encode_u32(xdr, 0) != XDR_UNIT) + return nfserr_resource; + return nfs_ok; + } + + c = nfsd4_change_attribute(&args->stat, d_inode(args->dentry)); + return nfsd4_encode_changeid4(xdr, c); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3153,10 +3164,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_CHANGE) { - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - p = encode_change(p, &args.stat, d_inode(dentry), exp); + status = nfsd4_encode_fattr4_change(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_SIZE) { p = xdr_reserve_space(xdr, 8); diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index 355bf0db3235..dbfa0ac13564 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c @@ -771,7 +771,7 @@ enum fsid_source fsid_source(const struct svc_fh *fhp) * assume that the new change attr is always logged to stable storage in some * fashion before the results can be seen. */ -u64 nfsd4_change_attribute(struct kstat *stat, struct inode *inode) +u64 nfsd4_change_attribute(const struct kstat *stat, const struct inode *inode) { u64 chattr; diff --git a/fs/nfsd/nfsfh.h b/fs/nfsd/nfsfh.h index 40426f899e76..6ebdf7ea27bf 100644 --- a/fs/nfsd/nfsfh.h +++ b/fs/nfsd/nfsfh.h @@ -293,7 +293,8 @@ static inline void fh_clear_pre_post_attrs(struct svc_fh *fhp) fhp->fh_pre_saved = false; } -u64 nfsd4_change_attribute(struct kstat *stat, struct inode *inode); +u64 nfsd4_change_attribute(const struct kstat *stat, + const struct inode *inode); __be32 __must_check fh_fill_pre_attrs(struct svc_fh *fhp); __be32 fh_fill_post_attrs(struct svc_fh *fhp); __be32 __must_check fh_fill_both_attrs(struct svc_fh *fhp); diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 5c3eb3691f8b..d6059b0549f5 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -110,6 +110,8 @@ nfsd4_encode_uint64_t(struct xdr_stream *xdr, u64 val) return nfs_ok; } +#define nfsd4_encode_changeid4(x, v) nfsd4_encode_uint64_t(x, v) + /** * nfsd4_encode_opaque_fixed - Encode a fixed-length XDR opaque type result * @xdr: target XDR stream diff --git a/include/linux/iversion.h b/include/linux/iversion.h index f174ff1b59ee..8f972eaca2ed 100644 --- a/include/linux/iversion.h +++ b/include/linux/iversion.h @@ -256,7 +256,7 @@ inode_peek_iversion(const struct inode *inode) * For filesystems without any sort of change attribute, the best we can * do is fake one up from the ctime: */ -static inline u64 time_to_chattr(struct timespec64 *t) +static inline u64 time_to_chattr(const struct timespec64 *t) { u64 chattr = t->tv_sec; From patchwork Mon Sep 18 13:57:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13390071 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 47974CD37B0 for ; Mon, 18 Sep 2023 16:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229862AbjIRQhR (ORCPT ); Mon, 18 Sep 2023 12:37:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230006AbjIRQhG (ORCPT ); Mon, 18 Sep 2023 12:37:06 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3157171C for ; Mon, 18 Sep 2023 09:32:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 221B8C4166B; Mon, 18 Sep 2023 13:57:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045479; bh=KHpYt6z3tDgpzHy2k6y8Y5rZ4ZCZLSs4BRcrSAwGlkc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=EV0fF/v3jF+1DbB3Vs3UR40t/KIVW1IUytGrebEaBjjunleXLM8MbsbSoYXEl5Jug /P/3M0Y2IyGBKXTPKtiiTfDRlX9qeri2gRq4GkD+SVRPBhsITNCPOcD69G2tdfBZue BxE0LfBSTPaUUKAY+DWOpbWvVMACXXrbdtYiisGC+WJeQv4DFyG8p+xPQ3kuaL8Lzd +jcuCKgKToF4k+ssvu3jPzNVC1FvWJp6Qs+Uryxx8vitNBL917oh2UA3Jjrh2Y39cH nQRjbov0maclfk31O8L1IHOd3r8wXltOMkcJaXHW6AzXODMUV4Rau6gk2i9+dfOZXz aKy8/FQF2YMqQ== Subject: [PATCH v1 11/52] NFSD: Add nfsd4_encode_fattr4_size() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:57:58 -0400 Message-ID: <169504547814.133720.4907073026998034966.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_SIZE 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 3149cfcdac35..601b3a0e61d4 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3024,6 +3024,12 @@ static __be32 nfsd4_encode_fattr4_change(struct xdr_stream *xdr, return nfsd4_encode_changeid4(xdr, c); } +static __be32 nfsd4_encode_fattr4_size(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_uint64_t(xdr, args->stat.size); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3169,10 +3175,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_SIZE) { - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - p = xdr_encode_hyper(p, args.stat.size); + status = nfsd4_encode_fattr4_size(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_LINK_SUPPORT) { status = nfsd4_encode_fattr4__true(xdr, &args); From patchwork Mon Sep 18 13:58:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389808 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 5EE11CD37B0 for ; Mon, 18 Sep 2023 15:22:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233992AbjIRPWq (ORCPT ); Mon, 18 Sep 2023 11:22:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236084AbjIRPWp (ORCPT ); Mon, 18 Sep 2023 11:22:45 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13DA02707 for ; Mon, 18 Sep 2023 08:18:41 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85C4FC43142; Mon, 18 Sep 2023 13:58:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045485; bh=kNaL5e8aaD0GTwAKDAPTJ9K7nCrPYuoVxT9Pmw/x1TI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ssgJi9DY6Ww5dFkndPBe2rE872DWybkcApuMPKEHgUOPkUMm5SX4Oyqjn+0MQsCBP fwSrtmXZQ/Grgwo9Riz2MniKT5NrK2p/ib+yNpzG+2u8rCIQx+YuoPmDs5EDfiVlh5 aSWsT3VzBzfbhl3dWazVZr3DHGbJwNv6bihip5J5f9x/XCC28Zk+UmB1BiSO0Bz4+Z ove3RG7JMWCeFWsBiLq1kNTNrqrt++1YzVCrJZdUUAVy1w3UOWlylSmlAW83kGHo0x hmz62TFXIqSnpKTg1NgM5e1AIMD9Dk1zrgAW111aX4mHX5fTAfVo5dq0HcZQWJhMqd TRHUDSzJre00w== Subject: [PATCH v1 12/52] NFSD: Add nfsd4_encode_fattr4_fsid() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:58:04 -0400 Message-ID: <169504548451.133720.15494194051885617338.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_FSID 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 | 58 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 601b3a0e61d4..b41bc1b0c12c 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3030,6 +3030,39 @@ static __be32 nfsd4_encode_fattr4_size(struct xdr_stream *xdr, return nfsd4_encode_uint64_t(xdr, args->stat.size); } +static __be32 nfsd4_encode_fattr4_fsid(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + __be32 *p; + + p = xdr_reserve_space(xdr, XDR_UNIT * 2 + XDR_UNIT * 2); + if (!p) + return nfserr_resource; + + if (unlikely(args->exp->ex_fslocs.migrated)) { + p = xdr_encode_hyper(p, NFS4_REFERRAL_FSID_MAJOR); + xdr_encode_hyper(p, NFS4_REFERRAL_FSID_MINOR); + return nfs_ok; + } + switch (fsid_source(args->fhp)) { + case FSIDSOURCE_FSID: + p = xdr_encode_hyper(p, (u64)args->exp->ex_fsid); + xdr_encode_hyper(p, (u64)0); + break; + case FSIDSOURCE_DEV: + *p++ = xdr_zero; + *p++ = cpu_to_be32(MAJOR(args->stat.dev)); + *p++ = xdr_zero; + *p = cpu_to_be32(MINOR(args->stat.dev)); + break; + case FSIDSOURCE_UUID: + xdr_encode_opaque_fixed(p, args->exp->ex_uuid, EX_UUID_LEN); + break; + } + + return nfs_ok; +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3195,28 +3228,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_FSID) { - p = xdr_reserve_space(xdr, 16); - if (!p) - goto out_resource; - if (exp->ex_fslocs.migrated) { - p = xdr_encode_hyper(p, NFS4_REFERRAL_FSID_MAJOR); - p = xdr_encode_hyper(p, NFS4_REFERRAL_FSID_MINOR); - } else switch (fsid_source(args.fhp)) { - case FSIDSOURCE_FSID: - p = xdr_encode_hyper(p, (u64)exp->ex_fsid); - p = xdr_encode_hyper(p, (u64)0); - break; - case FSIDSOURCE_DEV: - *p++ = cpu_to_be32(0); - *p++ = cpu_to_be32(MAJOR(args.stat.dev)); - *p++ = cpu_to_be32(0); - *p++ = cpu_to_be32(MINOR(args.stat.dev)); - break; - case FSIDSOURCE_UUID: - p = xdr_encode_opaque_fixed(p, exp->ex_uuid, - EX_UUID_LEN); - break; - } + status = nfsd4_encode_fattr4_fsid(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_UNIQUE_HANDLES) { status = nfsd4_encode_fattr4__false(xdr, &args); From patchwork Mon Sep 18 13:58:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389832 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 8A8D1CD37B0 for ; Mon, 18 Sep 2023 15:26:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229594AbjIRP0J (ORCPT ); Mon, 18 Sep 2023 11:26:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231184AbjIRP0I (ORCPT ); Mon, 18 Sep 2023 11:26:08 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B95D310E4 for ; Mon, 18 Sep 2023 08:24:19 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8538C116A1; Mon, 18 Sep 2023 13:58:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045492; bh=4bX28rcLfTjwMKcweUPIz9tfBG6eDRYjCDjZfyqCq/U=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ddPkljgvAQfgdKGJuja+8Jm5rUK90RcNb4VMy3kZKUEicnL9eoKc9WlzNTa4NY5Ur bAKo8RuFT+WldHVtysDkZZdu1Y9LZpnHP7UPTHNKFqIBPsXd1i0ehg5fMT5TklDZR8 zqglvtl+c0b6ronGcEjHJtTUjwAMCSqA4g0DNVxbCl0BEE1mU+FFFS743Z8XmfRPLy ONg5inEICDo86qF4lFdFJIZ3ZQO5NUUTqcRj+KwYyDBZy5eNAW1+Mr44TSZ5ieuV2l md2ke0v61FL1LEkoPTcz01ptQyyyCFoxWTyfYl+uFcJ/cmRpYRnoo6BrwZ4DG/X6i/ vmy5JUtsqMEzg== Subject: [PATCH v1 13/52] NFSD: Add nfsd4_encode_fattr4_lease_time() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:58:10 -0400 Message-ID: <169504549092.133720.11655987019526283395.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_LEASE_TIME 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 +++++++++++----- fs/nfsd/xdr4.h | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index b41bc1b0c12c..15a07f7d9b38 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3063,6 +3063,14 @@ static __be32 nfsd4_encode_fattr4_fsid(struct xdr_stream *xdr, return nfs_ok; } +static __be32 nfsd4_encode_fattr4_lease_time(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + struct nfsd_net *nn = net_generic(SVC_NET(args->rqstp), nfsd_net_id); + + return nfsd4_encode_nfs_lease4(xdr, nn->nfsd4_lease); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3094,7 +3102,6 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, .mnt = exp->ex_path.mnt, .dentry = dentry, }; - struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); BUG_ON(bmval1 & NFSD_WRITEONLY_ATTRS_WORD1); BUG_ON(!nfsd_attrs_supported(minorversion, bmval)); @@ -3238,10 +3245,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_LEASE_TIME) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(nn->nfsd4_lease); + status = nfsd4_encode_fattr4_lease_time(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_RDATTR_ERROR) { p = xdr_reserve_space(xdr, 4); diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index d6059b0549f5..488ecdacc4c6 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -90,6 +90,8 @@ nfsd4_encode_uint32_t(struct xdr_stream *xdr, u32 val) return nfs_ok; } +#define nfsd4_encode_nfs_lease4(x, v) nfsd4_encode_uint32_t(x, v) + /** * nfsd4_encode_uint64_t - Encode an XDR uint64_t type result * @xdr: target XDR stream From patchwork Mon Sep 18 13:58:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389801 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 8808DCD37B0 for ; Mon, 18 Sep 2023 15:22:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238243AbjIRPWG (ORCPT ); Mon, 18 Sep 2023 11:22:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239467AbjIRPWF (ORCPT ); Mon, 18 Sep 2023 11:22:05 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 380901707 for ; Mon, 18 Sep 2023 08:20:03 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EE32C4167D; Mon, 18 Sep 2023 13:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045498; bh=aDSeXCSL7SZoK6/Ot3WLqq53MCPrOBsCDGMyJ1Ik22g=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=T7ciIjQdbuy251hZSF9/QcOP7Bcw/+HgudAKk5t/VOjJvrXWFFk/XKZOdMbXBH2nk dWM3glDDKRQrxFhBT9FIjHfQTACavIaFdxMExUk0RnIul8+EQkhKupzb7iYVrIxoDA KLmW85GkvPvyfevdJQwZ30XufFLdhoBiSRm0ittzOEXNRl6oD3dMNYCHVPi6209hV4 mmYpvmUzO9rxaNEaBHROD10ZVWC3O22bNQc0W0kdGGEsJj3QOOPWxkhrPbX+z/5tfW SE0bfm+/IsykbUa115HmoPP6vubMqeLJMIE/HlgZwqQYWotUPCQvcLcSAQrNipjC4u jwhEDJIXGjq2w== Subject: [PATCH v1 14/52] NFSD: Add nfsd4_encode_fattr4_rdattr_error() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:58:17 -0400 Message-ID: <169504549733.133720.7851563488445082802.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_RDATTR_ERROR 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 15a07f7d9b38..c67b5d942390 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3071,6 +3071,12 @@ static __be32 nfsd4_encode_fattr4_lease_time(struct xdr_stream *xdr, return nfsd4_encode_nfs_lease4(xdr, nn->nfsd4_lease); } +static __be32 nfsd4_encode_fattr4_rdattr_error(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_uint32_t(xdr, args->rdattr_err); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3250,10 +3256,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_RDATTR_ERROR) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(args.rdattr_err); + status = nfsd4_encode_fattr4_rdattr_error(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_ACL) { struct nfs4_ace *ace; From patchwork Mon Sep 18 13:58:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389803 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 9C4E6CD37B0 for ; Mon, 18 Sep 2023 15:22:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239620AbjIRPWW (ORCPT ); Mon, 18 Sep 2023 11:22:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239634AbjIRPWU (ORCPT ); Mon, 18 Sep 2023 11:22:20 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9449226BA for ; Mon, 18 Sep 2023 08:20:16 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFF54C116A0; Mon, 18 Sep 2023 13:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045504; bh=XvaHvfQJlyRNh/aVDspmx5wQA7m0ZtMKN0EboRwQ8Fc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=uA8Qt7uK2STwN2BRcBpK6KysAHLLQLkI3jDMqr3v9POktG7RzJRe2cb6w67zcS0QU LVwqcHZFVqFL7E9WqRBef/PTEVMWCsmHg/TvAF3SWF8yruy+kgWCNG+JzDkqu8qiTi FapFmH0gjPyTlTDQH0I6thAVNR8yBDm7oWXZeoUf3w+5nWZZnX5W4KKbx7uWwGr16j gTOU4kSit5VtzV1TbttO605S9RpAvZ0gSCsdaMCgmthybRRkIhQ3j4GJvm51GAtuPW JSSgMwLMYnCrGkrowHHU7b/4XWrf6WRY4muGCZwTxcrJJujwQVzcEtdlmjO6hsTj7I tB7+7JvMvNEGQ== Subject: [PATCH v1 15/52] NFSD: Add nfsd4_encode_fattr4_aclsupport() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:58:23 -0400 Message-ID: <169504550370.133720.16652934537928090407.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_ACLSUPPORT 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 | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index c67b5d942390..6604763bd96c 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3077,6 +3077,17 @@ static __be32 nfsd4_encode_fattr4_rdattr_error(struct xdr_stream *xdr, return nfsd4_encode_uint32_t(xdr, args->rdattr_err); } +static __be32 nfsd4_encode_fattr4_aclsupport(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + u32 mask; + + mask = 0; + if (IS_POSIXACL(d_inode(args->dentry))) + mask = ACL4_SUPPORT_ALLOW_ACL | ACL4_SUPPORT_DENY_ACL; + return nfsd4_encode_uint32_t(xdr, mask); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3291,11 +3302,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, } out_acl: if (bmval0 & FATTR4_WORD0_ACLSUPPORT) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(IS_POSIXACL(dentry->d_inode) ? - ACL4_SUPPORT_ALLOW_ACL|ACL4_SUPPORT_DENY_ACL : 0); + status = nfsd4_encode_fattr4_aclsupport(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_CANSETTIME) { status = nfsd4_encode_fattr4__true(xdr, &args); From patchwork Mon Sep 18 13:58:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389817 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 A5D49CD37B0 for ; Mon, 18 Sep 2023 15:24:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240741AbjIRPYT (ORCPT ); Mon, 18 Sep 2023 11:24:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236845AbjIRPYR (ORCPT ); Mon, 18 Sep 2023 11:24:17 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93CE0FD for ; Mon, 18 Sep 2023 08:22:41 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 107D0C116A5; Mon, 18 Sep 2023 13:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045511; bh=i63og+Oy8QoX7wqXUkTyTGKqBSbru6EW6mxAYEBZppk=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=qx3jSaHPnrVbZmfzB32gcDwI/XvQQHg/Y26K6ZGLEeyxWIJKP90dAUPpHJ+S5Go8z FY3aS4vJgQu7t3NaiL4ta8BmxVbh9dWrnqwXAx2UCkcnsSJdbggX2SdJs44NobHdrn vIRSim2Li65wTpOoT0XmbM9yrtpww9OhXqicuHzM/9zShVGVu393AQN2nEJkiCkSGD t4IVeGqrlRCKIlCXTt+Xltroxm8mVNGCDa6fI5gHxu6QbxbGPJ6LKn7rty1/CUT+U3 Ihdd0GIJaq1lbNWGcaldEPsti8iUrc5uukMO/BaodvpcAh/NKeWAdpkJ8TtUXjAfXH k/+6wLuzjKxfA== Subject: [PATCH v1 16/52] NFSD: Add nfsd4_encode_nfsace4() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:58:30 -0400 Message-ID: <169504551010.133720.3074976241793989767.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 ACE encoding helper so that it can eventually be reused for encoding OPEN results that contain delegation ACEs. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 36 +++++++++++++++++++++--------------- fs/nfsd/xdr4.h | 3 +++ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 6604763bd96c..89d3b276a494 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2783,16 +2783,29 @@ static __be32 nfsd4_encode_fs_locations(struct xdr_stream *xdr, return 0; } -static inline __be32 -nfsd4_encode_aclname(struct xdr_stream *xdr, struct svc_rqst *rqstp, - struct nfs4_ace *ace) +static __be32 nfsd4_encode_nfsace4(struct xdr_stream *xdr, struct svc_rqst *rqstp, + struct nfs4_ace *ace) { + __be32 status; + + /* type */ + status = nfsd4_encode_acetype4(xdr, ace->type); + if (status != nfs_ok) + return nfserr_resource; + /* flag */ + status = nfsd4_encode_aceflag4(xdr, ace->flag); + if (status != nfs_ok) + return nfserr_resource; + /* access mask */ + status = nfsd4_encode_acemask4(xdr, ace->access_mask & NFS4_ACE_MASK_ALL); + if (status != nfs_ok) + return nfserr_resource; + /* who */ if (ace->whotype != NFS4_ACL_WHO_NAMED) return nfs4_acl_write_who(xdr, ace->whotype); - else if (ace->flag & NFS4_ACE_IDENTIFIER_GROUP) + if (ace->flag & NFS4_ACE_IDENTIFIER_GROUP) return nfsd4_encode_group(xdr, rqstp, ace->who_gid); - else - return nfsd4_encode_user(xdr, rqstp, ace->who_uid); + return nfsd4_encode_user(xdr, rqstp, ace->who_uid); } static inline __be32 @@ -3288,15 +3301,8 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, *p++ = cpu_to_be32(args.acl->naces); for (ace = args.acl->aces; ace < args.acl->aces + args.acl->naces; ace++) { - p = xdr_reserve_space(xdr, 4*3); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(ace->type); - *p++ = cpu_to_be32(ace->flag); - *p++ = cpu_to_be32(ace->access_mask & - NFS4_ACE_MASK_ALL); - status = nfsd4_encode_aclname(xdr, rqstp, ace); - if (status) + status = nfsd4_encode_nfsace4(xdr, args.rqstp, ace); + if (status != nfs_ok) goto out; } } diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 488ecdacc4c6..f0866a55fd91 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -90,6 +90,9 @@ nfsd4_encode_uint32_t(struct xdr_stream *xdr, u32 val) return nfs_ok; } +#define nfsd4_encode_aceflag4(x, v) nfsd4_encode_uint32_t(x, v) +#define nfsd4_encode_acemask4(x, v) nfsd4_encode_uint32_t(x, v) +#define nfsd4_encode_acetype4(x, v) nfsd4_encode_uint32_t(x, v) #define nfsd4_encode_nfs_lease4(x, v) nfsd4_encode_uint32_t(x, v) /** From patchwork Mon Sep 18 13:58:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389826 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 AA5FACD37B0 for ; Mon, 18 Sep 2023 15:25:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232987AbjIRPZb (ORCPT ); Mon, 18 Sep 2023 11:25:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234573AbjIRPZ3 (ORCPT ); Mon, 18 Sep 2023 11:25:29 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A428E5A for ; Mon, 18 Sep 2023 08:22:14 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76BBBC116A4; Mon, 18 Sep 2023 13:58:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045517; bh=DiIy/9dHyZXGiXiWZAsGqUR7XE4E69RNs5XGyzBP/TQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=YAD2mHCfO5htu7sdUD5UtCf0xU56dOselPPAFMUCKAoCOZAmTTvtsExUvom7h63B7 xZ1qZ8mTbNgtHDkMqLhPkQltO6oj7mUnWrMavRIh72llMXuDg92drZ+UWdPIa8JkB/ A7/XIVaAaQ1YdR200DSlxdTiqxd53rukbOGy5av+KojpyHT8isTXt66Mc03xLHeCg/ cN01Lef2XgO6RE5NeaxoOwaiaPVpg1NiosdCof4UZq+E0cBUPUc1+okFsvVpVy98oo tGNqlQYgOSqaQZcji1U8YRt85gN/EALsjydVbO6aT1HvPt6dcn7DMlW6OJdd2rtRV2 /AZysMcyWY4gA== Subject: [PATCH v1 17/52] NFSD: Add nfsd4_encode_fattr4_acl() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:58:36 -0400 Message-ID: <169504551644.133720.1056760362211885614.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_ACL 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 | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 89d3b276a494..5e91ed6ae0f7 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3101,6 +3101,29 @@ static __be32 nfsd4_encode_fattr4_aclsupport(struct xdr_stream *xdr, return nfsd4_encode_uint32_t(xdr, mask); } +static __be32 nfsd4_encode_fattr4_acl(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + struct nfs4_acl *acl = args->acl; + struct nfs4_ace *ace; + __be32 status; + + /* nfsace4<> */ + if (!acl) { + if (xdr_stream_encode_u32(xdr, 0) != XDR_UNIT) + return nfserr_resource; + } else { + if (xdr_stream_encode_u32(xdr, acl->naces) != XDR_UNIT) + return nfserr_resource; + for (ace = acl->aces; ace < acl->aces + acl->naces; ace++) { + status = nfsd4_encode_nfsace4(xdr, args->rqstp, ace); + if (status != nfs_ok) + return status; + } + } + return nfs_ok; +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3285,28 +3308,10 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_ACL) { - struct nfs4_ace *ace; - - if (args.acl == NULL) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - - *p++ = cpu_to_be32(0); - goto out_acl; - } - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(args.acl->naces); - - for (ace = args.acl->aces; ace < args.acl->aces + args.acl->naces; ace++) { - status = nfsd4_encode_nfsace4(xdr, args.rqstp, ace); - if (status != nfs_ok) - goto out; - } + status = nfsd4_encode_fattr4_acl(xdr, &args); + if (status) + goto out; } -out_acl: if (bmval0 & FATTR4_WORD0_ACLSUPPORT) { status = nfsd4_encode_fattr4_aclsupport(xdr, &args); if (status != nfs_ok) From patchwork Mon Sep 18 13:58:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389797 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 1007BCD37B0 for ; Mon, 18 Sep 2023 15:20:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229594AbjIRPUH (ORCPT ); Mon, 18 Sep 2023 11:20:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230227AbjIRPUG (ORCPT ); Mon, 18 Sep 2023 11:20:06 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B962110E5 for ; Mon, 18 Sep 2023 08:18:40 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0178C116A6; Mon, 18 Sep 2023 13:58:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045524; bh=JVowiB1qwGRQwKqjm0kyZoKJGWEGX8p3DbGw3T2pl5Q=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=NH3W1mXa+mN+t116thnwT8P4gBFYsM850faNRQrTkUgNTHxm2+98OwTO23mlhnbbQ S/j27nUD7bEivfqjQDcXgrj7In6IZFzVXa1prmanlA9+niYp64l3Y/VIZg5Gu795jm 5AtDZbtpZgOp/AY58vC7IjYSB9zEbzcZ8KBld1KpIL7mdzA4IBPRsGbAE5ofeiQNVv 4PhjKL2hLut7tYCRhTQj1NJUDTAuB9Y36opNzXyxOR8I/lxNhvs1GjezQ002YaVrzI K3P0ezvaydk2vfd7te9o73MOHaQ6Z56BXEWa2rddKr6rCyfQsV/630dTu6sL45DGvy wumFk2q2ngYrw== Subject: [PATCH v1 18/52] NFSD: Add nfsd4_encode_fattr4_filehandle() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:58:42 -0400 Message-ID: <169504552286.133720.2850816810472540761.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_FILEHANDLE into a helper. In a subsequent patch, this helper will be called from a bitmask loop. We can de-duplicate the other filehandle encoder (in GETFH) using our new helper. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 5e91ed6ae0f7..17997bf08139 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2530,6 +2530,12 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) return true; } +static __be32 nfsd4_encode_nfs_fh4(struct xdr_stream *xdr, + struct knfsd_fh *fh_handle) +{ + return nfsd4_encode_opaque(xdr, fh_handle->fh_raw, fh_handle->fh_size); +} + static __be32 nfsd4_encode_nfstime4(struct xdr_stream *xdr, struct timespec64 *tv) { @@ -3124,6 +3130,12 @@ static __be32 nfsd4_encode_fattr4_acl(struct xdr_stream *xdr, return nfs_ok; } +static __be32 nfsd4_encode_fattr4_filehandle(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_nfs_fh4(xdr, &args->fhp->fh_handle); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3338,11 +3350,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_FILEHANDLE) { - p = xdr_reserve_space(xdr, args.fhp->fh_handle.fh_size + 4); - if (!p) - goto out_resource; - p = xdr_encode_opaque(p, &args.fhp->fh_handle.fh_raw, - args.fhp->fh_handle.fh_size); + status = nfsd4_encode_fattr4_filehandle(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_FILEID) { p = xdr_reserve_space(xdr, 8); @@ -3927,18 +3937,11 @@ static __be32 nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr, union nfsd4_op_u *u) { - struct svc_fh **fhpp = &u->getfh; struct xdr_stream *xdr = resp->xdr; - struct svc_fh *fhp = *fhpp; - unsigned int len; - __be32 *p; + struct svc_fh *fhp = u->getfh; - len = fhp->fh_handle.fh_size; - p = xdr_reserve_space(xdr, len + 4); - if (!p) - return nfserr_resource; - p = xdr_encode_opaque(p, &fhp->fh_handle.fh_raw, len); - return 0; + /* object */ + return nfsd4_encode_nfs_fh4(xdr, &fhp->fh_handle); } /* From patchwork Mon Sep 18 13:58:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389791 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 024E3CD13D9 for ; Mon, 18 Sep 2023 15:18:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232620AbjIRPSt (ORCPT ); Mon, 18 Sep 2023 11:18:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230102AbjIRPSo (ORCPT ); Mon, 18 Sep 2023 11:18:44 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBA231A3 for ; Mon, 18 Sep 2023 08:17:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37B7AC116A7; Mon, 18 Sep 2023 13:58:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045530; bh=LDzmDY9+OVIwkq/9CVMxOdGFPlemS8fqVm2t+0gQaB0=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=CKGICMAAxl/F5BFoW/1LyFwyMJVrSBcHlL4yW5PaZBMgag2+qXeBZefz/tqidGq6g QbnaNTdF6P0eumhz2RcpqAvLQPJi9l08fVb/e64ZqfXhnYi3ohFIZobIja/3HmsHfP EHIUw9Woz64+ZgRuyXcPEfvBA56ojxnmShpuGhDfwMZabjQyvM3PVvoKmZgXree0M1 7YZuZ3hBkMtRDjsvsuHJLx3zPv0d1bi5lK8edVkOPug0JbcjwZ4RJznzalvtDGCCbz MrEZq7mAkkR5zHhm02ydcgvdWQ3IMFJ4n5ZtzzxprcpkMoNYQ7tpI5BijcNKZxshvS RqH+K7ZyvjHRw== Subject: [PATCH v1 19/52] NFSD: Add nfsd4_encode_fattr4_fileid() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:58:49 -0400 Message-ID: <169504552923.133720.14141060340723098538.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_FILEID 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 17997bf08139..e3dd05f8d28f 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3136,6 +3136,12 @@ static __be32 nfsd4_encode_fattr4_filehandle(struct xdr_stream *xdr, return nfsd4_encode_nfs_fh4(xdr, &args->fhp->fh_handle); } +static __be32 nfsd4_encode_fattr4_fileid(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_uint64_t(xdr, args->stat.ino); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3355,10 +3361,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_FILEID) { - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - p = xdr_encode_hyper(p, args.stat.ino); + status = nfsd4_encode_fattr4_fileid(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_FILES_AVAIL) { p = xdr_reserve_space(xdr, 8); From patchwork Mon Sep 18 13:58:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389798 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 1E920C46CA1 for ; Mon, 18 Sep 2023 15:20:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230270AbjIRPUJ (ORCPT ); Mon, 18 Sep 2023 11:20:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230227AbjIRPUJ (ORCPT ); Mon, 18 Sep 2023 11:20:09 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B89B59D for ; Mon, 18 Sep 2023 08:18:41 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D2A6C116A9; Mon, 18 Sep 2023 13:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045536; bh=1h9D3uLyrIFnieq2Dat4g6QoaOTnBtZKMZzU7+jA84M=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=UnOElsntEeI99XI5vGjiXHZXuYhCa18WuEmod+roKqnaLizX3BDNMHZqHnd8eCaDq aLzWRAbT+JMURUJsgL+cuTE9gQAkFWSgqcjOSsO4UMcvZSka+r20pr0O6t7Ql/oe9e AhpuUPH7y3NLWlVwiPOqwip/99UCNeHaBDF/v/ti7+A4m5cOO60iaCg6gvxT7OYZ2+ k9VlugxocvaCZ81Oq0PAMUhCFJzEZxytZ46H7fWqpzxCisqFwi+ucQHt8ckVE90pNV nV8Yh3J4H4d+OSzjfs7/eMgRiCSDxhI5K6mQePwx6fmiLG06SXlXWBBMaL3I5m34vZ NLIa/7xw4b0gg== Subject: [PATCH v1 20/52] NFSD: Add nfsd4_encode_fattr4_files_avail() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:58:55 -0400 Message-ID: <169504553560.133720.17115534414934358128.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_AVAIL 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 e3dd05f8d28f..737c13c4bf82 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3142,6 +3142,12 @@ static __be32 nfsd4_encode_fattr4_fileid(struct xdr_stream *xdr, return nfsd4_encode_uint64_t(xdr, args->stat.ino); } +static __be32 nfsd4_encode_fattr4_files_avail(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_uint64_t(xdr, args->statfs.f_ffree); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3366,10 +3372,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_FILES_AVAIL) { - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - p = xdr_encode_hyper(p, (u64) args.statfs.f_ffree); + status = nfsd4_encode_fattr4_files_avail(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_FILES_FREE) { p = xdr_reserve_space(xdr, 8); From patchwork Mon Sep 18 13:59:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389812 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 DFC95CD37B0 for ; Mon, 18 Sep 2023 15:23:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240802AbjIRPXz (ORCPT ); Mon, 18 Sep 2023 11:23:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240711AbjIRPXv (ORCPT ); Mon, 18 Sep 2023 11:23:51 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3238E18D for ; Mon, 18 Sep 2023 08:22:04 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE5D2C116A8; Mon, 18 Sep 2023 13:59:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045543; bh=c0pK+arqvnDF4Pc2CeR1UNms2aINpfYvH+nnr6+zfDM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=GQjXYDVuhFXEaA3gRL64QMByp+SBzN12Jh3YQAfTlOz0pwOdQQ1tlCVCNAKC3BcdV bYSb67zJ7sNaSabKJ0YLtghm7ejD83cdz5CJzLkwmjRrxzoA3bkZ1LttokRFL7If/0 w0eMK+KFKN/3jNw8eHwUyuy0R+YPIohwAYyu4S7bLQ4AEhMmwi/mf0zOlv6ZeAgmro ut5Lz7/0g17w0Z78x0Hy0WU7nNiOPlgRh0k0EHmZ6PqV/9or+1i1C4ZXQJMc8zQ6Uh gDPkRbgebQ+Sx9VMcSh/q2jHhpTjCJHLIN7PvJJW7i0MfuCvtRs8syZWI4CoSIngVj I5vDG2Czullrw== Subject: [PATCH v1 21/52] NFSD: Add nfsd4_encode_fattr4_files_free() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:59:01 -0400 Message-ID: <169504554195.133720.8954634709081256034.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_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 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 737c13c4bf82..ee5fd6ff12e0 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3148,6 +3148,12 @@ static __be32 nfsd4_encode_fattr4_files_avail(struct xdr_stream *xdr, return nfsd4_encode_uint64_t(xdr, args->statfs.f_ffree); } +static __be32 nfsd4_encode_fattr4_files_free(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_uint64_t(xdr, args->statfs.f_ffree); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3377,10 +3383,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_FILES_FREE) { - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - p = xdr_encode_hyper(p, (u64) args.statfs.f_ffree); + status = nfsd4_encode_fattr4_files_free(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_FILES_TOTAL) { p = xdr_reserve_space(xdr, 8); 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); From patchwork Mon Sep 18 13:59:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389809 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 D375EC46CA1 for ; Mon, 18 Sep 2023 15:23:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229485AbjIRPXN (ORCPT ); Mon, 18 Sep 2023 11:23:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239865AbjIRPXM (ORCPT ); Mon, 18 Sep 2023 11:23:12 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B60369C for ; Mon, 18 Sep 2023 08:18:41 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89ADAC116AB; Mon, 18 Sep 2023 13:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045555; bh=8igG2bOvJV6gb5Z0K/jxYV0hxPwdZTTiiBz9YVdPno8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Z/URcogfnWYTZ4SmCW787BgZAWQ7fR1p6Ph4UFUVe2ryQQHgpn9fYnHy++CZ7XdS6 J2Z+9cYZ2wuQ6wUzHH3WYNPrFCknLW7eisJnILD7mHiYg8PiQTCkw05JBWP2aFoRK5 MjFQ81PBUjf0Pmi2nQf/u8yENogP5fu4ha7R2MFx7hIxPA73xMKOljjZwm9nVNpX7D PzwSWhP4JV5U8x7JbPDMQq0N+evP9cucZWVWHBRb8evqXlx5teYcweFnM3+O/yylx4 MPr9m7MhbaV7K3hOncka82Z1k1Jx4HdheutJVHsQNd3X7qNaG5ZNsUzjzU4bdawzlk VuuiSMKkQsu8A== Subject: [PATCH v1 23/52] NFSD: Add nfsd4_encode_fattr4_fs_locations() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:59:14 -0400 Message-ID: <169504555464.133720.2700015104145924369.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_FS_LOCATIONS 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 | 66 ++++++++++++++++++++++------------------------------- 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index e024742abc73..f247fd6f02f5 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2658,9 +2658,6 @@ static __be32 nfsd4_encode_components(struct xdr_stream *xdr, char sep, return nfsd4_encode_components_esc(xdr, sep, components, 0, 0); } -/* - * encode a location element of a fs_locations structure - */ static __be32 nfsd4_encode_fs_location4(struct xdr_stream *xdr, struct nfsd4_fs_location *location) { @@ -2673,15 +2670,12 @@ static __be32 nfsd4_encode_fs_location4(struct xdr_stream *xdr, status = nfsd4_encode_components(xdr, '/', location->path); if (status) return status; - return 0; + return nfs_ok; } -/* - * Encode a path in RFC3530 'pathname4' format - */ -static __be32 nfsd4_encode_path(struct xdr_stream *xdr, - const struct path *root, - const struct path *path) +static __be32 nfsd4_encode_pathname4(struct xdr_stream *xdr, + const struct path *root, + const struct path *path) { struct path cur = *path; __be32 *p; @@ -2749,44 +2743,34 @@ static __be32 nfsd4_encode_path(struct xdr_stream *xdr, return err; } -static __be32 nfsd4_encode_fsloc_fsroot(struct xdr_stream *xdr, - struct svc_rqst *rqstp, const struct path *path) +static __be32 nfsd4_encode_fs_locations4(struct xdr_stream *xdr, + struct svc_rqst *rqstp, + struct svc_export *exp) { + struct nfsd4_fs_locations *fslocs = &exp->ex_fslocs; struct svc_export *exp_ps; - __be32 res; + unsigned int i; + __be32 status; + /* fs_root */ exp_ps = rqst_find_fsidzero_export(rqstp); if (IS_ERR(exp_ps)) return nfserrno(PTR_ERR(exp_ps)); - res = nfsd4_encode_path(xdr, &exp_ps->ex_path, path); + status = nfsd4_encode_pathname4(xdr, &exp_ps->ex_path, &exp->ex_path); exp_put(exp_ps); - return res; -} - -/* - * encode a fs_locations structure - */ -static __be32 nfsd4_encode_fs_locations(struct xdr_stream *xdr, - struct svc_rqst *rqstp, struct svc_export *exp) -{ - __be32 status; - int i; - __be32 *p; - struct nfsd4_fs_locations *fslocs = &exp->ex_fslocs; - - status = nfsd4_encode_fsloc_fsroot(xdr, rqstp, &exp->ex_path); - if (status) + if (status != nfs_ok) return status; - p = xdr_reserve_space(xdr, 4); - if (!p) + + /* locations<> */ + if (xdr_stream_encode_u32(xdr, fslocs->locations_count) != XDR_UNIT) return nfserr_resource; - *p++ = cpu_to_be32(fslocs->locations_count); - for (i=0; ilocations_count; i++) { + for (i = 0; i < fslocs->locations_count; i++) { status = nfsd4_encode_fs_location4(xdr, &fslocs->locations[i]); - if (status) + if (status != nfs_ok) return status; } - return 0; + + return nfs_ok; } static __be32 nfsd4_encode_nfsace4(struct xdr_stream *xdr, struct svc_rqst *rqstp, @@ -3160,6 +3144,12 @@ static __be32 nfsd4_encode_fattr4_files_total(struct xdr_stream *xdr, return nfsd4_encode_uint64_t(xdr, args->statfs.f_files); } +static __be32 nfsd4_encode_fattr4_fs_locations(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_fs_locations4(xdr, args->rqstp, args->exp); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3399,8 +3389,8 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_FS_LOCATIONS) { - status = nfsd4_encode_fs_locations(xdr, rqstp, exp); - if (status) + status = nfsd4_encode_fattr4_fs_locations(xdr, &args); + if (status != nfs_ok) goto out; } if (bmval0 & FATTR4_WORD0_HOMOGENEOUS) { From patchwork Mon Sep 18 13:59:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389806 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 AEC74C46CA1 for ; Mon, 18 Sep 2023 15:22:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237639AbjIRPWn (ORCPT ); Mon, 18 Sep 2023 11:22:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233840AbjIRPWl (ORCPT ); Mon, 18 Sep 2023 11:22:41 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBEB110E9 for ; Mon, 18 Sep 2023 08:18:40 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA21DC116AC; Mon, 18 Sep 2023 13:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045562; bh=M/h82MFHWyr2mUvrs0vB5POUEek15Jg9Mw+pNHvf7mE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=fzST+M1STn6w7fw3TImFNXFwAXm9IiZGW0Cd6BFR+9bFrog31OgxHcWATzgY+Wq8S lQR7cqc4H9pkhlUpItgQSwlMXD8gVk8VzFH+wBg+2a/+4+HW1Zg7XXLzDO4JijxnfC g1UKAgJzj58BPHVDwLvpgs1lFwZz+5cOZyJbUtKN6i+7JG3zcOwFc8pW/cRbrHRd2e 0F1HAqNWm9JM3zEbFO6hYIza9hpSDAmxNqNyvOGQqcF3R6pVv9GGQfAVJ09h4UJMAF Tj/KrwuXniF9vDqO4qdufnDDNoRmO+EH5gI+tE2Q25otBVdCQLDUpgn9SrKfSzEb++ ydyAsyrE6aw+w== Subject: [PATCH v1 24/52] NFSD: Add nfsd4_encode_fattr4_maxfilesize() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:59:20 -0400 Message-ID: <169504556094.133720.15381129751899751169.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_MAXFILESIZE 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, 11 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index f247fd6f02f5..eb7bc713f85c 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3150,6 +3150,14 @@ static __be32 nfsd4_encode_fattr4_fs_locations(struct xdr_stream *xdr, return nfsd4_encode_fs_locations4(xdr, args->rqstp, args->exp); } +static __be32 nfsd4_encode_fattr4_maxfilesize(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + struct super_block *sb = args->exp->ex_path.mnt->mnt_sb; + + return nfsd4_encode_uint64_t(xdr, sb->s_maxbytes); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3399,10 +3407,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_MAXFILESIZE) { - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - p = xdr_encode_hyper(p, exp->ex_path.mnt->mnt_sb->s_maxbytes); + status = nfsd4_encode_fattr4_maxfilesize(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_MAXLINK) { p = xdr_reserve_space(xdr, 4); From patchwork Mon Sep 18 13:59:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389800 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 13168CD37B0 for ; Mon, 18 Sep 2023 15:20:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230307AbjIRPUR (ORCPT ); Mon, 18 Sep 2023 11:20:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230227AbjIRPUQ (ORCPT ); Mon, 18 Sep 2023 11:20:16 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04F7910DC for ; Mon, 18 Sep 2023 08:18:39 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BBC3C116AE; Mon, 18 Sep 2023 13:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045568; bh=Yegaz6cGZwJJsAj6SZEdsba96jxIHs4Vb/e5LSdFc2w=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=LJrxFs/OLvszUeCrNZDBg33LCNZFxzysf7E99ijpNYVjYDiM3WAcf9M3IKIwmIvQ7 6t6I2qEEiS+qR9xL+54KClJJFFxhgq1NXTNXXUuUALV0Yc8kg05j4Efa6HrTu4F6Ku nGEQqv3sazGx7XwZFVUzQA6lh/M5TXxdKXIrwVfweNT5FXQ36cz5b5bamo7L+SHeKZ g7e4Kb/OMWriNG6uVxN4YL3nUsfXAnOZkHox8ng4bBO9UhfS08a0Dj5T216IVQIRYM afWii2ofHpexhaL83w/t45l3cSykjYaFoI4Ld513tA7ymnLGRwscvSMO3DVdsoNml2 hIvTpydb0uxbA== Subject: [PATCH v1 25/52] NFSD: Add nfsd4_encode_fattr4_maxlink() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:59:27 -0400 Message-ID: <169504556726.133720.8757481551055565977.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_MAXLINK 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 eb7bc713f85c..05d3b4409d03 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3158,6 +3158,12 @@ static __be32 nfsd4_encode_fattr4_maxfilesize(struct xdr_stream *xdr, return nfsd4_encode_uint64_t(xdr, sb->s_maxbytes); } +static __be32 nfsd4_encode_fattr4_maxlink(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_uint32_t(xdr, 255); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3412,10 +3418,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_MAXLINK) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(255); + status = nfsd4_encode_fattr4_maxlink(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_MAXNAME) { p = xdr_reserve_space(xdr, 4); From patchwork Mon Sep 18 13:59:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389805 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 DAB24CD37B0 for ; Mon, 18 Sep 2023 15:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236195AbjIRPWn (ORCPT ); Mon, 18 Sep 2023 11:22:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239886AbjIRPWk (ORCPT ); Mon, 18 Sep 2023 11:22:40 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A6221709 for ; Mon, 18 Sep 2023 08:20:04 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F611C116AD; Mon, 18 Sep 2023 13:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045574; bh=WZ61rQvfdYA+C3Bp6913SfYWN/RR9drvMnAlL1DR2HY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=rC8uv7ZbOUDfZ7ektzt8mguAnz71VYQakFU+O9PpECz71wK4MoVRFEpEcgZbPpqnT khT8IJ9L48VzADeawHX3LvKWL1gxGD9EhU70O8T4Kvl6UnS25ZSWJHq8777+GYVUDH btBSUfq1ff4rdUPfe8t/hFlc+P4XTvJ8bZBrhO61FnlpUOtPmy+Qi0JzqxEgIgBxd3 n+6VCsgK2ruF+L9xkCU5TDOUqIOOgcGNyJRg1MLOXpNyRwgcTAIZX9v0EtvPaE2+61 A0z4A6iZwmH214FdSbOk0ynuab4l31ouFpM2hKjFGeKkBRcVdblS1UPAvQofSZvK/d jkTzgoHNEPl+A== Subject: [PATCH v1 26/52] NFSD: Add nfsd4_encode_fattr4_maxname() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:59:33 -0400 Message-ID: <169504557361.133720.1521968664950334982.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_MAXNAME 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 05d3b4409d03..546879759c71 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3164,6 +3164,12 @@ static __be32 nfsd4_encode_fattr4_maxlink(struct xdr_stream *xdr, return nfsd4_encode_uint32_t(xdr, 255); } +static __be32 nfsd4_encode_fattr4_maxname(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_uint32_t(xdr, args->statfs.f_namelen); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3423,10 +3429,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_MAXNAME) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(args.statfs.f_namelen); + status = nfsd4_encode_fattr4_maxname(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_MAXREAD) { p = xdr_reserve_space(xdr, 8); From patchwork Mon Sep 18 13:59:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389811 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 DC3EBCD37B0 for ; Mon, 18 Sep 2023 15:23:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240729AbjIRPXv (ORCPT ); Mon, 18 Sep 2023 11:23:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236784AbjIRPXu (ORCPT ); Mon, 18 Sep 2023 11:23:50 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 613D519D for ; Mon, 18 Sep 2023 08:22:05 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE373C116B4; Mon, 18 Sep 2023 13:59:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045581; bh=rfFAteDhYCQvoSPjxMRQ5ipc/xK9xXR6g5Fbi87zWOU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=gVU/jMdWy3YfE/TA7pg/2P42r3Xmw62TfbHB8wiMRKGONSieBt/SAwszCF/xmQ5fB YhZu/MDfYe1hTlt+D+5VU3BoggBRrFznuzWJB0C0ZpOAmfef3WYfjaNaGH9oMBnvED AIn253gYWkxf05mjLYjYSiToBbYr5Xi2LAZ7I4ZMHX1QG8T0Y7tdiXHvmZx3WIbi9y wIj/IoSfOyG9txt8cRVaMawdDueBcszW7cExoMgx3flkBLWD+6wf5d1pn0CfzeN2K/ 4k4zJyB3bO2JPl3h0RiFqkIwVNDYbK7e6mVhsh3CB0Jk+Q33P/EBnmFlGRrS/kbKQ9 fkde2LHDDHsuw== Subject: [PATCH v1 27/52] NFSD: Add nfsd4_encode_fattr4_maxread() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:59:39 -0400 Message-ID: <169504557996.133720.11598552337976844789.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_MAXREAD 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 546879759c71..35911ecccfbd 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3170,6 +3170,12 @@ static __be32 nfsd4_encode_fattr4_maxname(struct xdr_stream *xdr, return nfsd4_encode_uint32_t(xdr, args->statfs.f_namelen); } +static __be32 nfsd4_encode_fattr4_maxread(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_uint64_t(xdr, svc_max_payload(args->rqstp)); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3434,10 +3440,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_MAXREAD) { - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - p = xdr_encode_hyper(p, (u64) svc_max_payload(rqstp)); + status = nfsd4_encode_fattr4_maxread(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval0 & FATTR4_WORD0_MAXWRITE) { p = xdr_reserve_space(xdr, 8); From patchwork Mon Sep 18 13:59:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389793 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 A9E54CD13DA for ; Mon, 18 Sep 2023 15:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230102AbjIRPSv (ORCPT ); Mon, 18 Sep 2023 11:18:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232684AbjIRPSu (ORCPT ); Mon, 18 Sep 2023 11:18:50 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE3F11A5 for ; Mon, 18 Sep 2023 08:17:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59FABC116AF; Mon, 18 Sep 2023 13:59:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045587; bh=InadVBSo7OT/pmDWDwEtwVs+CXyYxyCgjheZH7QSbIA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=QHaM3kdxz9jNVV7LdlmZDIO4pvJNJxrTwP2ZbUGfnpCzumWX0xqNukX27E/wiF/6S Bnzsktz3DCO36BFM5m3UeLNx0X32BtlRbGtH8sMAzG4MhcHTsU6vTOMf5lIkCV5y2D 7k1Xy3Ad7IF747UM61rLQUBr3uQHAsEnW1RZJ4ogz0/lByIgtSG9zhnYHOVnI9lXki yZL3fFkfBNChVjyVfrMdeWk+BgTz7fj7wgexFn/7t0DiFFZl65K8AaTvaCRYTnxPE9 8dk4DkF1BePXGYlGPWsBlZk2piqcarAMOZzrNbT5io+tBDhJ4EbSSXh810DJxQZ/iK 9rEWG/1yaNTiQ== Subject: [PATCH v1 28/52] NFSD: Add nfsd4_encode_fattr4_maxwrite() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:59:46 -0400 Message-ID: <169504558635.133720.13043616190229667215.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_MAXWRITE 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 35911ecccfbd..39ff6d1bd41d 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3176,6 +3176,12 @@ static __be32 nfsd4_encode_fattr4_maxread(struct xdr_stream *xdr, return nfsd4_encode_uint64_t(xdr, svc_max_payload(args->rqstp)); } +static __be32 nfsd4_encode_fattr4_maxwrite(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_uint64_t(xdr, svc_max_payload(args->rqstp)); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3445,10 +3451,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval0 & FATTR4_WORD0_MAXWRITE) { - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - p = xdr_encode_hyper(p, (u64) svc_max_payload(rqstp)); + status = nfsd4_encode_fattr4_maxwrite(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval1 & FATTR4_WORD1_MODE) { p = xdr_reserve_space(xdr, 4); From patchwork Mon Sep 18 13:59:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389814 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 52210CD13D2 for ; Mon, 18 Sep 2023 15:23:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239917AbjIRPX5 (ORCPT ); Mon, 18 Sep 2023 11:23:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240084AbjIRPXz (ORCPT ); Mon, 18 Sep 2023 11:23:55 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64514131 for ; Mon, 18 Sep 2023 08:20:11 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A857AC116B0; Mon, 18 Sep 2023 13:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045593; bh=d2XeAT7z58UAmZE6/pqypsYM53v61CZ2QZKJG0Ipqdc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=XG9viIT8tIGnOOBQVrpPaRyk7pKRnzqbVRIrzb042x3Qg+c0js+FI7+kV+PHbs5sC E2N+/OeFs8ryjHU9fQ58gM9adgzS9isFEVDV4AsHhJutV53+s1NskcFXYAkXBpluIe eRQlnyz2tnlYkmGavOpxjLbDH87i8B3QjAfnkbeSrErSfGDQ/pzksyCxAdqBiIoQAR WbHjjqVzA+r5n+VI2hG6xRj0acdDo4Zyj9/C5zlpBszyT6yIxiV/n7nM6s7yTZGrcT Exx2dxNhsNfEsxeSiK2Oc68UizNpDIPPeBmw6a9Mvr0yL2VI/BvmULjq2MmloOVKpj Nt0GFDhBP4jjQ== Subject: [PATCH v1 29/52] NFSD: Add nfsd4_encode_fattr4_mode() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:59:52 -0400 Message-ID: <169504559274.133720.18210392905469993992.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_MODE 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 +++++++++---- fs/nfsd/xdr4.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 39ff6d1bd41d..91f5f154428b 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3182,6 +3182,12 @@ static __be32 nfsd4_encode_fattr4_maxwrite(struct xdr_stream *xdr, return nfsd4_encode_uint64_t(xdr, svc_max_payload(args->rqstp)); } +static __be32 nfsd4_encode_fattr4_mode(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_mode4(xdr, args->stat.mode & S_IALLUGO); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3456,10 +3462,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_MODE) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(args.stat.mode & S_IALLUGO); + status = nfsd4_encode_fattr4_mode(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval1 & FATTR4_WORD1_NO_TRUNC) { status = nfsd4_encode_fattr4__true(xdr, &args); diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index f0866a55fd91..52322acc1e9f 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -93,6 +93,7 @@ nfsd4_encode_uint32_t(struct xdr_stream *xdr, u32 val) #define nfsd4_encode_aceflag4(x, v) nfsd4_encode_uint32_t(x, v) #define nfsd4_encode_acemask4(x, v) nfsd4_encode_uint32_t(x, v) #define nfsd4_encode_acetype4(x, v) nfsd4_encode_uint32_t(x, v) +#define nfsd4_encode_mode4(x, v) nfsd4_encode_uint32_t(x, v) #define nfsd4_encode_nfs_lease4(x, v) nfsd4_encode_uint32_t(x, v) /** From patchwork Mon Sep 18 13:59:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389802 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 17460C46CA1 for ; Mon, 18 Sep 2023 15:22:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239727AbjIRPWV (ORCPT ); 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 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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); From patchwork Mon Sep 18 14:00:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389810 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 E44B7CD13D8 for ; Mon, 18 Sep 2023 15:23:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232220AbjIRPXu (ORCPT ); Mon, 18 Sep 2023 11:23:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240756AbjIRPXs (ORCPT ); Mon, 18 Sep 2023 11:23:48 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58C4F10C9 for ; Mon, 18 Sep 2023 08:20:05 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68270C116B2; Mon, 18 Sep 2023 14:00:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045606; bh=FHAAE6TUbfavTm7dq4dD82FCYvzIisEOnVuUD+XO8os=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=OxkFSoGl1zFeIeyOkqVB1vTMQ2Dgo4+ff2AhexqFdiNkIuURXG5getegmvAtX8185 WIBfxOIwNtmWdxc3cydI/Ux1SHeceeFI5gczyZKp3kMubF00RhfcS2Hn7rxP9mm4pA Wzf9uZOPZpy0CERSkSK/vyfeu0LXyOAcYnspArhWmV7W00eyjLoRwF3Y86CJCXCFGa rDtslbFtra021/8SjOFYrRNox7qigU3GLBD8Iu4pmIKhLWft+Rva8MTeMvdwPI7VD9 n6VT3wHx02mqMAUL1RY0Nx6dqrVtM+vY3Qo5jBVCNtH6D194NmILce9nFbqD57OZv0 xMiczdoTdSXDA== Subject: [PATCH v1 31/52] NFSD: Add nfsd4_encode_fattr4_owner() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:00:05 -0400 Message-ID: <169504560541.133720.17707540313238672641.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_OWNER 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index e3d9ec44c817..11922b18f357 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3194,6 +3194,12 @@ static __be32 nfsd4_encode_fattr4_numlinks(struct xdr_stream *xdr, return nfsd4_encode_uint32_t(xdr, args->stat.nlink); } +static __be32 nfsd4_encode_fattr4_owner(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_user(xdr, args->rqstp, args->stat.uid); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3483,8 +3489,8 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_OWNER) { - status = nfsd4_encode_user(xdr, rqstp, args.stat.uid); - if (status) + status = nfsd4_encode_fattr4_owner(xdr, &args); + if (status != nfs_ok) goto out; } if (bmval1 & FATTR4_WORD1_OWNER_GROUP) { From patchwork Mon Sep 18 14:00:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389845 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 19FA1CD13D9 for ; Mon, 18 Sep 2023 15:33:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229500AbjIRPcl (ORCPT ); Mon, 18 Sep 2023 11:32:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229602AbjIRPcV (ORCPT ); Mon, 18 Sep 2023 11:32:21 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEB4D128 for ; Mon, 18 Sep 2023 08:28:09 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7C11C116B5; Mon, 18 Sep 2023 14:00:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045612; bh=oWnM++4sTTDXhDcWv911bJNzVpUnPd9jMvyXntU1aI0=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=FGUhh3CONTDUP/aWzCiUjTKjYm1kOMGPxvZ7aoxMihon5JayiUlpOKha+V7OhKM0V V+760dXDp4rVvw8gxnY6Aan0riDyezK/QG/7CUjabLvpBVfrbS0/MUpA90bvMJYDMj fa9r3mbK32p53udUF9gAvTd5qrtj7mdddFtlpvZyHYl+mi9zrjXWwUSiJWTt/SFeFI IS7aXcZaQky+E5nPGgD/SSS6wro6vr3TdGh4Xt2aqm9Sg5jmy3o4+qcXyDhQ94dW8N oE76oEfQIsJExZr+DRqk3YuE/mBnbJwXgzui4TN1Kzp3V5kajprdpg3XnZ3g6glV12 H4sJ7dIgQmVnw== Subject: [PATCH v1 32/52] NFSD: Add nfsd4_encode_fattr4_owner_group() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:00:11 -0400 Message-ID: <169504561180.133720.5689851436829082956.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_OWNER_GROUP 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 11922b18f357..91ac991dea9d 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3200,6 +3200,12 @@ static __be32 nfsd4_encode_fattr4_owner(struct xdr_stream *xdr, return nfsd4_encode_user(xdr, args->rqstp, args->stat.uid); } +static __be32 nfsd4_encode_fattr4_owner_group(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_group(xdr, args->rqstp, args->stat.gid); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3494,8 +3500,8 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_OWNER_GROUP) { - status = nfsd4_encode_group(xdr, rqstp, args.stat.gid); - if (status) + status = nfsd4_encode_fattr4_owner_group(xdr, &args); + if (status != nfs_ok) goto out; } if (bmval1 & FATTR4_WORD1_RAWDEV) { From patchwork Mon Sep 18 14:00:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389827 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 249F2CD13D8 for ; Mon, 18 Sep 2023 15:25:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233417AbjIRPZb (ORCPT ); Mon, 18 Sep 2023 11:25:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234127AbjIRPZa (ORCPT ); Mon, 18 Sep 2023 11:25:30 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 209A510B for ; Mon, 18 Sep 2023 08:22:37 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FBEBC116B7; Mon, 18 Sep 2023 14:00:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045619; bh=neirfrnQbQuonWQbTaGfXOUbDRFNitlMukdByJdYq/M=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=OK7D7e1hTzAvjwhRoWXb3Zj5GPgCbxRyLT1ZvJYooS5/H1B51DsoXE11Dx3nQxHcE E0AneDJ/+31sI6LbTlIN7X2NjQ/pzsCdR9c4BowABZSEsrVLkJBkJlCAi949iILqnG 013fJrmRdsp3+eb6wWlnhAu3FtzOU1LHFS9yMRLr2JWZ1RUP/YwZIeoxUAvHAbdI9E J6IkA9hbVEXMK9LuQHpb3nKMvo3nNf6J7wKXdZ5DFIsVGSI7rAuuwX/sPWjt8Jz575 dn81D9R0YITA2kltBKVjrY6+xCxILF3ChXf2u3bi+PQntPXHItJT6CHoOM64yn7DzA ExgqfOAZnxp2g== Subject: [PATCH v1 33/52] NFSD: Add nfsd4_encode_fattr4_rawdev() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:00:18 -0400 Message-ID: <169504561813.133720.13629335937477563549.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_RAWDEV 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 | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 91ac991dea9d..146ac641ef8e 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2550,6 +2550,17 @@ static __be32 nfsd4_encode_nfstime4(struct xdr_stream *xdr, return nfs_ok; } +static __be32 nfsd4_encode_specdata4(struct xdr_stream *xdr, + unsigned int major, unsigned int minor) +{ + __be32 status; + + status = nfsd4_encode_uint32_t(xdr, major); + if (status != nfs_ok) + return status; + return nfsd4_encode_uint32_t(xdr, minor); +} + /* * ctime (in NFSv4, time_metadata) is not writeable, and the client * doesn't really care what resolution could theoretically be stored by @@ -3206,6 +3217,13 @@ static __be32 nfsd4_encode_fattr4_owner_group(struct xdr_stream *xdr, return nfsd4_encode_group(xdr, args->rqstp, args->stat.gid); } +static __be32 nfsd4_encode_fattr4_rawdev(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_specdata4(xdr, MAJOR(args->stat.rdev), + MINOR(args->stat.rdev)); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3505,11 +3523,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_RAWDEV) { - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - *p++ = cpu_to_be32((u32) MAJOR(args.stat.rdev)); - *p++ = cpu_to_be32((u32) MINOR(args.stat.rdev)); + status = nfsd4_encode_fattr4_rawdev(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval1 & FATTR4_WORD1_SPACE_AVAIL) { p = xdr_reserve_space(xdr, 8); From patchwork Mon Sep 18 14:00:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389804 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 1517ACD13D9 for ; Mon, 18 Sep 2023 15:22:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239775AbjIRPWX (ORCPT ); Mon, 18 Sep 2023 11:22:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238605AbjIRPWU (ORCPT ); Mon, 18 Sep 2023 11:22:20 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1ED010C8 for ; Mon, 18 Sep 2023 08:20:11 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6EC31C116B6; Mon, 18 Sep 2023 14:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045625; bh=7UlAzVQCyxw8WrqdUycPn4PtvnvgbPr9juX8TTFC9yQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=c6+O4KNDhABNHF/eQlcFOsP+cQ7QPxyhl8yxVjQlU45V4cuO/rHgbursDcpp/J+rD Gj5aKMbV6FKgRcvN8/WQQkFQ4a48fE4v22fA6yRy75eisHarhZ+BSJ81GeDCqfgQrs iEKpblDWivyaCbNr7KXwXQY/dB6s9Hw1eMOGrakriTch4eQ4Ki5b1DTYnu1If8hC+n m9cC5RAhcg7DdxN2qpQ/8CRdBEeHI/OwMH5C7hREmR5tOeR7NmUVGoaw1LGS3Mm6n8 n6NiBj42ZhYOjmcjOhaDbjscUWBuwcQNufydTTnt8wTD9nuzbKvFdKUK2bEYJqEsMs M4MwqPMTrpyHw== Subject: [PATCH v1 34/52] NFSD: Add nfsd4_encode_fattr4_space_avail() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:00:24 -0400 Message-ID: <169504562450.133720.15612884724683454845.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_SPACE_AVAIL 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 146ac641ef8e..42ce95b8db43 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3224,6 +3224,14 @@ static __be32 nfsd4_encode_fattr4_rawdev(struct xdr_stream *xdr, MINOR(args->stat.rdev)); } +static __be32 nfsd4_encode_fattr4_space_avail(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + u64 avail = (u64)args->statfs.f_bavail * (u64)args->statfs.f_bsize; + + return nfsd4_encode_uint64_t(xdr, avail); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3528,11 +3536,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_SPACE_AVAIL) { - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - dummy64 = (u64)args.statfs.f_bavail * (u64)args.statfs.f_bsize; - p = xdr_encode_hyper(p, dummy64); + status = nfsd4_encode_fattr4_space_avail(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval1 & FATTR4_WORD1_SPACE_FREE) { p = xdr_reserve_space(xdr, 8); From patchwork Mon Sep 18 14:00:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389829 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 A9FBECD37B0 for ; Mon, 18 Sep 2023 15:25:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230303AbjIRPZk (ORCPT ); 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 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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); From patchwork Mon Sep 18 14:00:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389799 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 729A9C46CA1 for ; Mon, 18 Sep 2023 15:20:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231171AbjIRPUR (ORCPT ); Mon, 18 Sep 2023 11:20:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229816AbjIRPUQ (ORCPT ); Mon, 18 Sep 2023 11:20:16 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03EF3E75 for ; Mon, 18 Sep 2023 08:18:39 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3AA57C116B9; Mon, 18 Sep 2023 14:00:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045638; bh=hmYbnv+NI+RmySPbTF73qcSDypUOl0VihBv0TCZ4oC0=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=BVegSLdbiUZNX1twat76tJpS7wibnYDQW4+k5DdcvlPkH80SbP6GecyzpKUYo6E3p DQ9T1M+jU2vqvsBHIB3TiuWXiDibCgV4f/63zpwMncnfHrcjG76O5Wf0O5DZMlIES/ yNuDx/dQbKPZYQEp0gRYEYqqYKfRS4s313DQot3vXe4H19AKgHfClQo1sW2p9zri2S b2ejjmCufYfZzXBXtDnsybE5e1uUyQrz2iqumKCO3lHIKe+xkHKQZE3Q8Wjxstpegc v+keAYaK7btp5RY2G6J73W6HHwXW90u7aPFfzUtSxiR6wDtKHAwEz6zcha200s6z/d 3ES5Zvee75bpg== Subject: [PATCH v1 36/52] NFSD: Add nfsd4_encode_fattr4_space_total() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:00:37 -0400 Message-ID: <169504563722.133720.16090756244061462044.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_SPACE_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 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index a9f99f07c904..963fa2ccadd7 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3240,6 +3240,14 @@ static __be32 nfsd4_encode_fattr4_space_free(struct xdr_stream *xdr, return nfsd4_encode_uint64_t(xdr, free); } +static __be32 nfsd4_encode_fattr4_space_total(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + u64 total = (u64)args->statfs.f_blocks * (u64)args->statfs.f_bsize; + + return nfsd4_encode_uint64_t(xdr, total); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3554,11 +3562,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_SPACE_TOTAL) { - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - dummy64 = (u64)args.statfs.f_blocks * (u64)args.statfs.f_bsize; - p = xdr_encode_hyper(p, dummy64); + status = nfsd4_encode_fattr4_space_total(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval1 & FATTR4_WORD1_SPACE_USED) { p = xdr_reserve_space(xdr, 8); From patchwork Mon Sep 18 14:00:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13390070 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 28458C46CA1 for ; Mon, 18 Sep 2023 16:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229940AbjIRQhR (ORCPT ); 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 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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); From patchwork Mon Sep 18 14:00:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389831 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 E1110CD37B0 for ; Mon, 18 Sep 2023 15:25:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230100AbjIRP0D (ORCPT ); Mon, 18 Sep 2023 11:26:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234811AbjIRPZ6 (ORCPT ); Mon, 18 Sep 2023 11:25:58 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A49F81726 for ; Mon, 18 Sep 2023 08:23:06 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16313C116C9; Mon, 18 Sep 2023 14:00:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045651; bh=8ts/dGfDn9e/PDy01qBGBPy53p+fSvaXqXeGiNNYM78=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=DW9UwFdd6mCeMb6tdVFE+1UmGSVR35WtBr0MGaajDA+N4NzDLMAEd40Gqs+n+FwhR /OB5nm5QcVmimNv73A10Iz6Gl72uui4C/S31HscTpFmvEoofAIDUPgBmLhGwwvxXp3 pktPiwe3RPir4AR88hsdaPZaBAYohMg+CJiGMNwSl11wqUsXt25oN4X1SpuvKYkpGb nL05rh6YYsEBVJ6lKgCB18t9maP7hY3FFdJMq6HZQnwfFQGZh+JQd7fb7HpOYPWPSP s+hY78MboRYBWPYFn8mLXY+gl4x0v50GTxgCCFAnL+N0fVJfe3UsOdgcpotSAbqzRP eU5Kobg6/gM1w== Subject: [PATCH v1 38/52] NFSD: Add nfsd4_encode_fattr4_time_access() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:00:50 -0400 Message-ID: <169504565001.133720.3671879742657326384.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_TIME_ACCESS 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 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 80be20217402..214e2fdcbd89 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2536,16 +2536,16 @@ static __be32 nfsd4_encode_nfs_fh4(struct xdr_stream *xdr, return nfsd4_encode_opaque(xdr, fh_handle->fh_raw, fh_handle->fh_size); } +/* This is a frequently-encoded type; open-coded for speed */ static __be32 nfsd4_encode_nfstime4(struct xdr_stream *xdr, - struct timespec64 *tv) + const struct timespec64 *tv) { __be32 *p; p = xdr_reserve_space(xdr, XDR_UNIT * 3); if (!p) return nfserr_resource; - - p = xdr_encode_hyper(p, (s64)tv->tv_sec); + p = xdr_encode_hyper(p, tv->tv_sec); *p = cpu_to_be32(tv->tv_nsec); return nfs_ok; } @@ -3254,6 +3254,12 @@ static __be32 nfsd4_encode_fattr4_space_used(struct xdr_stream *xdr, return nfsd4_encode_uint64_t(xdr, (u64)args->stat.blocks << 9); } +static __be32 nfsd4_encode_fattr4_time_access(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_nfstime4(xdr, &args->stat.atime); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3577,7 +3583,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_TIME_ACCESS) { - status = nfsd4_encode_nfstime4(xdr, &args.stat.atime); + status = nfsd4_encode_fattr4_time_access(xdr, &args); if (status) goto out; } From patchwork Mon Sep 18 14:00:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389825 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 6005DC46CA1 for ; Mon, 18 Sep 2023 15:25:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235107AbjIRPZa (ORCPT ); Mon, 18 Sep 2023 11:25:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234376AbjIRPZ0 (ORCPT ); Mon, 18 Sep 2023 11:25:26 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45324E5F for ; Mon, 18 Sep 2023 08:22:15 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 724FDC116CA; Mon, 18 Sep 2023 14:00:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045657; bh=PM4YplbX7xYRY5Wfe94JDDlv5/9Zg7S4w6N+tWUQf8U=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ndsDrwOjVQHHTEEtXr7Os7jCdpB0pJngw84gfV+hjLZ+M24YVmMbNLpIgBpmg7m0E ElyNzw/lvkKun1kNnc1VrA6TtjJBeujCKACiB6CmvXkrOO5bmDeh7nOX5rUqbcsv+I CqgByY8Zq7SYy1P7cOO7MTSXg9faUA5oCFQ121PZkEtXSLM/jPudcuWHEXcPwv26y/ m7SqFcQfE3UhZOtQd8wUJSDP1UDqxdtQlqPDflLYd3Zy49+CKYbDFkKd+eidQp8D0F M7Ekb4YdKQYirgVgPvt27jnWxsxqj9h7/FgqQkcRzq1nPIyoUQK28gdW7r0avAa62c L4qpzuV/PADRQ== Subject: [PATCH v1 39/52] NFSD: Add nfsd4_encode_fattr4_time_create() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:00:56 -0400 Message-ID: <169504565646.133720.8387408052195832855.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_TIME_CREATE 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 214e2fdcbd89..5a98dc3910ef 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3260,6 +3260,12 @@ static __be32 nfsd4_encode_fattr4_time_access(struct xdr_stream *xdr, return nfsd4_encode_nfstime4(xdr, &args->stat.atime); } +static __be32 nfsd4_encode_fattr4_time_create(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_nfstime4(xdr, &args->stat.btime); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3588,7 +3594,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_TIME_CREATE) { - status = nfsd4_encode_nfstime4(xdr, &args.stat.btime); + status = nfsd4_encode_fattr4_time_create(xdr, &args); if (status) goto out; } From patchwork Mon Sep 18 14:01:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13390072 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 D3DE0CD13D9 for ; Mon, 18 Sep 2023 16:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230059AbjIRQhS (ORCPT ); Mon, 18 Sep 2023 12:37:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230139AbjIRQhG (ORCPT ); Mon, 18 Sep 2023 12:37:06 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF05410E6 for ; Mon, 18 Sep 2023 09:32:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3DD7C116CB; Mon, 18 Sep 2023 14:01:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045664; bh=eLAMI+04+0pa1jhKRCTkyUFIbNQssVlNGe8wkM70w3g=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=SvF5H5sBS/U6/neWupfecms+heNrLq+vlIQ62eIz/ekz2T7nzD/jV3zL3klJGk3YJ wR3LLvGRgScHHjt6g88SDIHCEujS0fmvJ5l3YRUFxnooWikSxA0Vz4XkM09ezd+yix IOvyydD0xp6l7EhksOtTf2PrgzVHVvdyKBxKxeegU9v6mLFqSi9gUhsk0kopkveB6r 7On81Rx131YEesaGc7gEoc40Ds0DMekJKPJ/OydP3/bS+e/vsyx1V7M84wUR7e+yRv h3Nv3Vc6jKdFkFslAHQu9MUfa4UxDasQUltykNFjujGISLwYcBkSlWUqhCxblj5XNc 6ZVVhFie1r3Jg== Subject: [PATCH v1 40/52] NFSD: Add nfsd4_encode_fattr4_time_delta() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:01:02 -0400 Message-ID: <169504566285.133720.8429913510077918237.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_TIME_DELTA into a helper. In a subsequent patch, this helper will be called from a bitmask loop. fattr4_time_delta is specified as an nfstime4, so de-duplicate this encoder. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 53 ++++++++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 5a98dc3910ef..28eb777f82d2 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2561,31 +2561,6 @@ static __be32 nfsd4_encode_specdata4(struct xdr_stream *xdr, return nfsd4_encode_uint32_t(xdr, minor); } -/* - * ctime (in NFSv4, time_metadata) is not writeable, and the client - * doesn't really care what resolution could theoretically be stored by - * the filesystem. - * - * The client cares how close together changes can be while still - * guaranteeing ctime changes. For most filesystems (which have - * timestamps with nanosecond fields) that is limited by the resolution - * of the time returned from current_time() (which I'm assuming to be - * 1/HZ). - */ -static __be32 *encode_time_delta(__be32 *p, struct inode *inode) -{ - struct timespec64 ts; - u32 ns; - - ns = max_t(u32, NSEC_PER_SEC/HZ, inode->i_sb->s_time_gran); - ts = ns_to_timespec64(ns); - - p = xdr_encode_hyper(p, ts.tv_sec); - *p++ = cpu_to_be32(ts.tv_nsec); - - return p; -} - static __be32 nfsd4_encode_change_info4(struct xdr_stream *xdr, const struct nfsd4_change_info *c) { @@ -3266,6 +3241,27 @@ static __be32 nfsd4_encode_fattr4_time_create(struct xdr_stream *xdr, return nfsd4_encode_nfstime4(xdr, &args->stat.btime); } +/* + * ctime (in NFSv4, time_metadata) is not writeable, and the client + * doesn't really care what resolution could theoretically be stored by + * the filesystem. + * + * The client cares how close together changes can be while still + * guaranteeing ctime changes. For most filesystems (which have + * timestamps with nanosecond fields) that is limited by the resolution + * of the time returned from current_time() (which I'm assuming to be + * 1/HZ). + */ +static __be32 nfsd4_encode_fattr4_time_delta(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + const struct inode *inode = d_inode(args->dentry); + u32 ns = max_t(u32, NSEC_PER_SEC/HZ, inode->i_sb->s_time_gran); + struct timespec64 ts = ns_to_timespec64(ns); + + return nfsd4_encode_nfstime4(xdr, &ts); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3599,10 +3595,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_TIME_DELTA) { - p = xdr_reserve_space(xdr, 12); - if (!p) - goto out_resource; - p = encode_time_delta(p, d_inode(dentry)); + status = nfsd4_encode_fattr4_time_delta(xdr, &args); + if (status != nfs_ok) + goto out; } if (bmval1 & FATTR4_WORD1_TIME_METADATA) { status = nfsd4_encode_nfstime4(xdr, &args.stat.ctime); From patchwork Mon Sep 18 14:01:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389838 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 E81BCCD37B0 for ; Mon, 18 Sep 2023 15:28:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229452AbjIRP2W (ORCPT ); Mon, 18 Sep 2023 11:28:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbjIRP15 (ORCPT ); Mon, 18 Sep 2023 11:27:57 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25BAEE78 for ; Mon, 18 Sep 2023 08:25:03 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CDB2C116D2; Mon, 18 Sep 2023 14:01:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045670; bh=vVxaXwBNqYVp9Tr8tf6Zt/VPqh7Mco63r7P50T5BHO4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=HXUiK6m2/qU9FWltAY3JeohlqlmO7oY3ygZ1wPDDSfJP/WxuU4cWGMR0OPuowcwBi fuEmxvegQ96SqJEWv93O7jyRlRoZ84cXBRNRw71lG/H31im5r/aZRUtaWdlonaFE/R bjLcOb5K4wGV/HWtanomxNpym7PJYQDqdvDgHJisG/mt6gmdmKT8Cm3EtO/7Vl32vH 9HQTMGQfyyrYqX/qqPPwwL1x836klCJ3xSTiqBQL1OpjnoLJmhGIYKGHXTrgfcG/I9 uL/+AGam/jmMkbDd1fD3HNZ+ow8Q+S/W1eKhan8Hf/hMtxLGkX1RX53xrE5OVTjATY DdHklYZgHGKCg== Subject: [PATCH v1 41/52] NFSD: Add nfsd4_encode_fattr4_time_metadata() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:01:09 -0400 Message-ID: <169504566918.133720.1802016538751714347.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_TIME_METADATA 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 28eb777f82d2..75121b4a6020 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3262,6 +3262,12 @@ static __be32 nfsd4_encode_fattr4_time_delta(struct xdr_stream *xdr, return nfsd4_encode_nfstime4(xdr, &ts); } +static __be32 nfsd4_encode_fattr4_time_metadata(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_nfstime4(xdr, &args->stat.ctime); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3600,7 +3606,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_TIME_METADATA) { - status = nfsd4_encode_nfstime4(xdr, &args.stat.ctime); + status = nfsd4_encode_fattr4_time_metadata(xdr, &args); if (status) goto out; } From patchwork Mon Sep 18 14:01:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389816 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 0ECDBC46CA1 for ; Mon, 18 Sep 2023 15:24:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240762AbjIRPYS (ORCPT ); Mon, 18 Sep 2023 11:24:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241004AbjIRPYQ (ORCPT ); Mon, 18 Sep 2023 11:24:16 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36E78BA for ; Mon, 18 Sep 2023 08:22:36 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 773A7C116D3; Mon, 18 Sep 2023 14:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045676; bh=7T/ahaIQ40lO0iadikPZJwQTz6UCKqt6StYeT1YAY9c=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=BnyKX4ZJW2VfzBToga9cZ7p1Sz+8NcuVdMPhJzIo4bhIGw4Nq80UhbUq5F9Muq2Ol lEutkaxaFT3LKJTtb7wxF7nlCZ7MqmEVK5/r71/XsxjbbhKK8tnKz3zE5UOmdZdSKP YL7vNmAq6w6wvV36dD3HDpVKjTvfMAfB1OZgdXb8xebTa5qFrFfbulHIZRStlbgqlB RqkPf+lBFjRwLaJUoEjPVhEG5eRk6Uwqun/y7/eNghXMo5cuc+or9yq/kHZS6DHtvN kJnicJ0fMmTS+tTR91IQw4M7Fc6Opluj5fcv5k+niBgVA8jhKzA7vS0a//1L9E0rk6 lsjV0AIrlCalg== Subject: [PATCH v1 42/52] NFSD: Add nfsd4_encode_fattr4_time_modify() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:01:15 -0400 Message-ID: <169504567550.133720.11907611503992862711.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_TIME_MODIFY 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 75121b4a6020..730596c53258 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3268,6 +3268,12 @@ static __be32 nfsd4_encode_fattr4_time_metadata(struct xdr_stream *xdr, return nfsd4_encode_nfstime4(xdr, &args->stat.ctime); } +static __be32 nfsd4_encode_fattr4_time_modify(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_nfstime4(xdr, &args->stat.mtime); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3611,7 +3617,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_TIME_MODIFY) { - status = nfsd4_encode_nfstime4(xdr, &args.stat.mtime); + status = nfsd4_encode_fattr4_time_modify(xdr, &args); if (status) goto out; } From patchwork Mon Sep 18 14:01:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389830 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 9DFC1CD37B0 for ; Mon, 18 Sep 2023 15:25:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234376AbjIRPZn (ORCPT ); Mon, 18 Sep 2023 11:25:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232935AbjIRPZm (ORCPT ); Mon, 18 Sep 2023 11:25:42 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC3ECEA for ; Mon, 18 Sep 2023 08:24:00 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C832DC116D4; Mon, 18 Sep 2023 14:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045683; bh=J3LpBgaMi3k7+6kgzaZ4NJOFtzEpmNGp6BzTjh0Ny9w=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=qxRxBMCkECQgoQsoUa3S7JKgOlSkgFkpXWxNu7yh5H52bOKkEiGpOYy/5QL7XvjiW Sj6bDu/WCv7taJCV14VwRY+Pex6Y7V4rvp5mvLY0OGbZEA/WVpapivW8UwiUrJgRMW QGF2JO71omO7+FlYLXZCytlfPhDE30FAQcqZtJtrWRN6tqxzp8OZlarqzPXXohN5UU n05Rul3bKtSPb8sHqy/ZD9w2FEMY24lPEIaq+IhoIShH5mQe4dRnM95sQtYKg3F/Uw tvbThu4G6Xw6tWeuYcDk9HUyZxz5DWbBBUhuw8M/xiZtQGR9ItFD3ujmiARwO87oVy PE/Xv6q5D0uSg== Subject: [PATCH v1 43/52] NFSD: Add nfsd4_encode_fattr4_mounted_on_fileid() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:01:21 -0400 Message-ID: <169504568186.133720.2744006796725296542.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_MOUNTED_ON_FILEID 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 | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 730596c53258..929be84482b9 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2914,6 +2914,7 @@ struct nfsd4_fattr_args { struct nfs4_acl *acl; u32 rdattr_err; bool contextsupport; + bool ignore_crossmnt; }; static __be32 nfsd4_encode_fattr4__true(struct xdr_stream *xdr, @@ -3274,6 +3275,23 @@ static __be32 nfsd4_encode_fattr4_time_modify(struct xdr_stream *xdr, return nfsd4_encode_nfstime4(xdr, &args->stat.mtime); } +static __be32 nfsd4_encode_fattr4_mounted_on_fileid(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + u64 ino; + int err; + + if (!args->ignore_crossmnt && + args->dentry == args->exp->ex_path.mnt->mnt_root) { + err = nfsd4_get_mounted_on_ino(args->exp, &ino); + if (err) + return nfserrno(err); + } else + ino = args->stat.ino; + + return nfsd4_encode_uint64_t(xdr, ino); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3311,6 +3329,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, args.rqstp = rqstp; args.exp = exp; args.dentry = dentry; + args.ignore_crossmnt = (ignore_crossmnt != 0); args.rdattr_err = 0; if (exp->ex_fslocs.migrated) { @@ -3622,23 +3641,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) { - u64 ino = args.stat.ino; - - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - /* - * Get ino of mountpoint in parent filesystem, if not ignoring - * crossmount and this is the root of a cross-mounted - * filesystem. - */ - if (ignore_crossmnt == 0 && - dentry == exp->ex_path.mnt->mnt_root) { - err = nfsd4_get_mounted_on_ino(exp, &ino); - if (err) - goto out_nfserr; - } - p = xdr_encode_hyper(p, ino); + status = nfsd4_encode_fattr4_mounted_on_fileid(xdr, &args); + if (status != nfs_ok) + goto out; } #ifdef CONFIG_NFSD_PNFS if (bmval1 & FATTR4_WORD1_FS_LAYOUT_TYPES) { From patchwork Mon Sep 18 14:01:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389834 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 139E8CD37B0 for ; Mon, 18 Sep 2023 15:26:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236565AbjIRP0g (ORCPT ); Mon, 18 Sep 2023 11:26:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233190AbjIRP0e (ORCPT ); Mon, 18 Sep 2023 11:26:34 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2E479D for ; Mon, 18 Sep 2023 08:23:45 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26911C116D5; Mon, 18 Sep 2023 14:01:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045689; bh=LKBwjOs5grznuP43WvwJlJfLxSIlS02lg4NcoKyC+TA=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=S3T+xOqY2NM2QCbUSr0n6i3evymGAuXxcZdBZsSCPgwhokl3EQ6gAO+m6GyvLS6Yc bwiajfhm7wR9enODPcJe4gp6/NsHZK8HOzWNXlrq2rCp11nt2rz0qUuNZObU9D/DP6 lxXJQUEi0P8zUcWnHVSXz5AvbYZ1GFF9GFQDA9HKsPE6iFnh2uIElee+0fZ7mGhtms Fb9TSpVe+gtK1YCEv4gN7gjiu5ae0UZxVxFGfBlCHNstYq3hLTBvTNLuihRkb1odVu tUq8AQnE+tLDHg/Mn2KmLmoRVvo+8dpfBhpmpVDMUZHAolkXyVuHeyqBvURXK7qBaG B4SQJYqptHf1g== Subject: [PATCH v1 44/52] NFSD: Add nfsd4_encode_fattr4_fs_layout_types() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:01:28 -0400 Message-ID: <169504568820.133720.7893935930026220174.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_FS_LAYOUT_TYPES 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 | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 929be84482b9..d67fa4b2a2f6 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3292,6 +3292,28 @@ static __be32 nfsd4_encode_fattr4_mounted_on_fileid(struct xdr_stream *xdr, return nfsd4_encode_uint64_t(xdr, ino); } +#ifdef CONFIG_NFSD_PNFS + +static __be32 nfsd4_encode_fattr4_fs_layout_types(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + unsigned long mask = args->exp->ex_layout_types; + int i; + + /* Hamming weight of @mask is the number of layout types to return */ + if (xdr_stream_encode_u32(xdr, hweight_long(mask)) != XDR_UNIT) + return nfserr_resource; + for (i = LAYOUT_NFSV4_1_FILES; i < LAYOUT_TYPE_MAX; ++i) + if (mask & BIT(i)) { + /* layouttype4 */ + if (xdr_stream_encode_u32(xdr, i) != XDR_UNIT) + return nfserr_resource; + } + return nfs_ok; +} + +#endif + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3647,7 +3669,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, } #ifdef CONFIG_NFSD_PNFS if (bmval1 & FATTR4_WORD1_FS_LAYOUT_TYPES) { - status = nfsd4_encode_layout_types(xdr, exp->ex_layout_types); + status = nfsd4_encode_fattr4_fs_layout_types(xdr, &args); if (status) goto out; } From patchwork Mon Sep 18 14:01:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389837 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 16B31C46CA1 for ; Mon, 18 Sep 2023 15:28:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229454AbjIRP1u (ORCPT ); Mon, 18 Sep 2023 11:27:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbjIRP1T (ORCPT ); Mon, 18 Sep 2023 11:27:19 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B02EE19BA for ; Mon, 18 Sep 2023 08:24:23 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CCE2C116D6; Mon, 18 Sep 2023 14:01:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045695; bh=E8m7IBAU38rUn/tzgzdGVKAGGb/FUXzES+W+Yuv2ErU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=b3SM/ChNoVguyh4RGdM3852LQuRWb0imjkWqYU+oMAio2xeoisKhEJZ+aU5+grLx1 +Mus/6EadyADISGbLDc71vJmvjwBnzzwwzTmWbLryNoFW5frxmrFir32XOqqu3W4UQ 7BlJ+cCh0GQVtBl0hGAB3/eL+oG5u3AOV0olrVNRCoRZUy4aFA9iShxUKs0DS98kCw HqJhOEvfwYNHS3qYHQZau3ZSrt9CNOSu387yl1BNBmJ4x5kY659BYskGfBCdC53Kpa 61iUq5x/1P60AltrRC5HLITGh40ewNpm1mfS1jXMs6KARwNe06Oevg9WI+mzkQ0Ltf Vk9gwzFGLFCNw== Subject: [PATCH v1 45/52] NFSD: Add nfsd4_encode_fattr4_layout_types() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:01:34 -0400 Message-ID: <169504569453.133720.12458816197833544713.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_LAYOUT_TYPES 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 | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index d67fa4b2a2f6..bc0b5bc3e655 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2784,25 +2784,6 @@ static __be32 nfsd4_encode_nfsace4(struct xdr_stream *xdr, struct svc_rqst *rqst return nfsd4_encode_user(xdr, rqstp, ace->who_uid); } -static inline __be32 -nfsd4_encode_layout_types(struct xdr_stream *xdr, u32 layout_types) -{ - __be32 *p; - unsigned long i = hweight_long(layout_types); - - p = xdr_reserve_space(xdr, 4 + 4 * i); - if (!p) - return nfserr_resource; - - *p++ = cpu_to_be32(i); - - for (i = LAYOUT_NFSV4_1_FILES; i < LAYOUT_TYPE_MAX; ++i) - if (layout_types & (1 << i)) - *p++ = cpu_to_be32(i); - - return 0; -} - #define WORD0_ABSENT_FS_ATTRS (FATTR4_WORD0_FS_LOCATIONS | FATTR4_WORD0_FSID | \ FATTR4_WORD0_RDATTR_ERROR) #define WORD1_ABSENT_FS_ATTRS FATTR4_WORD1_MOUNTED_ON_FILEID @@ -3312,6 +3293,24 @@ static __be32 nfsd4_encode_fattr4_fs_layout_types(struct xdr_stream *xdr, return nfs_ok; } +static __be32 nfsd4_encode_fattr4_layout_types(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + unsigned long mask = args->exp->ex_layout_types; + int i; + + /* Hamming weight of @mask is the number of layout types to return */ + if (xdr_stream_encode_u32(xdr, hweight_long(mask)) != XDR_UNIT) + return nfserr_resource; + for (i = LAYOUT_NFSV4_1_FILES; i < LAYOUT_TYPE_MAX; ++i) + if (mask & BIT(i)) { + /* layouttype4 */ + if (xdr_stream_encode_u32(xdr, i) != XDR_UNIT) + return nfserr_resource; + } + return nfs_ok; +} + #endif /* @@ -3675,7 +3674,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, } if (bmval2 & FATTR4_WORD2_LAYOUT_TYPES) { - status = nfsd4_encode_layout_types(xdr, exp->ex_layout_types); + status = nfsd4_encode_fattr4_layout_types(xdr, &args); if (status) goto out; } From patchwork Mon Sep 18 14:01:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389807 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 6E3C9CD13D2 for ; Mon, 18 Sep 2023 15:22:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234346AbjIRPWr (ORCPT ); Mon, 18 Sep 2023 11:22:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237604AbjIRPWq (ORCPT ); Mon, 18 Sep 2023 11:22:46 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 141B82708 for ; Mon, 18 Sep 2023 08:18:41 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3A7CC116D7; Mon, 18 Sep 2023 14:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045702; bh=9Uap5azBaIBKFC7HoUN000H7e4t+ppeDBbqeNKDYR/I=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=MlQuJdHUZgx7XwN/ET1AcDreILf9acW6gtFMPsxmkWcZAtmp7dx6iTohUelCldiZy EoF+3BWCUuQ6pqsD8W11ervbfvrBB6FPZ7pliCeyeKUEsfkv4DWPahxdHXfUVB065J Tt0JcaTKnFPLH26JL6yW5hApQ8CXP6aaBDCgNJ7XrO/MGcA5JdRDXqLuOu1tYQiAs+ fm29KanTDeedK8GbDhUC9oLy4QQyodKdljxxrV0DXz10qB6SmWcPxirS/Xr1Ewmzhx YnEA5rGcKuTp93nUeLyqxxeMiDvilcTiT+MB6jrgfo0lgQdDVj2g6TWJUpFIJuJzqp lBIdQ+6iIdoug== Subject: [PATCH v1 46/52] NFSD: Add nfsd4_encode_fattr4_layout_blksize() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:01:40 -0400 Message-ID: <169504570088.133720.70116052510788365.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_LAYOUT_BLKSIZE 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 bc0b5bc3e655..aca0301dc949 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3311,6 +3311,12 @@ static __be32 nfsd4_encode_fattr4_layout_types(struct xdr_stream *xdr, return nfs_ok; } +static __be32 nfsd4_encode_fattr4_layout_blksize(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_uint32_t(xdr, args->stat.blksize); +} + #endif /* @@ -3680,10 +3686,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, } if (bmval2 & FATTR4_WORD2_LAYOUT_BLKSIZE) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - *p++ = cpu_to_be32(args.stat.blksize); + status = nfsd4_encode_fattr4_layout_blksize(xdr, &args); + if (status != nfs_ok) + goto out; } #endif /* CONFIG_NFSD_PNFS */ if (bmval2 & FATTR4_WORD2_SUPPATTR_EXCLCREAT) { From patchwork Mon Sep 18 14:01:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389828 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 7EFDDC46CA1 for ; Mon, 18 Sep 2023 15:25:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229731AbjIRPZj (ORCPT ); Mon, 18 Sep 2023 11:25:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229594AbjIRPZj (ORCPT ); Mon, 18 Sep 2023 11:25:39 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF420112 for ; Mon, 18 Sep 2023 08:23:49 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AE35C16ABD; Mon, 18 Sep 2023 14:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045708; bh=8CPNAvxyxVIf7F9VE53I/wnnOhhBYNY6uynGY3wEaJ8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=kDQFiNm3y2s0C2V0eWQayIgKCwuLXHlmHYh+WOLCrbvXwIgvRLHnJMINyJirk2op8 +5jcAzlHX7qEGItH4SAW7iACWluBb91N3PQII73yGijIMsmdL1L8GHHoVGs6oUzDIF Uj9cxB6djweaKuqYoz2ODpXvpcMF9r3NL12uI9n3WNadOLB9k5vvWwO9bEUIAXZUQ8 eYRBRmsW6Jc68FLi2BQQ5p/smMYR0iMmrU77uN/+MiUud4zB2Q+UjfGOuR/pRBS6sw UMVooQXGOBbi9P9f6i9EV4kDlwwbk7sj4LpylXLJBnqt4IPWhxQOXbLDpe5dBko8oh /Id4w3SuPL/JQ== Subject: [PATCH v1 47/52] NFSD: Add nfsd4_encode_fattr4_suppattr_exclcreat() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:01:47 -0400 Message-ID: <169504570724.133720.15944434921909768890.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_SUPPATTR_EXCLCREAT 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 | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index aca0301dc949..02a28d07d6e4 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3319,6 +3319,20 @@ static __be32 nfsd4_encode_fattr4_layout_blksize(struct xdr_stream *xdr, #endif +static __be32 nfsd4_encode_fattr4_suppattr_exclcreat(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + struct nfsd4_compoundres *resp = args->rqstp->rq_resp; + u32 supp[3]; + + memcpy(supp, nfsd_suppattrs[resp->cstate.minorversion], sizeof(supp)); + supp[0] &= NFSD_SUPPATTR_EXCLCREAT_WORD0; + supp[1] &= NFSD_SUPPATTR_EXCLCREAT_WORD1; + supp[2] &= NFSD_SUPPATTR_EXCLCREAT_WORD2; + + 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. @@ -3692,14 +3706,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, } #endif /* CONFIG_NFSD_PNFS */ if (bmval2 & FATTR4_WORD2_SUPPATTR_EXCLCREAT) { - u32 supp[3]; - - memcpy(supp, nfsd_suppattrs[minorversion], sizeof(supp)); - supp[0] &= NFSD_SUPPATTR_EXCLCREAT_WORD0; - supp[1] &= NFSD_SUPPATTR_EXCLCREAT_WORD1; - supp[2] &= NFSD_SUPPATTR_EXCLCREAT_WORD2; - - status = nfsd4_encode_bitmap4(xdr, supp[0], supp[1], supp[2]); + status = nfsd4_encode_fattr4_suppattr_exclcreat(xdr, &args); if (status) goto out; } From patchwork Mon Sep 18 14:01:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389813 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 6BC0CCD13D9 for ; Mon, 18 Sep 2023 15:23:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240063AbjIRPX6 (ORCPT ); Mon, 18 Sep 2023 11:23:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240741AbjIRPXx (ORCPT ); Mon, 18 Sep 2023 11:23:53 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A5111A6 for ; Mon, 18 Sep 2023 08:20:14 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69037C32778; Mon, 18 Sep 2023 14:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045714; bh=QBNnRML3S6bGG3pfz5hCJOHDxJoyRg3wt3u2Fmuj6K0=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Ide9T8JKmXIDAf6LgMyl/CK9DWB7jE//EG1xrlnV4r9jZVkywousLHEYPmInwJ4Pr ABJ80VmDxOXAI7pWx/lnRjR8ZMwi47HpXBKTjKXmKviQ8Lt70NTCMQPScdfDWd4QVL pdUPfkYJ/5ZD+BSqBZdGNiJzjco2BRLd6+VqCsuIuOuBqlNJFbho1cSiZwXD4ju1nl Ym6yTOsjsOYZT1Pd3KgLf8z1j6fmAGvL8HEwaTL5tpIsbVqoC6t8m7x1qNIWW2/cpk dlaKMTINKelnJA9QSTXKnf+4AgA27rZqXGaIbMMT9iLJ8/4c1yW5KFXeVhHBztIAhp F9ItidsohkTRw== Subject: [PATCH v1 48/52] NFSD: Add nfsd4_encode_fattr4_sec_label() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:01:53 -0400 Message-ID: <169504571355.133720.18035352251995094063.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_SEC_LABEL 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 | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 02a28d07d6e4..137e7368dbfd 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2893,6 +2893,10 @@ struct nfsd4_fattr_args { struct kstat stat; struct kstatfs statfs; struct nfs4_acl *acl; +#ifdef CONFIG_NFSD_V4_SECURITY_LABEL + void *context; + int contextlen; +#endif u32 rdattr_err; bool contextsupport; bool ignore_crossmnt; @@ -3333,6 +3337,15 @@ static __be32 nfsd4_encode_fattr4_suppattr_exclcreat(struct xdr_stream *xdr, return nfsd4_encode_bitmap4(xdr, supp[0], supp[1], supp[2]); } +#ifdef CONFIG_NFSD_V4_SECURITY_LABEL +static __be32 nfsd4_encode_fattr4_sec_label(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfsd4_encode_security_label(xdr, args->rqstp, + args->context, args->contextlen); +} +#endif + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3353,10 +3366,6 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, int attrlen_offset; __be32 status; int err; -#ifdef CONFIG_NFSD_V4_SECURITY_LABEL - void *context = NULL; - int contextlen; -#endif struct nfsd4_compoundres *resp = rqstp->rq_resp; u32 minorversion = resp->cstate.minorversion; struct path path = { @@ -3430,11 +3439,12 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, args.contextsupport = false; #ifdef CONFIG_NFSD_V4_SECURITY_LABEL + args.context = NULL; if ((bmval2 & FATTR4_WORD2_SECURITY_LABEL) || bmval0 & FATTR4_WORD0_SUPPORTED_ATTRS) { if (exp->ex_flags & NFSEXP_SECURITY_LABEL) err = security_inode_getsecctx(d_inode(dentry), - &context, &contextlen); + &args.context, &args.contextlen); else err = -EOPNOTSUPP; args.contextsupport = (err == 0); @@ -3713,8 +3723,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, #ifdef CONFIG_NFSD_V4_SECURITY_LABEL if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) { - status = nfsd4_encode_security_label(xdr, rqstp, context, - contextlen); + status = nfsd4_encode_fattr4_sec_label(xdr, &args); if (status) goto out; } @@ -3733,8 +3742,8 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, out: #ifdef CONFIG_NFSD_V4_SECURITY_LABEL - if (context) - security_release_secctx(context, contextlen); + if (args.context) + security_release_secctx(args.context, args.contextlen); #endif /* CONFIG_NFSD_V4_SECURITY_LABEL */ kfree(args.acl); if (tempfh) { From patchwork Mon Sep 18 14:01:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389835 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 3C30CCD13D8 for ; Mon, 18 Sep 2023 15:26:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236845AbjIRP0g (ORCPT ); Mon, 18 Sep 2023 11:26:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234966AbjIRP0f (ORCPT ); Mon, 18 Sep 2023 11:26:35 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 082FECF7 for ; Mon, 18 Sep 2023 08:24:16 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE457C193E8; Mon, 18 Sep 2023 14:02:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045720; bh=4vsR15IVGU06iZtarv4SttIYOkjf26iIBQmJQ/9hrZU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=DPCFphlEmt/zQJYP6cM6jOcmMLgY6kbrSRLSmRlKFb9rFHc8FhDGMu/nOgU8p+r/q rWnsm7i4PDILNwIziGIVctw4Eb2UL53mvuq+7EjMn92sC2uCQg//9i4aweMTzENe0E vNycyVjdLOe4pgfIQl2yyiicC7ZovuzUd11OFz7jpTqRcKylvvaEwlZ379kyg1sazK ZciqqJbU4pUR0NpGMWujs8a2QzIyzZEYIMVj+Fm9jmacvgP8Yzk+vvI9qMlBHKiRlB i6AFtOZOJNNpBvijng2SB9ZsKCOz0jrkhzWxIw+GF0FmZ7jhVWZI0KVmqmnCxkfn1Z WM7cx9xazdDnA== Subject: [PATCH v1 49/52] NFSD: Add nfsd4_encode_fattr4_xattr_support() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:01:59 -0400 Message-ID: <169504571981.133720.8100882888549390817.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_XATTR_SUPPORT 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 | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 137e7368dbfd..97654a2b876f 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3346,6 +3346,14 @@ static __be32 nfsd4_encode_fattr4_sec_label(struct xdr_stream *xdr, } #endif +static __be32 nfsd4_encode_fattr4_xattr_support(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + int err = xattr_supports_user_prefix(d_inode(args->dentry)); + + return nfsd4_encode_bool(xdr, err == 0); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3361,10 +3369,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, u32 bmval1 = bmval[1]; u32 bmval2 = bmval[2]; struct svc_fh *tempfh = NULL; - __be32 *p, *attrlen_p; int starting_len = xdr->buf->len; + __be32 *attrlen_p, status; int attrlen_offset; - __be32 status; int err; struct nfsd4_compoundres *resp = rqstp->rq_resp; u32 minorversion = resp->cstate.minorversion; @@ -3730,11 +3737,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, #endif if (bmval2 & FATTR4_WORD2_XATTR_SUPPORT) { - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_resource; - err = xattr_supports_user_prefix(d_inode(dentry)); - *p++ = cpu_to_be32(err == 0); + status = nfsd4_encode_fattr4_xattr_support(xdr, &args); + if (status != nfs_ok) + goto out; } *attrlen_p = cpu_to_be32(xdr->buf->len - attrlen_offset - XDR_UNIT); From patchwork Mon Sep 18 14:02:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389818 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 124F3C46CA1 for ; Mon, 18 Sep 2023 15:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239938AbjIRPY0 (ORCPT ); Mon, 18 Sep 2023 11:24:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239996AbjIRPYZ (ORCPT ); Mon, 18 Sep 2023 11:24:25 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAA29109 for ; Mon, 18 Sep 2023 08:22:41 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11A0BC2BCFE; Mon, 18 Sep 2023 14:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045727; bh=BQefnBCIPeA85fMx0S7Kv++X5t/KtrIj+QjAcMjiXhk=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=HllNR+E/O8CzK2Hf/GuUEgdx4px16H56V00LPUgyBfLOCOt6XndmH+jep9uwZwbL5 0cm7li/M6cxtmddzTzq38CPnb+cn4a+RNNzgDgb1kVJefQthBIVZBEPhpU8qBw/KEf UshGdLLJaWu2xbPgamOoibHbYBUDZ5cr17OprTBcd4rACTaAMxNVv18Pn9Kz96aJZd YV/YmrpgTkZ/rii20ncN+pv/99nX3dBPORRKEKNUG+I8tXT/Ryuy8hxqN3cdnHP2Ud 2Ka75pPK984RJEfpE2c1WqdYk01mWnkCx58AVi3CQk+CCYFcokD/VklADWB1mS2wG9 Wgubl59Xo2t5A== Subject: [PATCH v1 50/52] NFSD: Copy FATTR4 bit number definitions from RFCs From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:02:06 -0400 Message-ID: <169504572609.133720.16474496647723355765.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 I'd like to convert nfsd4_encode_fattr() to rotate through the attrmask using for_each_bit() instead of explicitly testing the bitmask for each bit value. This means I need the bit numbers, as defined in the specs, instead of our internal bitmask constants. As a clean up, use the new spec-derived values to define the WORD# bitmask constants. Signed-off-by: Chuck Lever --- include/linux/nfs4.h | 260 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 192 insertions(+), 68 deletions(-) diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index 730003c4f4af..b23c193523c3 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -389,79 +389,203 @@ enum lock_type4 { NFS4_WRITEW_LT = 4 }; +/* + * Symbol names and values are from RFC 7531 Section 2. + * "XDR Description of NFSv4.0" + */ +enum { + FATTR4_SUPPORTED_ATTRS = 0, + FATTR4_TYPE = 1, + FATTR4_FH_EXPIRE_TYPE = 2, + FATTR4_CHANGE = 3, + FATTR4_SIZE = 4, + FATTR4_LINK_SUPPORT = 5, + FATTR4_SYMLINK_SUPPORT = 6, + FATTR4_NAMED_ATTR = 7, + FATTR4_FSID = 8, + FATTR4_UNIQUE_HANDLES = 9, + FATTR4_LEASE_TIME = 10, + FATTR4_RDATTR_ERROR = 11, + FATTR4_ACL = 12, + FATTR4_ACLSUPPORT = 13, + FATTR4_ARCHIVE = 14, + FATTR4_CANSETTIME = 15, + FATTR4_CASE_INSENSITIVE = 16, + FATTR4_CASE_PRESERVING = 17, + FATTR4_CHOWN_RESTRICTED = 18, + FATTR4_FILEHANDLE = 19, + FATTR4_FILEID = 20, + FATTR4_FILES_AVAIL = 21, + FATTR4_FILES_FREE = 22, + FATTR4_FILES_TOTAL = 23, + FATTR4_FS_LOCATIONS = 24, + FATTR4_HIDDEN = 25, + FATTR4_HOMOGENEOUS = 26, + FATTR4_MAXFILESIZE = 27, + FATTR4_MAXLINK = 28, + FATTR4_MAXNAME = 29, + FATTR4_MAXREAD = 30, + FATTR4_MAXWRITE = 31, + FATTR4_MIMETYPE = 32, + FATTR4_MODE = 33, + FATTR4_NO_TRUNC = 34, + FATTR4_NUMLINKS = 35, + FATTR4_OWNER = 36, + FATTR4_OWNER_GROUP = 37, + FATTR4_QUOTA_AVAIL_HARD = 38, + FATTR4_QUOTA_AVAIL_SOFT = 39, + FATTR4_QUOTA_USED = 40, + FATTR4_RAWDEV = 41, + FATTR4_SPACE_AVAIL = 42, + FATTR4_SPACE_FREE = 43, + FATTR4_SPACE_TOTAL = 44, + FATTR4_SPACE_USED = 45, + FATTR4_SYSTEM = 46, + FATTR4_TIME_ACCESS = 47, + FATTR4_TIME_ACCESS_SET = 48, + FATTR4_TIME_BACKUP = 49, + FATTR4_TIME_CREATE = 50, + FATTR4_TIME_DELTA = 51, + FATTR4_TIME_METADATA = 52, + FATTR4_TIME_MODIFY = 53, + FATTR4_TIME_MODIFY_SET = 54, + FATTR4_MOUNTED_ON_FILEID = 55, +}; + +/* + * Symbol names and values are from RFC 5662 Section 2. + * "XDR Description of NFSv4.1" + */ +enum { + FATTR4_DIR_NOTIF_DELAY = 56, + FATTR4_DIRENT_NOTIF_DELAY = 57, + FATTR4_DACL = 58, + FATTR4_SACL = 59, + FATTR4_CHANGE_POLICY = 60, + FATTR4_FS_STATUS = 61, + FATTR4_FS_LAYOUT_TYPES = 62, + FATTR4_LAYOUT_HINT = 63, + FATTR4_LAYOUT_TYPES = 64, + FATTR4_LAYOUT_BLKSIZE = 65, + FATTR4_LAYOUT_ALIGNMENT = 66, + FATTR4_FS_LOCATIONS_INFO = 67, + FATTR4_MDSTHRESHOLD = 68, + FATTR4_RETENTION_GET = 69, + FATTR4_RETENTION_SET = 70, + FATTR4_RETENTEVT_GET = 71, + FATTR4_RETENTEVT_SET = 72, + FATTR4_RETENTION_HOLD = 73, + FATTR4_MODE_SET_MASKED = 74, + FATTR4_SUPPATTR_EXCLCREAT = 75, + FATTR4_FS_CHARSET_CAP = 76, +}; + +/* + * Symbol names and values are from RFC 7863 Section 2. + * "XDR Description of NFSv4.2" + */ +enum { + FATTR4_CLONE_BLKSIZE = 77, + FATTR4_SPACE_FREED = 78, + FATTR4_CHANGE_ATTR_TYPE = 79, + FATTR4_SEC_LABEL = 80, +}; + +/* + * Symbol names and values are from RFC 8275 Section 5. + * "The mode_umask Attribute" + */ +enum { + FATTR4_MODE_UMASK = 81, +}; + +/* + * Symbol names and values are from RFC 8276 Section 8.6. + * "Numeric Values Assigned to Protocol Extensions" + */ +enum { + FATTR4_XATTR_SUPPORT = 82, +}; + +/* + * The following internal definitions enable processing the above + * attribute bits within 32-bit word boundaries. + */ /* Mandatory Attributes */ -#define FATTR4_WORD0_SUPPORTED_ATTRS (1UL << 0) -#define FATTR4_WORD0_TYPE (1UL << 1) -#define FATTR4_WORD0_FH_EXPIRE_TYPE (1UL << 2) -#define FATTR4_WORD0_CHANGE (1UL << 3) -#define FATTR4_WORD0_SIZE (1UL << 4) -#define FATTR4_WORD0_LINK_SUPPORT (1UL << 5) -#define FATTR4_WORD0_SYMLINK_SUPPORT (1UL << 6) -#define FATTR4_WORD0_NAMED_ATTR (1UL << 7) -#define FATTR4_WORD0_FSID (1UL << 8) -#define FATTR4_WORD0_UNIQUE_HANDLES (1UL << 9) -#define FATTR4_WORD0_LEASE_TIME (1UL << 10) -#define FATTR4_WORD0_RDATTR_ERROR (1UL << 11) +#define FATTR4_WORD0_SUPPORTED_ATTRS BIT(FATTR4_SUPPORTED_ATTRS) +#define FATTR4_WORD0_TYPE BIT(FATTR4_TYPE) +#define FATTR4_WORD0_FH_EXPIRE_TYPE BIT(FATTR4_FH_EXPIRE_TYPE) +#define FATTR4_WORD0_CHANGE BIT(FATTR4_CHANGE) +#define FATTR4_WORD0_SIZE BIT(FATTR4_SIZE) +#define FATTR4_WORD0_LINK_SUPPORT BIT(FATTR4_LINK_SUPPORT) +#define FATTR4_WORD0_SYMLINK_SUPPORT BIT(FATTR4_SYMLINK_SUPPORT) +#define FATTR4_WORD0_NAMED_ATTR BIT(FATTR4_NAMED_ATTR) +#define FATTR4_WORD0_FSID BIT(FATTR4_FSID) +#define FATTR4_WORD0_UNIQUE_HANDLES BIT(FATTR4_UNIQUE_HANDLES) +#define FATTR4_WORD0_LEASE_TIME BIT(FATTR4_LEASE_TIME) +#define FATTR4_WORD0_RDATTR_ERROR BIT(FATTR4_RDATTR_ERROR) /* Mandatory in NFSv4.1 */ -#define FATTR4_WORD2_SUPPATTR_EXCLCREAT (1UL << 11) +#define FATTR4_WORD2_SUPPATTR_EXCLCREAT BIT(FATTR4_SUPPATTR_EXCLCREAT - 64) /* Recommended Attributes */ -#define FATTR4_WORD0_ACL (1UL << 12) -#define FATTR4_WORD0_ACLSUPPORT (1UL << 13) -#define FATTR4_WORD0_ARCHIVE (1UL << 14) -#define FATTR4_WORD0_CANSETTIME (1UL << 15) -#define FATTR4_WORD0_CASE_INSENSITIVE (1UL << 16) -#define FATTR4_WORD0_CASE_PRESERVING (1UL << 17) -#define FATTR4_WORD0_CHOWN_RESTRICTED (1UL << 18) -#define FATTR4_WORD0_FILEHANDLE (1UL << 19) -#define FATTR4_WORD0_FILEID (1UL << 20) -#define FATTR4_WORD0_FILES_AVAIL (1UL << 21) -#define FATTR4_WORD0_FILES_FREE (1UL << 22) -#define FATTR4_WORD0_FILES_TOTAL (1UL << 23) -#define FATTR4_WORD0_FS_LOCATIONS (1UL << 24) -#define FATTR4_WORD0_HIDDEN (1UL << 25) -#define FATTR4_WORD0_HOMOGENEOUS (1UL << 26) -#define FATTR4_WORD0_MAXFILESIZE (1UL << 27) -#define FATTR4_WORD0_MAXLINK (1UL << 28) -#define FATTR4_WORD0_MAXNAME (1UL << 29) -#define FATTR4_WORD0_MAXREAD (1UL << 30) -#define FATTR4_WORD0_MAXWRITE (1UL << 31) -#define FATTR4_WORD1_MIMETYPE (1UL << 0) -#define FATTR4_WORD1_MODE (1UL << 1) -#define FATTR4_WORD1_NO_TRUNC (1UL << 2) -#define FATTR4_WORD1_NUMLINKS (1UL << 3) -#define FATTR4_WORD1_OWNER (1UL << 4) -#define FATTR4_WORD1_OWNER_GROUP (1UL << 5) -#define FATTR4_WORD1_QUOTA_HARD (1UL << 6) -#define FATTR4_WORD1_QUOTA_SOFT (1UL << 7) -#define FATTR4_WORD1_QUOTA_USED (1UL << 8) -#define FATTR4_WORD1_RAWDEV (1UL << 9) -#define FATTR4_WORD1_SPACE_AVAIL (1UL << 10) -#define FATTR4_WORD1_SPACE_FREE (1UL << 11) -#define FATTR4_WORD1_SPACE_TOTAL (1UL << 12) -#define FATTR4_WORD1_SPACE_USED (1UL << 13) -#define FATTR4_WORD1_SYSTEM (1UL << 14) -#define FATTR4_WORD1_TIME_ACCESS (1UL << 15) -#define FATTR4_WORD1_TIME_ACCESS_SET (1UL << 16) -#define FATTR4_WORD1_TIME_BACKUP (1UL << 17) -#define FATTR4_WORD1_TIME_CREATE (1UL << 18) -#define FATTR4_WORD1_TIME_DELTA (1UL << 19) -#define FATTR4_WORD1_TIME_METADATA (1UL << 20) -#define FATTR4_WORD1_TIME_MODIFY (1UL << 21) -#define FATTR4_WORD1_TIME_MODIFY_SET (1UL << 22) -#define FATTR4_WORD1_MOUNTED_ON_FILEID (1UL << 23) -#define FATTR4_WORD1_DACL (1UL << 26) -#define FATTR4_WORD1_SACL (1UL << 27) -#define FATTR4_WORD1_FS_LAYOUT_TYPES (1UL << 30) -#define FATTR4_WORD2_LAYOUT_TYPES (1UL << 0) -#define FATTR4_WORD2_LAYOUT_BLKSIZE (1UL << 1) -#define FATTR4_WORD2_MDSTHRESHOLD (1UL << 4) -#define FATTR4_WORD2_CLONE_BLKSIZE (1UL << 13) -#define FATTR4_WORD2_CHANGE_ATTR_TYPE (1UL << 15) -#define FATTR4_WORD2_SECURITY_LABEL (1UL << 16) -#define FATTR4_WORD2_MODE_UMASK (1UL << 17) -#define FATTR4_WORD2_XATTR_SUPPORT (1UL << 18) +#define FATTR4_WORD0_ACL BIT(FATTR4_ACL) +#define FATTR4_WORD0_ACLSUPPORT BIT(FATTR4_ACLSUPPORT) +#define FATTR4_WORD0_ARCHIVE BIT(FATTR4_ARCHIVE) +#define FATTR4_WORD0_CANSETTIME BIT(FATTR4_CANSETTIME) +#define FATTR4_WORD0_CASE_INSENSITIVE BIT(FATTR4_CASE_INSENSITIVE) +#define FATTR4_WORD0_CASE_PRESERVING BIT(FATTR4_CASE_PRESERVING) +#define FATTR4_WORD0_CHOWN_RESTRICTED BIT(FATTR4_CHOWN_RESTRICTED) +#define FATTR4_WORD0_FILEHANDLE BIT(FATTR4_FILEHANDLE) +#define FATTR4_WORD0_FILEID BIT(FATTR4_FILEID) +#define FATTR4_WORD0_FILES_AVAIL BIT(FATTR4_FILES_AVAIL) +#define FATTR4_WORD0_FILES_FREE BIT(FATTR4_FILES_FREE) +#define FATTR4_WORD0_FILES_TOTAL BIT(FATTR4_FILES_TOTAL) +#define FATTR4_WORD0_FS_LOCATIONS BIT(FATTR4_FS_LOCATIONS) +#define FATTR4_WORD0_HIDDEN BIT(FATTR4_HIDDEN) +#define FATTR4_WORD0_HOMOGENEOUS BIT(FATTR4_HOMOGENEOUS) +#define FATTR4_WORD0_MAXFILESIZE BIT(FATTR4_MAXFILESIZE) +#define FATTR4_WORD0_MAXLINK BIT(FATTR4_MAXLINK) +#define FATTR4_WORD0_MAXNAME BIT(FATTR4_MAXNAME) +#define FATTR4_WORD0_MAXREAD BIT(FATTR4_MAXREAD) +#define FATTR4_WORD0_MAXWRITE BIT(FATTR4_MAXWRITE) + +#define FATTR4_WORD1_MIMETYPE BIT(FATTR4_MIMETYPE - 32) +#define FATTR4_WORD1_MODE BIT(FATTR4_MODE - 32) +#define FATTR4_WORD1_NO_TRUNC BIT(FATTR4_NO_TRUNC - 32) +#define FATTR4_WORD1_NUMLINKS BIT(FATTR4_NUMLINKS - 32) +#define FATTR4_WORD1_OWNER BIT(FATTR4_OWNER - 32) +#define FATTR4_WORD1_OWNER_GROUP BIT(FATTR4_OWNER_GROUP - 32) +#define FATTR4_WORD1_QUOTA_HARD BIT(FATTR4_QUOTA_AVAIL_HARD - 32) +#define FATTR4_WORD1_QUOTA_SOFT BIT(FATTR4_QUOTA_AVAIL_SOFT - 32) +#define FATTR4_WORD1_QUOTA_USED BIT(FATTR4_QUOTA_USED - 32) +#define FATTR4_WORD1_RAWDEV BIT(FATTR4_RAWDEV - 32) +#define FATTR4_WORD1_SPACE_AVAIL BIT(FATTR4_SPACE_AVAIL - 32) +#define FATTR4_WORD1_SPACE_FREE BIT(FATTR4_SPACE_FREE - 32) +#define FATTR4_WORD1_SPACE_TOTAL BIT(FATTR4_SPACE_TOTAL - 32) +#define FATTR4_WORD1_SPACE_USED BIT(FATTR4_SPACE_USED - 32) +#define FATTR4_WORD1_SYSTEM BIT(FATTR4_SYSTEM - 32) +#define FATTR4_WORD1_TIME_ACCESS BIT(FATTR4_TIME_ACCESS - 32) +#define FATTR4_WORD1_TIME_ACCESS_SET BIT(FATTR4_TIME_ACCESS_SET - 32) +#define FATTR4_WORD1_TIME_BACKUP BIT(FATTR4_TIME_BACKUP - 32) +#define FATTR4_WORD1_TIME_CREATE BIT(FATTR4_TIME_CREATE - 32) +#define FATTR4_WORD1_TIME_DELTA BIT(FATTR4_TIME_DELTA - 32) +#define FATTR4_WORD1_TIME_METADATA BIT(FATTR4_TIME_METADATA - 32) +#define FATTR4_WORD1_TIME_MODIFY BIT(FATTR4_TIME_MODIFY - 32) +#define FATTR4_WORD1_TIME_MODIFY_SET BIT(FATTR4_TIME_MODIFY_SET - 32) +#define FATTR4_WORD1_MOUNTED_ON_FILEID BIT(FATTR4_MOUNTED_ON_FILEID - 32) +#define FATTR4_WORD1_DACL BIT(FATTR4_DACL - 32) +#define FATTR4_WORD1_SACL BIT(FATTR4_SACL - 32) +#define FATTR4_WORD1_FS_LAYOUT_TYPES BIT(FATTR4_FS_LAYOUT_TYPES - 32) + +#define FATTR4_WORD2_LAYOUT_TYPES BIT(FATTR4_LAYOUT_TYPES - 64) +#define FATTR4_WORD2_LAYOUT_BLKSIZE BIT(FATTR4_LAYOUT_BLKSIZE - 64) +#define FATTR4_WORD2_MDSTHRESHOLD BIT(FATTR4_MDSTHRESHOLD - 64) +#define FATTR4_WORD2_CLONE_BLKSIZE BIT(FATTR4_CLONE_BLKSIZE - 64) +#define FATTR4_WORD2_CHANGE_ATTR_TYPE BIT(FATTR4_CHANGE_ATTR_TYPE - 64) +#define FATTR4_WORD2_SECURITY_LABEL BIT(FATTR4_SEC_LABEL - 64) +#define FATTR4_WORD2_MODE_UMASK BIT(FATTR4_MODE_UMASK - 64) +#define FATTR4_WORD2_XATTR_SUPPORT BIT(FATTR4_XATTR_SUPPORT - 64) /* MDS threshold bitmap bits */ #define THRESHOLD_RD (1UL << 0) From patchwork Mon Sep 18 14:02:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389836 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 DD0E9CD37B0 for ; Mon, 18 Sep 2023 15:27:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229436AbjIRP1V (ORCPT ); Mon, 18 Sep 2023 11:27:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjIRP1L (ORCPT ); Mon, 18 Sep 2023 11:27:11 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02BEC19AD for ; Mon, 18 Sep 2023 08:24:22 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74D5EC32779; Mon, 18 Sep 2023 14:02:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045733; bh=IdTdyDpdBato/bTnTFqZ+mN7N2a+jtToSoHwzF6AAtI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=hY7takWeeRSEFHncg9ZFpl7VDNI4pRgWlK6nToGI/0eKf/CxcU9X9C7deHw0Z+Fjo 6kWeWkP/D4tuKVpZ4wSElLYXEjyi/9VKaB2xX7204GoPLXcnU+lj7N8BN5+ITevfLH UFWqaZS4O+oREYas83O+b4PJzhb/bp0HwUj6rc3M68UZesGR8Nq1G1PdHwxvE/cs8Q 2Al3ke30v06ZZTwgHY1WGZyBTNtjfJ1VeOfdbsRlILvMqwdg9a0TssBfnCEJQCJwQF 1NNdAPxLIZTWqPGUojp8fg6/kU3Ps/YNzZkik0iBC6LZoq9qvzBH7JdWLiMouSHeem OdzEvhwTmjFqw== Subject: [PATCH v1 51/52] NFSD: Use a bitmask loop to encode FATTR4 results From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:02:12 -0400 Message-ID: <169504573247.133720.11599512132060333899.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 The fattr4 encoder is now structured like the COMPOUND op encoder: one function for each individual attribute, called by bit number. Benefits include: - The individual attributes are now guaranteed to be encoded in bitmask order into the send buffer - There can be no unwanted side effects between attribute encoders - The code now clearly documents which attributes are /not/ implemented on this server Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 429 ++++++++++++++++++----------------------------------- 1 file changed, 142 insertions(+), 287 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 97654a2b876f..d7f690a3ea86 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2902,6 +2902,15 @@ struct nfsd4_fattr_args { bool ignore_crossmnt; }; +typedef __be32(*nfsd4_enc_attr)(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args); + +static __be32 nfsd4_encode_fattr4__noop(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + return nfs_ok; +} + static __be32 nfsd4_encode_fattr4__true(struct xdr_stream *xdr, const struct nfsd4_fattr_args *args) { @@ -3354,6 +3363,108 @@ static __be32 nfsd4_encode_fattr4_xattr_support(struct xdr_stream *xdr, return nfsd4_encode_bool(xdr, err == 0); } +static const nfsd4_enc_attr nfsd4_enc_fattr4_encode_ops[] = { + [FATTR4_SUPPORTED_ATTRS] = nfsd4_encode_fattr4_supported_attrs, + [FATTR4_TYPE] = nfsd4_encode_fattr4_type, + [FATTR4_FH_EXPIRE_TYPE] = nfsd4_encode_fattr4_fh_expire_type, + [FATTR4_CHANGE] = nfsd4_encode_fattr4_change, + [FATTR4_SIZE] = nfsd4_encode_fattr4_size, + [FATTR4_LINK_SUPPORT] = nfsd4_encode_fattr4__true, + [FATTR4_SYMLINK_SUPPORT] = nfsd4_encode_fattr4__true, + [FATTR4_NAMED_ATTR] = nfsd4_encode_fattr4__false, + [FATTR4_FSID] = nfsd4_encode_fattr4_fsid, + [FATTR4_UNIQUE_HANDLES] = nfsd4_encode_fattr4__true, + [FATTR4_LEASE_TIME] = nfsd4_encode_fattr4_lease_time, + [FATTR4_RDATTR_ERROR] = nfsd4_encode_fattr4_rdattr_error, + [FATTR4_ACL] = nfsd4_encode_fattr4_acl, + [FATTR4_ACLSUPPORT] = nfsd4_encode_fattr4_aclsupport, + [FATTR4_ARCHIVE] = nfsd4_encode_fattr4__noop, + [FATTR4_CANSETTIME] = nfsd4_encode_fattr4__true, + [FATTR4_CASE_INSENSITIVE] = nfsd4_encode_fattr4__false, + [FATTR4_CASE_PRESERVING] = nfsd4_encode_fattr4__true, + [FATTR4_CHOWN_RESTRICTED] = nfsd4_encode_fattr4__true, + [FATTR4_FILEHANDLE] = nfsd4_encode_fattr4_filehandle, + [FATTR4_FILEID] = nfsd4_encode_fattr4_fileid, + [FATTR4_FILES_AVAIL] = nfsd4_encode_fattr4_files_avail, + [FATTR4_FILES_FREE] = nfsd4_encode_fattr4_files_free, + [FATTR4_FILES_TOTAL] = nfsd4_encode_fattr4_files_total, + [FATTR4_FS_LOCATIONS] = nfsd4_encode_fattr4_fs_locations, + [FATTR4_HIDDEN] = nfsd4_encode_fattr4__noop, + [FATTR4_HOMOGENEOUS] = nfsd4_encode_fattr4__true, + [FATTR4_MAXFILESIZE] = nfsd4_encode_fattr4_maxfilesize, + [FATTR4_MAXLINK] = nfsd4_encode_fattr4_maxlink, + [FATTR4_MAXNAME] = nfsd4_encode_fattr4_maxname, + [FATTR4_MAXREAD] = nfsd4_encode_fattr4_maxread, + [FATTR4_MAXWRITE] = nfsd4_encode_fattr4_maxwrite, + [FATTR4_MIMETYPE] = nfsd4_encode_fattr4__noop, + [FATTR4_MODE] = nfsd4_encode_fattr4_mode, + [FATTR4_NO_TRUNC] = nfsd4_encode_fattr4__true, + [FATTR4_NUMLINKS] = nfsd4_encode_fattr4_numlinks, + [FATTR4_OWNER] = nfsd4_encode_fattr4_owner, + [FATTR4_OWNER_GROUP] = nfsd4_encode_fattr4_owner_group, + [FATTR4_QUOTA_AVAIL_HARD] = nfsd4_encode_fattr4__noop, + [FATTR4_QUOTA_AVAIL_SOFT] = nfsd4_encode_fattr4__noop, + [FATTR4_QUOTA_USED] = nfsd4_encode_fattr4__noop, + [FATTR4_RAWDEV] = nfsd4_encode_fattr4_rawdev, + [FATTR4_SPACE_AVAIL] = nfsd4_encode_fattr4_space_avail, + [FATTR4_SPACE_FREE] = nfsd4_encode_fattr4_space_free, + [FATTR4_SPACE_TOTAL] = nfsd4_encode_fattr4_space_total, + [FATTR4_SPACE_USED] = nfsd4_encode_fattr4_space_used, + [FATTR4_SYSTEM] = nfsd4_encode_fattr4__noop, + [FATTR4_TIME_ACCESS] = nfsd4_encode_fattr4_time_access, + [FATTR4_TIME_ACCESS_SET] = nfsd4_encode_fattr4__noop, + [FATTR4_TIME_BACKUP] = nfsd4_encode_fattr4__noop, + [FATTR4_TIME_CREATE] = nfsd4_encode_fattr4_time_create, + [FATTR4_TIME_DELTA] = nfsd4_encode_fattr4_time_delta, + [FATTR4_TIME_METADATA] = nfsd4_encode_fattr4_time_metadata, + [FATTR4_TIME_MODIFY] = nfsd4_encode_fattr4_time_modify, + [FATTR4_TIME_MODIFY_SET] = nfsd4_encode_fattr4__noop, + [FATTR4_MOUNTED_ON_FILEID] = nfsd4_encode_fattr4_mounted_on_fileid, + [FATTR4_DIR_NOTIF_DELAY] = nfsd4_encode_fattr4__noop, + [FATTR4_DIRENT_NOTIF_DELAY] = nfsd4_encode_fattr4__noop, + [FATTR4_DACL] = nfsd4_encode_fattr4__noop, + [FATTR4_SACL] = nfsd4_encode_fattr4__noop, + [FATTR4_CHANGE_POLICY] = nfsd4_encode_fattr4__noop, + [FATTR4_FS_STATUS] = nfsd4_encode_fattr4__noop, + +#ifdef CONFIG_NFSD_PNFS + [FATTR4_FS_LAYOUT_TYPES] = nfsd4_encode_fattr4_fs_layout_types, + [FATTR4_LAYOUT_HINT] = nfsd4_encode_fattr4__noop, + [FATTR4_LAYOUT_TYPES] = nfsd4_encode_fattr4_layout_types, + [FATTR4_LAYOUT_BLKSIZE] = nfsd4_encode_fattr4_layout_blksize, + [FATTR4_LAYOUT_ALIGNMENT] = nfsd4_encode_fattr4__noop, +#else + [FATTR4_FS_LAYOUT_TYPES] = nfsd4_encode_fattr4__noop, + [FATTR4_LAYOUT_HINT] = nfsd4_encode_fattr4__noop, + [FATTR4_LAYOUT_TYPES] = nfsd4_encode_fattr4__noop, + [FATTR4_LAYOUT_BLKSIZE] = nfsd4_encode_fattr4__noop, + [FATTR4_LAYOUT_ALIGNMENT] = nfsd4_encode_fattr4__noop, +#endif + + [FATTR4_FS_LOCATIONS_INFO] = nfsd4_encode_fattr4__noop, + [FATTR4_MDSTHRESHOLD] = nfsd4_encode_fattr4__noop, + [FATTR4_RETENTION_GET] = nfsd4_encode_fattr4__noop, + [FATTR4_RETENTION_SET] = nfsd4_encode_fattr4__noop, + [FATTR4_RETENTEVT_GET] = nfsd4_encode_fattr4__noop, + [FATTR4_RETENTEVT_SET] = nfsd4_encode_fattr4__noop, + [FATTR4_RETENTION_HOLD] = nfsd4_encode_fattr4__noop, + [FATTR4_MODE_SET_MASKED] = nfsd4_encode_fattr4__noop, + [FATTR4_SUPPATTR_EXCLCREAT] = nfsd4_encode_fattr4_suppattr_exclcreat, + [FATTR4_FS_CHARSET_CAP] = nfsd4_encode_fattr4__noop, + [FATTR4_CLONE_BLKSIZE] = nfsd4_encode_fattr4__noop, + [FATTR4_SPACE_FREED] = nfsd4_encode_fattr4__noop, + [FATTR4_CHANGE_ATTR_TYPE] = nfsd4_encode_fattr4__noop, + +#ifdef CONFIG_NFSD_V4_SECURITY_LABEL + [FATTR4_SEC_LABEL] = nfsd4_encode_fattr4_sec_label, +#else + [FATTR4_SEC_LABEL] = nfsd4_encode_fattr4__noop, +#endif + + [FATTR4_MODE_UMASK] = nfsd4_encode_fattr4__noop, + [FATTR4_XATTR_SUPPORT] = nfsd4_encode_fattr4_xattr_support, +}; + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3361,13 +3472,10 @@ static __be32 nfsd4_encode_fattr4_xattr_support(struct xdr_stream *xdr, static __be32 nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, struct svc_export *exp, - struct dentry *dentry, u32 *bmval, + struct dentry *dentry, const u32 *bmval, struct svc_rqst *rqstp, int ignore_crossmnt) { struct nfsd4_fattr_args args; - u32 bmval0 = bmval[0]; - u32 bmval1 = bmval[1]; - u32 bmval2 = bmval[2]; struct svc_fh *tempfh = NULL; int starting_len = xdr->buf->len; __be32 *attrlen_p, status; @@ -3379,23 +3487,32 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, .mnt = exp->ex_path.mnt, .dentry = dentry, }; + unsigned long bit, *mask; + u32 attrmask[3]; - BUG_ON(bmval1 & NFSD_WRITEONLY_ATTRS_WORD1); - BUG_ON(!nfsd_attrs_supported(minorversion, bmval)); + WARN_ON_ONCE(bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1); + WARN_ON_ONCE(!nfsd_attrs_supported(minorversion, bmval)); args.rqstp = rqstp; args.exp = exp; args.dentry = dentry; args.ignore_crossmnt = (ignore_crossmnt != 0); + /* + * Make a local copy of the attribute bitmap that can be modified. + */ + attrmask[0] = bmval[0]; + attrmask[1] = bmval[1]; + attrmask[2] = bmval[2]; + args.rdattr_err = 0; if (exp->ex_fslocs.migrated) { - status = fattr_handle_absent_fs(&bmval0, &bmval1, &bmval2, - &args.rdattr_err); + status = fattr_handle_absent_fs(&attrmask[0], &attrmask[1], + &attrmask[2], &args.rdattr_err); if (status) goto out; } - if (bmval0 & (FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE)) { + if (attrmask[0] & (FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE)) { status = nfsd4_deleg_getattr_conflict(rqstp, d_inode(dentry)); if (status) goto out; @@ -3409,16 +3526,17 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, if (!(args.stat.result_mask & STATX_BTIME)) /* underlying FS does not offer btime so we can't share it */ - bmval1 &= ~FATTR4_WORD1_TIME_CREATE; - if ((bmval0 & (FATTR4_WORD0_FILES_AVAIL | FATTR4_WORD0_FILES_FREE | + attrmask[1] &= ~FATTR4_WORD1_TIME_CREATE; + if ((attrmask[0] & (FATTR4_WORD0_FILES_AVAIL | FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_MAXNAME)) || - (bmval1 & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE | + (attrmask[1] & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE | FATTR4_WORD1_SPACE_TOTAL))) { err = vfs_statfs(&path, &args.statfs); if (err) goto out_nfserr; } - if ((bmval0 & (FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FSID)) && !fhp) { + if ((attrmask[0] & (FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FSID)) && + !fhp) { tempfh = kmalloc(sizeof(struct svc_fh), GFP_KERNEL); status = nfserr_jukebox; if (!tempfh) @@ -3432,10 +3550,10 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, args.fhp = fhp; args.acl = NULL; - if (bmval0 & FATTR4_WORD0_ACL) { + if (attrmask[0] & FATTR4_WORD0_ACL) { err = nfsd4_get_nfs4_acl(rqstp, dentry, &args.acl); if (err == -EOPNOTSUPP) - bmval0 &= ~FATTR4_WORD0_ACL; + attrmask[0] &= ~FATTR4_WORD0_ACL; else if (err == -EINVAL) { status = nfserr_attrnotsupp; goto out; @@ -3447,24 +3565,25 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, #ifdef CONFIG_NFSD_V4_SECURITY_LABEL args.context = NULL; - if ((bmval2 & FATTR4_WORD2_SECURITY_LABEL) || - bmval0 & FATTR4_WORD0_SUPPORTED_ATTRS) { + if ((attrmask[2] & FATTR4_WORD2_SECURITY_LABEL) || + attrmask[0] & FATTR4_WORD0_SUPPORTED_ATTRS) { if (exp->ex_flags & NFSEXP_SECURITY_LABEL) err = security_inode_getsecctx(d_inode(dentry), &args.context, &args.contextlen); else err = -EOPNOTSUPP; args.contextsupport = (err == 0); - if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) { + if (attrmask[2] & FATTR4_WORD2_SECURITY_LABEL) { if (err == -EOPNOTSUPP) - bmval2 &= ~FATTR4_WORD2_SECURITY_LABEL; + attrmask[2] &= ~FATTR4_WORD2_SECURITY_LABEL; else if (err) goto out_nfserr; } } #endif /* CONFIG_NFSD_V4_SECURITY_LABEL */ - status = nfsd4_encode_bitmap4(xdr, bmval0, bmval1, bmval2); + status = nfsd4_encode_bitmap4(xdr, attrmask[0], + attrmask[1], attrmask[2]); if (status) goto out; @@ -3472,276 +3591,12 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, attrlen_p = xdr_reserve_space(xdr, XDR_UNIT); if (!attrlen_p) goto out_resource; - - if (bmval0 & FATTR4_WORD0_SUPPORTED_ATTRS) { - status = nfsd4_encode_fattr4_supported_attrs(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_TYPE) { - status = nfsd4_encode_fattr4_type(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_FH_EXPIRE_TYPE) { - status = nfsd4_encode_fattr4_fh_expire_type(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_CHANGE) { - status = nfsd4_encode_fattr4_change(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_SIZE) { - status = nfsd4_encode_fattr4_size(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_LINK_SUPPORT) { - status = nfsd4_encode_fattr4__true(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_SYMLINK_SUPPORT) { - status = nfsd4_encode_fattr4__true(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_NAMED_ATTR) { - status = nfsd4_encode_fattr4__false(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_FSID) { - status = nfsd4_encode_fattr4_fsid(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_UNIQUE_HANDLES) { - status = nfsd4_encode_fattr4__false(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_LEASE_TIME) { - status = nfsd4_encode_fattr4_lease_time(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_RDATTR_ERROR) { - status = nfsd4_encode_fattr4_rdattr_error(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_ACL) { - status = nfsd4_encode_fattr4_acl(xdr, &args); - if (status) - goto out; - } - if (bmval0 & FATTR4_WORD0_ACLSUPPORT) { - status = nfsd4_encode_fattr4_aclsupport(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_CANSETTIME) { - status = nfsd4_encode_fattr4__true(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_CASE_INSENSITIVE) { - status = nfsd4_encode_fattr4__false(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_CASE_PRESERVING) { - status = nfsd4_encode_fattr4__true(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_CHOWN_RESTRICTED) { - status = nfsd4_encode_fattr4__true(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_FILEHANDLE) { - status = nfsd4_encode_fattr4_filehandle(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_FILEID) { - status = nfsd4_encode_fattr4_fileid(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_FILES_AVAIL) { - status = nfsd4_encode_fattr4_files_avail(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_FILES_FREE) { - status = nfsd4_encode_fattr4_files_free(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_FILES_TOTAL) { - status = nfsd4_encode_fattr4_files_total(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_FS_LOCATIONS) { - status = nfsd4_encode_fattr4_fs_locations(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_HOMOGENEOUS) { - status = nfsd4_encode_fattr4__true(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_MAXFILESIZE) { - status = nfsd4_encode_fattr4_maxfilesize(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_MAXLINK) { - status = nfsd4_encode_fattr4_maxlink(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_MAXNAME) { - status = nfsd4_encode_fattr4_maxname(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_MAXREAD) { - status = nfsd4_encode_fattr4_maxread(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval0 & FATTR4_WORD0_MAXWRITE) { - status = nfsd4_encode_fattr4_maxwrite(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval1 & FATTR4_WORD1_MODE) { - status = nfsd4_encode_fattr4_mode(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval1 & FATTR4_WORD1_NO_TRUNC) { - status = nfsd4_encode_fattr4__true(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval1 & FATTR4_WORD1_NUMLINKS) { - status = nfsd4_encode_fattr4_numlinks(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval1 & FATTR4_WORD1_OWNER) { - status = nfsd4_encode_fattr4_owner(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval1 & FATTR4_WORD1_OWNER_GROUP) { - status = nfsd4_encode_fattr4_owner_group(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval1 & FATTR4_WORD1_RAWDEV) { - status = nfsd4_encode_fattr4_rawdev(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval1 & FATTR4_WORD1_SPACE_AVAIL) { - status = nfsd4_encode_fattr4_space_avail(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval1 & FATTR4_WORD1_SPACE_FREE) { - status = nfsd4_encode_fattr4_space_free(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval1 & FATTR4_WORD1_SPACE_TOTAL) { - status = nfsd4_encode_fattr4_space_total(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval1 & FATTR4_WORD1_SPACE_USED) { - status = nfsd4_encode_fattr4_space_used(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval1 & FATTR4_WORD1_TIME_ACCESS) { - status = nfsd4_encode_fattr4_time_access(xdr, &args); - if (status) - goto out; - } - if (bmval1 & FATTR4_WORD1_TIME_CREATE) { - status = nfsd4_encode_fattr4_time_create(xdr, &args); - if (status) - goto out; - } - if (bmval1 & FATTR4_WORD1_TIME_DELTA) { - status = nfsd4_encode_fattr4_time_delta(xdr, &args); - if (status != nfs_ok) - goto out; - } - if (bmval1 & FATTR4_WORD1_TIME_METADATA) { - status = nfsd4_encode_fattr4_time_metadata(xdr, &args); - if (status) - goto out; - } - if (bmval1 & FATTR4_WORD1_TIME_MODIFY) { - status = nfsd4_encode_fattr4_time_modify(xdr, &args); - if (status) - goto out; - } - if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) { - status = nfsd4_encode_fattr4_mounted_on_fileid(xdr, &args); - if (status != nfs_ok) - goto out; - } -#ifdef CONFIG_NFSD_PNFS - if (bmval1 & FATTR4_WORD1_FS_LAYOUT_TYPES) { - status = nfsd4_encode_fattr4_fs_layout_types(xdr, &args); - if (status) - goto out; - } - - if (bmval2 & FATTR4_WORD2_LAYOUT_TYPES) { - status = nfsd4_encode_fattr4_layout_types(xdr, &args); - if (status) - goto out; - } - - if (bmval2 & FATTR4_WORD2_LAYOUT_BLKSIZE) { - status = nfsd4_encode_fattr4_layout_blksize(xdr, &args); + mask = (unsigned long *)attrmask; + for_each_set_bit(bit, mask, ARRAY_SIZE(nfsd4_enc_fattr4_encode_ops)) { + status = nfsd4_enc_fattr4_encode_ops[bit](xdr, &args); if (status != nfs_ok) goto out; } -#endif /* CONFIG_NFSD_PNFS */ - if (bmval2 & FATTR4_WORD2_SUPPATTR_EXCLCREAT) { - status = nfsd4_encode_fattr4_suppattr_exclcreat(xdr, &args); - if (status) - goto out; - } - -#ifdef CONFIG_NFSD_V4_SECURITY_LABEL - if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) { - status = nfsd4_encode_fattr4_sec_label(xdr, &args); - if (status) - goto out; - } -#endif - - if (bmval2 & FATTR4_WORD2_XATTR_SUPPORT) { - status = nfsd4_encode_fattr4_xattr_support(xdr, &args); - if (status != nfs_ok) - goto out; - } - *attrlen_p = cpu_to_be32(xdr->buf->len - attrlen_offset - XDR_UNIT); status = nfs_ok; From patchwork Mon Sep 18 14:02:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13389833 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 70D5EC46CA1 for ; Mon, 18 Sep 2023 15:26:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231234AbjIRP0M (ORCPT ); Mon, 18 Sep 2023 11:26:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230206AbjIRP0M (ORCPT ); Mon, 18 Sep 2023 11:26:12 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B082210E3 for ; Mon, 18 Sep 2023 08:24:19 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7E4CC3277A; Mon, 18 Sep 2023 14:02:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045740; bh=F7a6thmp0sDPhZVNpiOt10d5AsAUD4N3eOni6yrQT/o=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=o9QA3tODgqShiEGrL2HRyB6UBmRw9QK2+NFvBwMeoN07NM2C9W8QuOlX/XUk1m4tF qaSeXjkVahniFeF2eqs9Crdne3SWt9G9X5JaplPfGtMr2n6tkQ8dvGnYjo7pGtKEjL +hE3A4fL/+5lGrm9+oLo8U9gAFCKAkErTkaQ7Sa3ruothFbls8fbDBSoghuUu0UZQE 1q9PDC1RmQhLYoMzf74qe5z4DTwQGS/UUF+wSA/8+2WoECzau+h2tAUPendp1NQ1z2 wNp6L4QnikeUl4LBhd7OrNMKwd0c66vK7oD4DSrCB5p4k5CMYp8IHwJm8mOgVkE+11 a8s2MHwKWUarg== Subject: [PATCH v1 52/52] NFSD: Rename nfsd4_encode_fattr() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:02:18 -0400 Message-ID: <169504573893.133720.10007386925698101507.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 For better alignment with the specification, NFSD's encoder function name should match the name of the XDR data type. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index d7f690a3ea86..e38af124169b 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3470,10 +3470,10 @@ static const nfsd4_enc_attr nfsd4_enc_fattr4_encode_ops[] = { * ourselves. */ static __be32 -nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, - struct svc_export *exp, - struct dentry *dentry, const u32 *bmval, - struct svc_rqst *rqstp, int ignore_crossmnt) +nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr, + struct svc_fh *fhp, struct svc_export *exp, + struct dentry *dentry, const u32 *bmval, + int ignore_crossmnt) { struct nfsd4_fattr_args args; struct svc_fh *tempfh = NULL; @@ -3582,11 +3582,13 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, } #endif /* CONFIG_NFSD_V4_SECURITY_LABEL */ + /* attrmask */ status = nfsd4_encode_bitmap4(xdr, attrmask[0], attrmask[1], attrmask[2]); if (status) goto out; + /* attr_vals */ attrlen_offset = xdr->buf->len; attrlen_p = xdr_reserve_space(xdr, XDR_UNIT); if (!attrlen_p) @@ -3646,8 +3648,8 @@ __be32 nfsd4_encode_fattr_to_buf(__be32 **p, int words, __be32 ret; svcxdr_init_encode_from_buffer(&xdr, &dummy, *p, words << 2); - ret = nfsd4_encode_fattr(&xdr, fhp, exp, dentry, bmval, rqstp, - ignore_crossmnt); + ret = nfsd4_encode_fattr4(rqstp, &xdr, fhp, exp, dentry, bmval, + ignore_crossmnt); *p = xdr.p; return ret; } @@ -3706,8 +3708,8 @@ nfsd4_encode_dirent_fattr(struct xdr_stream *xdr, struct nfsd4_readdir *cd, } out_encode: - nfserr = nfsd4_encode_fattr(xdr, NULL, exp, dentry, cd->rd_bmval, - cd->rd_rqstp, ignore_crossmnt); + nfserr = nfsd4_encode_fattr4(cd->rd_rqstp, xdr, NULL, exp, dentry, + cd->rd_bmval, ignore_crossmnt); out_put: dput(dentry); exp_put(exp); @@ -3951,8 +3953,9 @@ nfsd4_encode_getattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct svc_fh *fhp = getattr->ga_fhp; struct xdr_stream *xdr = resp->xdr; - return nfsd4_encode_fattr(xdr, fhp, fhp->fh_export, fhp->fh_dentry, - getattr->ga_bmval, resp->rqstp, 0); + /* obj_attributes */ + return nfsd4_encode_fattr4(resp->rqstp, xdr, fhp, fhp->fh_export, + fhp->fh_dentry, getattr->ga_bmval, 0); } static __be32