Skip to content

Commit e607ef6

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: allocate enough space for MR WRs and ib_drain_qp()
The IB_WR_REG_MR and IB_WR_LOCAL_INV operations for smbdirect_mr_io structures should never fail because the submission or completion queues are too small. So we allocate more send_wr depending on the (local) max number of MRs. While there also add additional space for ib_drain_qp(). This should make sure ib_post_send() will never fail because the submission queue is full. Fixes: f198186 ("CIFS: SMBD: Establish SMB Direct connection") Fixes: cc55f65 ("smb: client: make use of common smbdirect_socket_parameters") Cc: [email protected] Cc: Steve French <[email protected]> Cc: Tom Talpey <[email protected]> Cc: Long Li <[email protected]> Cc: Namjae Jeon <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Stefan Metzmacher <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 211ddde commit e607ef6

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

fs/smb/client/smbdirect.c

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,7 @@ static struct smbd_connection *_smbd_get_connection(
17671767
struct smbdirect_socket *sc;
17681768
struct smbdirect_socket_parameters *sp;
17691769
struct rdma_conn_param conn_param;
1770+
struct ib_qp_cap qp_cap;
17701771
struct ib_qp_init_attr qp_attr;
17711772
struct sockaddr_in *addr_in = (struct sockaddr_in *) dstaddr;
17721773
struct ib_port_immutable port_immutable;
@@ -1838,6 +1839,25 @@ static struct smbd_connection *_smbd_get_connection(
18381839
goto config_failed;
18391840
}
18401841

1842+
sp->responder_resources =
1843+
min_t(u8, sp->responder_resources,
1844+
sc->ib.dev->attrs.max_qp_rd_atom);
1845+
log_rdma_mr(INFO, "responder_resources=%d\n",
1846+
sp->responder_resources);
1847+
1848+
/*
1849+
* We use allocate sp->responder_resources * 2 MRs
1850+
* and each MR needs WRs for REG and INV, so
1851+
* we use '* 4'.
1852+
*
1853+
* +1 for ib_drain_qp()
1854+
*/
1855+
memset(&qp_cap, 0, sizeof(qp_cap));
1856+
qp_cap.max_send_wr = sp->send_credit_target + sp->responder_resources * 4 + 1;
1857+
qp_cap.max_recv_wr = sp->recv_credit_max + 1;
1858+
qp_cap.max_send_sge = SMBDIRECT_SEND_IO_MAX_SGE;
1859+
qp_cap.max_recv_sge = SMBDIRECT_RECV_IO_MAX_SGE;
1860+
18411861
sc->ib.pd = ib_alloc_pd(sc->ib.dev, 0);
18421862
if (IS_ERR(sc->ib.pd)) {
18431863
rc = PTR_ERR(sc->ib.pd);
@@ -1848,15 +1868,15 @@ static struct smbd_connection *_smbd_get_connection(
18481868

18491869
sc->ib.send_cq =
18501870
ib_alloc_cq_any(sc->ib.dev, sc,
1851-
sp->send_credit_target, IB_POLL_SOFTIRQ);
1871+
qp_cap.max_send_wr, IB_POLL_SOFTIRQ);
18521872
if (IS_ERR(sc->ib.send_cq)) {
18531873
sc->ib.send_cq = NULL;
18541874
goto alloc_cq_failed;
18551875
}
18561876

18571877
sc->ib.recv_cq =
18581878
ib_alloc_cq_any(sc->ib.dev, sc,
1859-
sp->recv_credit_max, IB_POLL_SOFTIRQ);
1879+
qp_cap.max_recv_wr, IB_POLL_SOFTIRQ);
18601880
if (IS_ERR(sc->ib.recv_cq)) {
18611881
sc->ib.recv_cq = NULL;
18621882
goto alloc_cq_failed;
@@ -1865,11 +1885,7 @@ static struct smbd_connection *_smbd_get_connection(
18651885
memset(&qp_attr, 0, sizeof(qp_attr));
18661886
qp_attr.event_handler = smbd_qp_async_error_upcall;
18671887
qp_attr.qp_context = sc;
1868-
qp_attr.cap.max_send_wr = sp->send_credit_target;
1869-
qp_attr.cap.max_recv_wr = sp->recv_credit_max;
1870-
qp_attr.cap.max_send_sge = SMBDIRECT_SEND_IO_MAX_SGE;
1871-
qp_attr.cap.max_recv_sge = SMBDIRECT_RECV_IO_MAX_SGE;
1872-
qp_attr.cap.max_inline_data = 0;
1888+
qp_attr.cap = qp_cap;
18731889
qp_attr.sq_sig_type = IB_SIGNAL_REQ_WR;
18741890
qp_attr.qp_type = IB_QPT_RC;
18751891
qp_attr.send_cq = sc->ib.send_cq;
@@ -1883,12 +1899,6 @@ static struct smbd_connection *_smbd_get_connection(
18831899
}
18841900
sc->ib.qp = sc->rdma.cm_id->qp;
18851901

1886-
sp->responder_resources =
1887-
min_t(u8, sp->responder_resources,
1888-
sc->ib.dev->attrs.max_qp_rd_atom);
1889-
log_rdma_mr(INFO, "responder_resources=%d\n",
1890-
sp->responder_resources);
1891-
18921902
memset(&conn_param, 0, sizeof(conn_param));
18931903
conn_param.initiator_depth = sp->initiator_depth;
18941904
conn_param.responder_resources = sp->responder_resources;

0 commit comments

Comments
 (0)