Skip to content

Commit c9f1892

Browse files
hcleesmfrench
authored andcommitted
ksmbd: smbd: create MR pool
Create a memory region pool because rdma_rw_ctx_init() uses memory registration if memory registration yields better performance than using multiple SGE entries. Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Hyunchul Lee <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 41dbda1 commit c9f1892

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

fs/ksmbd/transport_rdma.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ static void free_transport(struct smb_direct_transport *t)
428428

429429
if (t->qp) {
430430
ib_drain_qp(t->qp);
431+
ib_mr_pool_destroy(t->qp, &t->qp->rdma_mrs);
431432
ib_destroy_qp(t->qp);
432433
}
433434

@@ -1708,7 +1709,9 @@ static int smb_direct_init_params(struct smb_direct_transport *t,
17081709
cap->max_send_sge = SMB_DIRECT_MAX_SEND_SGES;
17091710
cap->max_recv_sge = SMB_DIRECT_MAX_RECV_SGES;
17101711
cap->max_inline_data = 0;
1711-
cap->max_rdma_ctxs = 0;
1712+
cap->max_rdma_ctxs =
1713+
rdma_rw_mr_factor(device, t->cm_id->port_num, max_pages) *
1714+
smb_direct_max_outstanding_rw_ops;
17121715
return 0;
17131716
}
17141717

@@ -1790,6 +1793,7 @@ static int smb_direct_create_qpair(struct smb_direct_transport *t,
17901793
{
17911794
int ret;
17921795
struct ib_qp_init_attr qp_attr;
1796+
int pages_per_rw;
17931797

17941798
t->pd = ib_alloc_pd(t->cm_id->device, 0);
17951799
if (IS_ERR(t->pd)) {
@@ -1837,6 +1841,23 @@ static int smb_direct_create_qpair(struct smb_direct_transport *t,
18371841
t->qp = t->cm_id->qp;
18381842
t->cm_id->event_handler = smb_direct_cm_handler;
18391843

1844+
pages_per_rw = DIV_ROUND_UP(t->max_rdma_rw_size, PAGE_SIZE) + 1;
1845+
if (pages_per_rw > t->cm_id->device->attrs.max_sgl_rd) {
1846+
int pages_per_mr, mr_count;
1847+
1848+
pages_per_mr = min_t(int, pages_per_rw,
1849+
t->cm_id->device->attrs.max_fast_reg_page_list_len);
1850+
mr_count = DIV_ROUND_UP(pages_per_rw, pages_per_mr) *
1851+
atomic_read(&t->rw_avail_ops);
1852+
ret = ib_mr_pool_init(t->qp, &t->qp->rdma_mrs, mr_count,
1853+
IB_MR_TYPE_MEM_REG, pages_per_mr, 0);
1854+
if (ret) {
1855+
pr_err("failed to init mr pool count %d pages %d\n",
1856+
mr_count, pages_per_mr);
1857+
goto err;
1858+
}
1859+
}
1860+
18401861
return 0;
18411862
err:
18421863
if (t->qp) {

0 commit comments

Comments
 (0)