NFSD: Clean up nfsd4_encode_readlink()
[ Upstream commit 99b002a1fa00d90e66357315757e7277447ce973 ] Similar changes to nfsd4_encode_readv(), all bundled into a single patch. 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:

committed by
Greg Kroah-Hartman

parent
c7863472e5
commit
0a1b9a216f
@@ -4019,16 +4019,13 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
|
|||||||
static __be32
|
static __be32
|
||||||
nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_readlink *readlink)
|
nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_readlink *readlink)
|
||||||
{
|
{
|
||||||
int maxcount;
|
__be32 *p, *maxcount_p, zero = xdr_zero;
|
||||||
__be32 wire_count;
|
|
||||||
int zero = 0;
|
|
||||||
struct xdr_stream *xdr = resp->xdr;
|
struct xdr_stream *xdr = resp->xdr;
|
||||||
int length_offset = xdr->buf->len;
|
int length_offset = xdr->buf->len;
|
||||||
int status;
|
int maxcount, status;
|
||||||
__be32 *p;
|
|
||||||
|
|
||||||
p = xdr_reserve_space(xdr, 4);
|
maxcount_p = xdr_reserve_space(xdr, XDR_UNIT);
|
||||||
if (!p)
|
if (!maxcount_p)
|
||||||
return nfserr_resource;
|
return nfserr_resource;
|
||||||
maxcount = PAGE_SIZE;
|
maxcount = PAGE_SIZE;
|
||||||
|
|
||||||
@@ -4053,14 +4050,11 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd
|
|||||||
nfserr = nfserrno(status);
|
nfserr = nfserrno(status);
|
||||||
goto out_err;
|
goto out_err;
|
||||||
}
|
}
|
||||||
|
*maxcount_p = cpu_to_be32(maxcount);
|
||||||
wire_count = htonl(maxcount);
|
xdr_truncate_encode(xdr, length_offset + 4 + xdr_align_size(maxcount));
|
||||||
write_bytes_to_xdr_buf(xdr->buf, length_offset, &wire_count, 4);
|
write_bytes_to_xdr_buf(xdr->buf, length_offset + 4 + maxcount, &zero,
|
||||||
xdr_truncate_encode(xdr, length_offset + 4 + ALIGN(maxcount, 4));
|
xdr_pad_size(maxcount));
|
||||||
if (maxcount & 3)
|
return nfs_ok;
|
||||||
write_bytes_to_xdr_buf(xdr->buf, length_offset + 4 + maxcount,
|
|
||||||
&zero, 4 - (maxcount&3));
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
out_err:
|
out_err:
|
||||||
xdr_truncate_encode(xdr, length_offset);
|
xdr_truncate_encode(xdr, length_offset);
|
||||||
|
Reference in New Issue
Block a user