Skip to content

Commit 56ab43f

Browse files
committed
svcrdma: Adjust the number of entries in svc_rdma_send_ctxt::sc_pages
Allow allocation of more entries in the sc_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 81381d1 commit 56ab43f

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

include/linux/sunrpc/svc_rdma.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ struct svc_rdma_send_ctxt {
245245
void *sc_xprt_buf;
246246
int sc_page_count;
247247
int sc_cur_sge_no;
248-
struct page *sc_pages[RPCSVC_MAXPAGES];
248+
unsigned long sc_maxpages;
249+
struct page **sc_pages;
249250
struct ib_sge sc_sges[];
250251
};
251252

net/sunrpc/xprtrdma/svc_rdma_sendto.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ svc_rdma_send_ctxt_alloc(struct svcxprt_rdma *rdma)
118118
{
119119
int node = ibdev_to_node(rdma->sc_cm_id->device);
120120
struct svc_rdma_send_ctxt *ctxt;
121+
unsigned long pages;
121122
dma_addr_t addr;
122123
void *buffer;
123124
int i;
@@ -126,13 +127,19 @@ svc_rdma_send_ctxt_alloc(struct svcxprt_rdma *rdma)
126127
GFP_KERNEL, node);
127128
if (!ctxt)
128129
goto fail0;
130+
pages = svc_serv_maxpages(rdma->sc_xprt.xpt_server);
131+
ctxt->sc_pages = kcalloc_node(pages, sizeof(struct page *),
132+
GFP_KERNEL, node);
133+
if (!ctxt->sc_pages)
134+
goto fail1;
135+
ctxt->sc_maxpages = pages;
129136
buffer = kmalloc_node(rdma->sc_max_req_size, GFP_KERNEL, node);
130137
if (!buffer)
131-
goto fail1;
138+
goto fail2;
132139
addr = ib_dma_map_single(rdma->sc_pd->device, buffer,
133140
rdma->sc_max_req_size, DMA_TO_DEVICE);
134141
if (ib_dma_mapping_error(rdma->sc_pd->device, addr))
135-
goto fail2;
142+
goto fail3;
136143

137144
svc_rdma_send_cid_init(rdma, &ctxt->sc_cid);
138145

@@ -151,8 +158,10 @@ svc_rdma_send_ctxt_alloc(struct svcxprt_rdma *rdma)
151158
ctxt->sc_sges[i].lkey = rdma->sc_pd->local_dma_lkey;
152159
return ctxt;
153160

154-
fail2:
161+
fail3:
155162
kfree(buffer);
163+
fail2:
164+
kfree(ctxt->sc_pages);
156165
fail1:
157166
kfree(ctxt);
158167
fail0:
@@ -176,6 +185,7 @@ void svc_rdma_send_ctxts_destroy(struct svcxprt_rdma *rdma)
176185
rdma->sc_max_req_size,
177186
DMA_TO_DEVICE);
178187
kfree(ctxt->sc_xprt_buf);
188+
kfree(ctxt->sc_pages);
179189
kfree(ctxt);
180190
}
181191
}

0 commit comments

Comments
 (0)