Re: [PATCH 11/14] nfsd: add user xattr RPC XDR encoding/decoding logic

Chuck Lever
2020-03-19T22:15:30Z

> On Mar 19, 2020, at 6:13 PM, Frank van der Linden <fllinden@amazon.com> wrote:
>
> On Thu, Mar 12, 2020 at 12:24:18PM -0400, Chuck Lever wrote:
>>> +static inline u32 nfsd4_getxattr_rsize(struct svc_rqst *rqstp,
>>> + struct nfsd4_op *op)
>>> +{
>>> + u32 maxcount, rlen;
>>> +
>>> + maxcount = svc_max_payload(rqstp);
>>> + rlen = min_t(u32, XATTR_SIZE_MAX, maxcount);
>>> +
>>> + return (op_encode_hdr_size + 1 + XDR_QUADLEN(rlen)) * sizeof(__be32);
>>
>> These should be added in the same patch that adds OP_GETXATTR and friends.
>>
>> Also, Trond recently added xdr_align_size which I prefer over the
>> use of XDR_QUADLEN in new code.
>
> Thanks, I've squashed together those patches for this and the other reasons
> you pointed out.
>
> As for XDR_QUADLEN: that returns the 32bit-word rounded up lenghth - in words.
> xdr_aligned_size returns the 32bit-word rounded up length - in bytes.
>
> So, the result would then look something like:
>
> return xdr_align_size((op_encode_hdr_size * 4) + 4 + rlen);
>
> Is that what you're suggesting?

Oops, you're right. When you want words, XDR_QUADLEN is correct. Never mind!

--
Chuck Lever