Commit fa94a951 authored by Trond Myklebust's avatar Trond Myklebust
Browse files

NFSv4.2: Fix up the get/listxattr calls to rpc_prepare_reply_pages()



Ensure that both getxattr and listxattr page array are correctly
aligned, and that getxattr correctly accounts for the page padding word.

Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent bf701b76
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -191,7 +191,7 @@

#define encode_getxattr_maxsz   (op_encode_hdr_maxsz + 1 + \
				 nfs4_xattr_name_maxsz)
#define decode_getxattr_maxsz   (op_decode_hdr_maxsz + 1 + 1)
#define decode_getxattr_maxsz   (op_decode_hdr_maxsz + 1 + pagepad_maxsz)
#define encode_setxattr_maxsz   (op_encode_hdr_maxsz + \
				 1 + nfs4_xattr_name_maxsz + 1)
#define decode_setxattr_maxsz   (op_decode_hdr_maxsz + decode_change_info_maxsz)
@@ -1476,17 +1476,18 @@ static void nfs4_xdr_enc_getxattr(struct rpc_rqst *req, struct xdr_stream *xdr,
	struct compound_hdr hdr = {
		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
	};
	uint32_t replen;
	size_t plen;

	encode_compound_hdr(xdr, req, &hdr);
	encode_sequence(xdr, &args->seq_args, &hdr);
	encode_putfh(xdr, args->fh, &hdr);
	replen = hdr.replen + op_decode_hdr_maxsz + 1;
	encode_getxattr(xdr, args->xattr_name, &hdr);

	plen = args->xattr_len ? args->xattr_len : XATTR_SIZE_MAX;

	rpc_prepare_reply_pages(req, args->xattr_pages, 0, plen,
	    hdr.replen);
	rpc_prepare_reply_pages(req, args->xattr_pages, 0, plen, replen);
	req->rq_rcv_buf.flags |= XDRBUF_SPARSE_PAGES;

	encode_nops(&hdr);
@@ -1520,14 +1521,15 @@ static void nfs4_xdr_enc_listxattrs(struct rpc_rqst *req,
	struct compound_hdr hdr = {
		.minorversion = nfs4_xdr_minorversion(&args->seq_args),
	};
	uint32_t replen;

	encode_compound_hdr(xdr, req, &hdr);
	encode_sequence(xdr, &args->seq_args, &hdr);
	encode_putfh(xdr, args->fh, &hdr);
	replen = hdr.replen + op_decode_hdr_maxsz + 2 + 1;
	encode_listxattrs(xdr, args, &hdr);

	rpc_prepare_reply_pages(req, args->xattr_pages, 0, args->count,
	    hdr.replen);
	rpc_prepare_reply_pages(req, args->xattr_pages, 0, args->count, replen);

	encode_nops(&hdr);
}