Commit 99b002a1 authored by Chuck Lever's avatar Chuck Lever

NFSD: Clean up nfsd4_encode_readlink()

Similar changes to nfsd4_encode_readv(), all bundled into a single
patch.
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 5e64d85c
...@@ -4008,16 +4008,13 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4008,16 +4008,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;
...@@ -4042,14 +4039,11 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd ...@@ -4042,14 +4039,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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment