Skip to content

Commit 8d18f6c

Browse files
committed
NFSv4.2: Fix READ_PLUS size calculations
I bump the decode_read_plus_maxsz to account for hole segments, but I need to subtract out this increase when calling rpc_prepare_reply_pages() so the common case of single data segment replies can be directly placed into the xdr pages without needing to be shifted around. Reported-by: Chuck Lever <chuck.lever@oracle.com> Fixes: d3b00a8 ("NFS: Replace the READ_PLUS decoding code") Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent bb05a61 commit 8d18f6c

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

fs/nfs/nfs42xdr.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,16 @@
5454
(1 /* data_content4 */ + \
5555
2 /* data_info4.di_offset */ + \
5656
1 /* data_info4.di_length */)
57+
#define NFS42_READ_PLUS_HOLE_SEGMENT_SIZE \
58+
(1 /* data_content4 */ + \
59+
2 /* data_info4.di_offset */ + \
60+
2 /* data_info4.di_length */)
61+
#define READ_PLUS_SEGMENT_SIZE_DIFF (NFS42_READ_PLUS_HOLE_SEGMENT_SIZE - \
62+
NFS42_READ_PLUS_DATA_SEGMENT_SIZE)
5763
#define decode_read_plus_maxsz (op_decode_hdr_maxsz + \
5864
1 /* rpr_eof */ + \
5965
1 /* rpr_contents count */ + \
60-
NFS42_READ_PLUS_DATA_SEGMENT_SIZE)
66+
NFS42_READ_PLUS_HOLE_SEGMENT_SIZE)
6167
#define encode_seek_maxsz (op_encode_hdr_maxsz + \
6268
encode_stateid_maxsz + \
6369
2 /* offset */ + \
@@ -617,8 +623,8 @@ static void nfs4_xdr_enc_read_plus(struct rpc_rqst *req,
617623
encode_putfh(xdr, args->fh, &hdr);
618624
encode_read_plus(xdr, args, &hdr);
619625

620-
rpc_prepare_reply_pages(req, args->pages, args->pgbase,
621-
args->count, hdr.replen);
626+
rpc_prepare_reply_pages(req, args->pages, args->pgbase, args->count,
627+
hdr.replen - READ_PLUS_SEGMENT_SIZE_DIFF);
622628
encode_nops(&hdr);
623629
}
624630

0 commit comments

Comments
 (0)