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>pull/1354/merge
parent
803bc849f0
commit
d7de37d6d7
|
|
@ -4480,18 +4480,30 @@ static __be32 nfsd4_encode_readv(struct nfsd4_compoundres *resp,
|
||||||
__be32 zero = xdr_zero;
|
__be32 zero = xdr_zero;
|
||||||
__be32 nfserr;
|
__be32 nfserr;
|
||||||
|
|
||||||
if (xdr_reserve_space_vec(xdr, maxcount) < 0)
|
|
||||||
return nfserr_resource;
|
|
||||||
|
|
||||||
nfserr = nfsd_iter_read(resp->rqstp, read->rd_fhp, read->rd_nf,
|
nfserr = nfsd_iter_read(resp->rqstp, read->rd_fhp, read->rd_nf,
|
||||||
read->rd_offset, &maxcount, base,
|
read->rd_offset, &maxcount, base,
|
||||||
&read->rd_eof);
|
&read->rd_eof);
|
||||||
read->rd_length = maxcount;
|
read->rd_length = maxcount;
|
||||||
if (nfserr)
|
if (nfserr)
|
||||||
return nfserr;
|
return nfserr;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* svcxdr_encode_opaque_pages() is not used here because
|
||||||
|
* we don't want to encode subsequent results in this
|
||||||
|
* COMPOUND into the xdr->buf's tail, but rather those
|
||||||
|
* results should follow the NFS READ payload in the
|
||||||
|
* buf's pages.
|
||||||
|
*/
|
||||||
|
if (xdr_reserve_space_vec(xdr, maxcount) < 0)
|
||||||
|
return nfserr_resource;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mark the buffer location of the NFS READ payload so that
|
||||||
|
* direct placement-capable transports send only the
|
||||||
|
* payload bytes out-of-band.
|
||||||
|
*/
|
||||||
if (svc_encode_result_payload(resp->rqstp, starting_len, maxcount))
|
if (svc_encode_result_payload(resp->rqstp, starting_len, maxcount))
|
||||||
return nfserr_io;
|
return nfserr_io;
|
||||||
xdr_truncate_encode(xdr, starting_len + xdr_align_size(maxcount));
|
|
||||||
|
|
||||||
write_bytes_to_xdr_buf(xdr->buf, starting_len + maxcount, &zero,
|
write_bytes_to_xdr_buf(xdr->buf, starting_len + maxcount, &zero,
|
||||||
xdr_pad_size(maxcount));
|
xdr_pad_size(maxcount));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue