fix getdevice{info,list} xdr decode sizing
Subsystems (2)
cover fix getdevice{info,list} xdr decode sizing
looks like encode_getdevice{info,list} went under the radar and they do not update hdr->replen.
decode_getdeviceinfo_maxsz was completely screwed up so that twas fixed along with the replen calculation for the deviceinfo's xdr_inline_pages.
PATCH 1/2 SQUASHME: pnfs-submit: fix getdeviceinfo decode sizing
it looks like we forgot to adjust hdr->replen inencode_getdeviceinfo (and encode_getdevicelist).
and decode_getdeviceinfo_maxsz is completely wrong! It's in bytes, not words as it should be. Ironically, this balanced the -8 bug above in computing replen for xdi_inline_pages
--- fs/nfs/nfs4xdr.c | 24 ++++++++++-------------- 1 files changed, 10 insertions(+), 14 deletions(-)
fs/nfs/nfs4xdr.c +10 -14
@@ -325,10 +325,11 @@ static int nfs4_stat_to_errno(int);#define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + 4 + \ XDR_QUADLEN(NFS4_PNFS_DEVICEID4_SIZE))#define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \ - 4 /*layout type */ + \ - 4 /* opaque devaddr4 length */ +\ - 4 /* notification bitmap length */ + \ - 4 /* notification bitmap */) + 1 /* layout type */ + \ + 1 /* opaque devaddr4 length */ + \ + /* devaddr4 payload is read into page */ \ + 1 /* notification bitmap length */ + \ + 1 /* notification bitmap */)#define encode_layoutget_maxsz (op_encode_hdr_maxsz + 10 + \ encode_stateid_maxsz)#define decode_layoutget_maxsz (op_decode_hdr_maxsz + 8 + \
@@ -1888,6 +1889,7 @@ encode_getdeviceinfo(struct xdr_stream *xdr,if (has_bitmap) *p =cpu_to_be32 (args->pdev->dev_notify_types); hdr->nops++; + hdr->replen += decode_getdeviceinfo_maxsz; } static void
@@ -2850,26 +2852,20 @@ static int nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, uint32_t *p, struct nfs4_getdeviceinfo_args *args) {struct xdr_stream xdr; -struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;struct compound_hdr hdr = { .minorversion =nfs4_xdr_minorversion (&args->seq_args), }; -int replen;xdr_init_encode (&xdr, &req->rq_snd_buf, p);encode_compound_hdr (&xdr, req, &hdr);encode_sequence (&xdr, &args->seq_args, &hdr);encode_getdeviceinfo (&xdr, args, &hdr); -/* set up reply kvec. Subtract notification bitmap max size (8) +/* set up reply kvec. Subtract notification bitmap max size (2) * so that notification bitmap is put in xdr_buf tail */ - replen = (RPC_REPHDRSIZE + auth->au_rslack + - NFS4_dec_getdeviceinfo_sz -8 ) <<2 ; -xdr_inline_pages (&req->rq_rcv_buf, replen, args->pdev->pages, - args->pdev->pgbase, args->pdev->pglen); -dprintk ("%s: inlined page args = (%u, %p, %u, %u)\n" , - __func__, replen, args->pdev->pages, - args->pdev->pgbase, args->pdev->pglen); +xdr_inline_pages (&req->rq_rcv_buf, (hdr.replen -2 ) <<2 , + args->pdev->pages, args->pdev->pgbase, + args->pdev->pglen);encode_nops (&hdr);return 0 ;
Signature · 1 line
1.7.2.2
PATCH 2/2 SQUASHME: pnfs-submit: fix getdevicelist decode sizing
In reply to Benny Halevyit looks like we forgot to adjust hdr->replen inencode_getdevicelist.
spell out the fields for decode_getdevicelist_maxsz.
--- fs/nfs/nfs4xdr.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-)
fs/nfs/nfs4xdr.c +10 -4
@@ -318,10 +318,15 @@ static int nfs4_stat_to_errno(int);#define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4)#define encode_getdevicelist_maxsz (op_encode_hdr_maxsz + 4 + \ encode_verifier_maxsz) -#define decode_getdevicelist_maxsz (op_decode_hdr_maxsz + 2 + 1 + 1 + \ - decode_verifier_maxsz + \ - XDR_QUADLEN(NFS4_PNFS_GETDEVLIST_MAXNUM * \ - NFS4_PNFS_DEVICEID4_SIZE)) +#define decode_getdevicelist_maxsz (op_decode_hdr_maxsz + \ + 2 /* nfs_cookie4 gdlr_cookie */ + \ + decode_verifier_maxsz \ + /* verifier4 gdlr_verifier */ + \ + 1 /* gdlr_deviceid_list count */ + \ + XDR_QUADLEN(NFS4_PNFS_GETDEVLIST_MAXNUM * \ + NFS4_PNFS_DEVICEID4_SIZE) \ + /* gdlr_deviceid_list */ + \ + 1 /* bool gdlr_eof */)#define encode_getdeviceinfo_maxsz (op_encode_hdr_maxsz + 4 + \ XDR_QUADLEN(NFS4_PNFS_DEVICEID4_SIZE))#define decode_getdeviceinfo_maxsz (op_decode_hdr_maxsz + \
@@ -1868,6 +1873,7 @@ encode_getdevicelist(struct xdr_stream *xdr,xdr_encode_hyper (p,0ULL );/* cookie */ encode_nfs4_verifier (xdr, &dummy); hdr->nops++; + hdr->replen += decode_getdevicelist_maxsz; } static void
Signature · 1 line
1.7.2.2