From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E025B45BD41; Tue, 16 Jun 2026 11:59:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781611171; cv=none; b=sObym3CBluxo9lwL3HoN5LvVfrr/s6WGkg9yw1Dtz9oQjyz4mZx5R8/17kW1E7enbN7XCakdtXoXQ8bZKcWWJclptF49FrDHevSmkwxJBJihuTRhMkeYOIn5nR+VzsGfFAdP4RxiWn0lUfR915/eFf0WGmwS9Lt06W9HDFfLCL4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781611171; c=relaxed/simple; bh=EdUrKbGO4aztP1z0MIJbDTbOA7CCGqvTe+ppF3r9yyo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c6m7eoyyy1+EnQxKNI/pftKyEu8tv9JVFT3ubO5rQLwDEBOdc7tO2Q21KmEYKO15+jnco0ODE7XDE2GGljTuaIGEtDpOc7DOzSmR8GHdeXwE3Jx4Ojta/RGVPAaIFAykJ8EjCf4Mqi7Lx05dkoolKmn2n7W97yQ2TBwk0jzdCuU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FExUUxEq; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FExUUxEq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5BFB1F00AC4; Tue, 16 Jun 2026 11:59:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781611169; bh=NBZNqjZ9ORe/fMxYK1STJ4cKuGlFnMs76zT3E74K0ng=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=FExUUxEqVW2Ulan04HamfoWSOLsdE7WbU1Mg13DRKNBjMsgmsyX6gqeUsRLv0HCZ3 Z0BTodPZjk9yu9eMvbdgiuzxCnjHea1XZyhZ5FDdSYq6KcFHbG5OLmRPa++TKZUsMU 7Yj0zEIHzFKlw4zjXxSWMBYg9Ww5IwaczB6ZbglpYEsDRZ/Qd2DhSAgN3IDwVT/i92 WJY/mKDoN86tRAnHaOFpyEDABnricd6Q+29GVvp3fiKghrNRH3n/Ubccqg4znjlA82 2gC+vwyWhGOdF0m5hUanpPNvtxFCk/tY1Ym8pXkB3ictVKKt2aRqTB0dWGJ1r8WsAO pdjNWo7gAvpjw== From: Jeff Layton Date: Tue, 16 Jun 2026 07:58:55 -0400 Subject: [PATCH v7 12/20] nfsd: add helper to marshal a fattr4 from completed args Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260616-dir-deleg-v7-12-6cbc7eac0ade@kernel.org> References: <20260616-dir-deleg-v7-0-6cbc7eac0ade@kernel.org> In-Reply-To: <20260616-dir-deleg-v7-0-6cbc7eac0ade@kernel.org> To: NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , Jonathan Corbet , Shuah Khan , Chuck Lever Cc: Steven Rostedt , Alexander Aring , Amir Goldstein , Jan Kara , Alexander Viro , Christian Brauner , Calum Mackay , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3412; i=jlayton@kernel.org; h=from:subject:message-id; bh=EdUrKbGO4aztP1z0MIJbDTbOA7CCGqvTe+ppF3r9yyo=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBqMTqGazpV664MnIPwQECSW0rt7apCTnP2qdflN yodtSyLSbyJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCajE6hgAKCRAADmhBGVaC FU2xD/wJ+XjGOs4Mu0Bycud+eg1GI87O7fLJrfehdal68esFJnlJMGCHGPWnSwyqeBBOmm9UhRw FPeAQ4lFniWy+ljmq/RoVW7YBqoRWVjj28HIyGzNCgxf05tz9w8GdNNqKXRMgENxrtOuXu0xsjJ vF3sqTeyXt9TCqOnyxiO9uEC7F9xBzeiERwIQvMRN8Sibp8iKk1kkqhc7It4osOmiyBLD2L5gvk RLtuzQDAENVQLDqKg5dYJtSQHH86ABxRjgrDFZSYSKJbFLOyqtKhxJFA/daNXBSJaSpqtr3LcoS L3V4QwXR4L4dmaCx9M31odCxGX/fkO2o6kTtwQ48NJN2B0R1uthoOfJDLeJcb4MSY8gZc7B5ULl E5OFJRuq+J6HbqhcgxtlxQYX1jP+8orLzbP837I7LWA4XZ0aU9U+18Bhct65bB/DqpLLIb7j0Ui h5kXc/2Y1xACKFMf7WQRIxreh9lUBigfZDsV3UgMD66ij+1viNSB6xdGjC1hGsBwNBnFU2CWT1r zTWoooJaAbAvrrynBN4vlNIRmuLXi6LldWTAgmeeXivWdtsPaAzOHFg8ZDLai03goj07yx3s0z0 mAng7q6smBTxiabTTm4xibcK/BwFvouf+UQ0ZJZ+/8RbtWYCC+AogXMqVBDxV4V/IxGgvjZmZTL vzr/KvLCSmazMEw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Break the loop that encodes the actual attr_vals field into a separate function. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4xdr.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 976d60115cd6..54a7902935b5 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3899,6 +3899,22 @@ static const nfsd4_enc_attr nfsd4_enc_fattr4_encode_ops[] = { #endif }; +static __be32 +nfsd4_encode_attr_vals(struct xdr_stream *xdr, u32 *attrmask, struct nfsd4_fattr_args *args) +{ + DECLARE_BITMAP(attr_bitmap, ARRAY_SIZE(nfsd4_enc_fattr4_encode_ops)); + unsigned long bit; + __be32 status; + + bitmap_from_arr32(attr_bitmap, attrmask, ARRAY_SIZE(nfsd4_enc_fattr4_encode_ops)); + for_each_set_bit(bit, attr_bitmap, ARRAY_SIZE(nfsd4_enc_fattr4_encode_ops)) { + status = nfsd4_enc_fattr4_encode_ops[bit](xdr, args); + 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. @case_cache is NULL for callers that encode a single dentry @@ -3912,7 +3928,6 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr, int ignore_crossmnt, struct nfsd_case_attrs_cache *case_cache) { - DECLARE_BITMAP(attr_bitmap, ARRAY_SIZE(nfsd4_enc_fattr4_encode_ops)); struct nfs4_delegation *dp = NULL; struct nfsd4_fattr_args args; struct svc_fh *tempfh = NULL; @@ -3927,7 +3942,6 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr, .mnt = exp->ex_path.mnt, .dentry = dentry, }; - unsigned long bit; WARN_ON_ONCE(bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1); WARN_ON_ONCE(!nfsd_attrs_supported(minorversion, bmval)); @@ -4141,27 +4155,22 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr, #endif /* CONFIG_NFSD_V4_POSIX_ACLS */ /* attrmask */ - status = nfsd4_encode_bitmap4(xdr, attrmask[0], attrmask[1], - attrmask[2]); + status = nfsd4_encode_bitmap4(xdr, attrmask[0], attrmask[1], attrmask[2]); if (status) goto out; /* attr_vals */ attrlen_offset = xdr->buf->len; - if (unlikely(!xdr_reserve_space(xdr, XDR_UNIT))) - goto out_resource; - bitmap_from_arr32(attr_bitmap, attrmask, - ARRAY_SIZE(nfsd4_enc_fattr4_encode_ops)); - for_each_set_bit(bit, attr_bitmap, - ARRAY_SIZE(nfsd4_enc_fattr4_encode_ops)) { - status = nfsd4_enc_fattr4_encode_ops[bit](xdr, &args); - if (status != nfs_ok) - goto out; + if (unlikely(!xdr_reserve_space(xdr, XDR_UNIT))) { + status = nfserr_resource; + goto out; } - attrlen = cpu_to_be32(xdr->buf->len - attrlen_offset - XDR_UNIT); - write_bytes_to_xdr_buf(xdr->buf, attrlen_offset, &attrlen, XDR_UNIT); - status = nfs_ok; + status = nfsd4_encode_attr_vals(xdr, attrmask, &args); + if (status == nfs_ok) { + attrlen = cpu_to_be32(xdr->buf->len - attrlen_offset - XDR_UNIT); + write_bytes_to_xdr_buf(xdr->buf, attrlen_offset, &attrlen, XDR_UNIT); + } out: #ifdef CONFIG_NFSD_V4_POSIX_ACLS if (args.dpacl) @@ -4184,9 +4193,6 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr, out_nfserr: status = nfserrno(err); goto out; -out_resource: - status = nfserr_resource; - goto out; } static bool -- 2.54.0