Skip to content

Commit 81381d1

Browse files
committed
svcrdma: Adjust the number of entries in svc_rdma_recv_ctxt::rc_pages
Allow allocation of more entries in the rc_pages[] array when the maximum size of an RPC message is increased. Reviewed-by: Jeff Layton <[email protected]> Reviewed-by: NeilBrown <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent f412682 commit 81381d1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

include/linux/sunrpc/svc_rdma.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ struct svc_rdma_recv_ctxt {
202202
struct svc_rdma_pcl rc_reply_pcl;
203203

204204
unsigned int rc_page_count;
205-
struct page *rc_pages[RPCSVC_MAXPAGES];
205+
unsigned long rc_maxpages;
206+
struct page *rc_pages[] __counted_by(rc_maxpages);
206207
};
207208

208209
/*

net/sunrpc/xprtrdma/svc_rdma_recvfrom.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,16 @@ svc_rdma_recv_ctxt_alloc(struct svcxprt_rdma *rdma)
120120
{
121121
int node = ibdev_to_node(rdma->sc_cm_id->device);
122122
struct svc_rdma_recv_ctxt *ctxt;
123+
unsigned long pages;
123124
dma_addr_t addr;
124125
void *buffer;
125126

126-
ctxt = kzalloc_node(sizeof(*ctxt), GFP_KERNEL, node);
127+
pages = svc_serv_maxpages(rdma->sc_xprt.xpt_server);
128+
ctxt = kzalloc_node(struct_size(ctxt, rc_pages, pages),
129+
GFP_KERNEL, node);
127130
if (!ctxt)
128131
goto fail0;
132+
ctxt->rc_maxpages = pages;
129133
buffer = kmalloc_node(rdma->sc_max_req_size, GFP_KERNEL, node);
130134
if (!buffer)
131135
goto fail1;
@@ -497,7 +501,7 @@ static bool xdr_check_write_chunk(struct svc_rdma_recv_ctxt *rctxt)
497501
* a computation, perform a simple range check. This is an
498502
* arbitrary but sensible limit (ie, not architectural).
499503
*/
500-
if (unlikely(segcount > RPCSVC_MAXPAGES))
504+
if (unlikely(segcount > rctxt->rc_maxpages))
501505
return false;
502506

503507
p = xdr_inline_decode(&rctxt->rc_stream,

0 commit comments

Comments
 (0)