Linux NFS development
 help / color / mirror / Atom feed
From: Chuck Lever <cel@kernel.org>
To: Chuck Lever <cel@kernel.org>, Christoph Hellwig <hch@lst.de>,
	 Jeff Layton <jlayton@kernel.org>, NeilBrown <neil@brown.name>,
	 Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <Dai.Ngo@oracle.com>,  Tom Talpey <tom@talpey.com>,
	Sergey Bashirov <sergeybashirov@gmail.com>,
	 Konstantin Evtushenko <koevtushenko@yandex.com>
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 3/4] NFSD: Decode block and SCSI layoutupdates from a local xdr_stream
Date: Thu, 19 Nov 2026 13:33:53 -0500	[thread overview]
Message-ID: <20261119-blocklayout-decode-stream-v1-3-d71322f42c28@kernel.org> (raw)
In-Reply-To: <20261119-blocklayout-decode-stream-v1-0-d71322f42c28@kernel.org>

nfsd4_decode_layoutupdate4() leaves the body of a layoutupdate4
undecoded in lc_up_layout. nfsd4_block_proc_layoutcommit() and
nfsd4_scsi_proc_layoutcommit() decode that body during the pc_func
step by overwriting rqstp->rq_arg and re-initializing
rq_arg_stream. Nothing reads those fields after pc_decode today,
but the svc_rqst should be free to keep state in them until the
request completes.

Decode the layoutupdate4 body from an xdr_stream and scratch
buffer on the stack instead, leaving rq_arg and rq_arg_stream
untouched. Decoding layoutupdate4 during the pc_decode step would
be a better design, but that larger change is outside the scope
of this patch.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 fs/nfsd/blocklayout.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c
index 06564f247795..c3b614b25278 100644
--- a/fs/nfsd/blocklayout.c
+++ b/fs/nfsd/blocklayout.c
@@ -269,15 +269,18 @@ static __be32
 nfsd4_block_proc_layoutcommit(struct inode *inode, struct svc_rqst *rqstp,
 		struct nfsd4_layoutcommit *lcp)
 {
+	__be32 scratch[XDR_QUADLEN(NFS4_DEVICEID4_SIZE)];
+	struct xdr_stream xdr;
 	struct iomap *iomaps;
 	int nr_iomaps;
 	__be32 nfserr;
 
-	rqstp->rq_arg = lcp->lc_up_layout;
-	svcxdr_init_decode(rqstp);
+	xdr_init_decode(&xdr, &lcp->lc_up_layout, NULL, NULL);
+	xdr_set_scratch_buffer(&xdr, scratch, sizeof(scratch));
 
-	nfserr = nfsd4_block_decode_layoutupdate(&rqstp->rq_arg_stream,
-			&iomaps, &nr_iomaps, i_blocksize(inode));
+	nfserr = nfsd4_block_decode_layoutupdate(&xdr, &iomaps, &nr_iomaps,
+						 i_blocksize(inode));
+	xdr_finish_decode(&xdr);
 	if (nfserr != nfs_ok)
 		return nfserr;
 
@@ -461,15 +464,18 @@ static __be32
 nfsd4_scsi_proc_layoutcommit(struct inode *inode, struct svc_rqst *rqstp,
 		struct nfsd4_layoutcommit *lcp)
 {
+	__be32 scratch[XDR_QUADLEN(NFS4_DEVICEID4_SIZE)];
+	struct xdr_stream xdr;
 	struct iomap *iomaps;
 	int nr_iomaps;
 	__be32 nfserr;
 
-	rqstp->rq_arg = lcp->lc_up_layout;
-	svcxdr_init_decode(rqstp);
+	xdr_init_decode(&xdr, &lcp->lc_up_layout, NULL, NULL);
+	xdr_set_scratch_buffer(&xdr, scratch, sizeof(scratch));
 
-	nfserr = nfsd4_scsi_decode_layoutupdate(&rqstp->rq_arg_stream,
-			&iomaps, &nr_iomaps, i_blocksize(inode));
+	nfserr = nfsd4_scsi_decode_layoutupdate(&xdr, &iomaps, &nr_iomaps,
+						i_blocksize(inode));
+	xdr_finish_decode(&xdr);
 	if (nfserr != nfs_ok)
 		return nfserr;
 

-- 
2.56.0


  parent reply	other threads:[~2026-11-19 18:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 18:33 [PATCH 0/4] NFSD: More minor XDR restructuring Chuck Lever
2026-11-19 18:33 ` [PATCH 1/4] NFSD: Reject layoutupdate extent counts that wrap the length check Chuck Lever
2026-11-20 16:12   ` Christoph Hellwig
2026-11-19 18:33 ` [PATCH 2/4] NFSD: Allocate the layoutupdate extent array with kvzalloc_objs() Chuck Lever
2026-11-20 16:13   ` Christoph Hellwig
2026-11-19 18:33 ` Chuck Lever [this message]
2026-11-20 16:14   ` [PATCH 3/4] NFSD: Decode block and SCSI layoutupdates from a local xdr_stream Christoph Hellwig
2026-11-19 18:33 ` [PATCH 4/4] NFSD: Remove the svc_rqst argument from proc_layoutcommit Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119-blocklayout-decode-stream-v1-3-d71322f42c28@kernel.org \
    --to=cel@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=hch@lst.de \
    --cc=jlayton@kernel.org \
    --cc=koevtushenko@yandex.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=sergeybashirov@gmail.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox