NFSD: Optimize nfsd4_encode_readv()
[ Upstream commit 28d5bc468efe74b790e052f758ce083a5015c665 ] write_bytes_to_xdr_buf() is pretty expensive to use for inserting an XDR data item that is always 1 XDR_UNIT at an address that is always XDR word-aligned. Since both the readv and splice read paths encode EOF and maxcount values, move both to a common code path. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
11f94493ca
commit
bb201cc062
1 changed files with 6 additions and 12 deletions
|
@ -3891,7 +3891,6 @@ static __be32 nfsd4_encode_splice_read(
|
||||||
struct xdr_buf *buf = xdr->buf;
|
struct xdr_buf *buf = xdr->buf;
|
||||||
int status, space_left;
|
int status, space_left;
|
||||||
__be32 nfserr;
|
__be32 nfserr;
|
||||||
__be32 *p = xdr->p - 2;
|
|
||||||
|
|
||||||
/* Make sure there will be room for padding if needed */
|
/* Make sure there will be room for padding if needed */
|
||||||
if (xdr->end - xdr->p < 1)
|
if (xdr->end - xdr->p < 1)
|
||||||
|
@ -3910,9 +3909,6 @@ static __be32 nfsd4_encode_splice_read(
|
||||||
goto out_err;
|
goto out_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(p++) = htonl(read->rd_eof);
|
|
||||||
*(p++) = htonl(maxcount);
|
|
||||||
|
|
||||||
buf->page_len = maxcount;
|
buf->page_len = maxcount;
|
||||||
buf->len += maxcount;
|
buf->len += maxcount;
|
||||||
xdr->page_ptr += (buf->page_base + maxcount + PAGE_SIZE - 1)
|
xdr->page_ptr += (buf->page_base + maxcount + PAGE_SIZE - 1)
|
||||||
|
@ -3973,11 +3969,6 @@ static __be32 nfsd4_encode_readv(struct nfsd4_compoundres *resp,
|
||||||
return nfserr_io;
|
return nfserr_io;
|
||||||
xdr_truncate_encode(xdr, starting_len + 8 + xdr_align_size(maxcount));
|
xdr_truncate_encode(xdr, starting_len + 8 + xdr_align_size(maxcount));
|
||||||
|
|
||||||
tmp = htonl(read->rd_eof);
|
|
||||||
write_bytes_to_xdr_buf(xdr->buf, starting_len , &tmp, 4);
|
|
||||||
tmp = htonl(maxcount);
|
|
||||||
write_bytes_to_xdr_buf(xdr->buf, starting_len + 4, &tmp, 4);
|
|
||||||
|
|
||||||
tmp = xdr_zero;
|
tmp = xdr_zero;
|
||||||
pad = (maxcount&3) ? 4 - (maxcount&3) : 0;
|
pad = (maxcount&3) ? 4 - (maxcount&3) : 0;
|
||||||
write_bytes_to_xdr_buf(xdr->buf, starting_len + 8 + maxcount,
|
write_bytes_to_xdr_buf(xdr->buf, starting_len + 8 + maxcount,
|
||||||
|
@ -4019,11 +4010,14 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
|
||||||
nfserr = nfsd4_encode_splice_read(resp, read, file, maxcount);
|
nfserr = nfsd4_encode_splice_read(resp, read, file, maxcount);
|
||||||
else
|
else
|
||||||
nfserr = nfsd4_encode_readv(resp, read, file, maxcount);
|
nfserr = nfsd4_encode_readv(resp, read, file, maxcount);
|
||||||
|
if (nfserr) {
|
||||||
if (nfserr)
|
|
||||||
xdr_truncate_encode(xdr, starting_len);
|
xdr_truncate_encode(xdr, starting_len);
|
||||||
|
return nfserr;
|
||||||
|
}
|
||||||
|
|
||||||
return nfserr;
|
p = xdr_encode_bool(p, read->rd_eof);
|
||||||
|
*p = cpu_to_be32(read->rd_length);
|
||||||
|
return nfs_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __be32
|
static __be32
|
||||||
|
|
Loading…
Add table
Reference in a new issue