]> git.ipfire.org Git - thirdparty/linux.git/commit
NFSD: Relocate the xdr_reserve_space_vec() call site
authorChuck Lever <chuck.lever@oracle.com>
Wed, 8 Oct 2025 13:52:29 +0000 (09:52 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Sun, 16 Nov 2025 23:20:11 +0000 (18:20 -0500)
commitd7de37d6d7ccfac9321d8cc4f36fc85dfadad54a
tree0a556aabd4b8ad34fceb636dc6f8b4c1f0f40b45
parent803bc849f0039291f546ba0e2237faebeb5c073e
NFSD: Relocate the xdr_reserve_space_vec() call site

In order to detect when a direct READ is possible, we need the send
buffer's .page_len to be zero when there is nothing in the buffer's
.pages array yet.

However, when xdr_reserve_space_vec() extends the size of the
xdr_stream to accommodate a READ payload, it adds to the send
buffer's .page_len.

It should be safe to reserve the stream space /after/ the VFS read
operation completes. This is, for example, how an NFSv3 READ works:
the VFS read goes into the rq_bvec, and is then added to the send
xdr_stream later by svcxdr_encode_opaque_pages().

Now that xdr_reserve_space_vec() uses the number of bytes actually
read, the xdr_truncate_encode() call is no longer necessary.

Reviewed-by: NeilBrown <neil@brown.name>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4xdr.c