Skip to content

Commit d2e81f9

Browse files
TTalpeysmfrench
authored andcommitted
Decrease the number of SMB3 smbdirect client SGEs
The client-side SMBDirect layer requires no more than 6 send SGEs and 1 receive SGE. The previous default of 8 send and 8 receive causes smbdirect to fail on the SoftiWARP (siw) provider, and possibly others. Additionally, large numbers of SGEs reduces performance significantly on adapter implementations. Also correct the frmr page count comment (not an SGE count). Acked-by: Paulo Alcantara (SUSE) <[email protected]> Signed-off-by: Tom Talpey <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent e98ecc6 commit d2e81f9

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

fs/cifs/smbdirect.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ int smbd_keep_alive_interval = 120;
9999
* User configurable initial values for RDMA transport
100100
* The actual values used may be lower and are limited to hardware capabilities
101101
*/
102-
/* Default maximum number of SGEs in a RDMA write/read */
102+
/* Default maximum number of pages in a single RDMA write/read */
103103
int smbd_max_frmr_depth = 2048;
104104

105105
/* If payload is less than this byte, use RDMA send/recv not read/write */
@@ -1017,9 +1017,9 @@ static int smbd_post_send_data(
10171017
{
10181018
int i;
10191019
u32 data_length = 0;
1020-
struct scatterlist sgl[SMBDIRECT_MAX_SGE];
1020+
struct scatterlist sgl[SMBDIRECT_MAX_SEND_SGE - 1];
10211021

1022-
if (n_vec > SMBDIRECT_MAX_SGE) {
1022+
if (n_vec > SMBDIRECT_MAX_SEND_SGE - 1) {
10231023
cifs_dbg(VFS, "Can't fit data to SGL, n_vec=%d\n", n_vec);
10241024
return -EINVAL;
10251025
}
@@ -1562,17 +1562,15 @@ static struct smbd_connection *_smbd_get_connection(
15621562
info->max_receive_size = smbd_max_receive_size;
15631563
info->keep_alive_interval = smbd_keep_alive_interval;
15641564

1565-
if (info->id->device->attrs.max_send_sge < SMBDIRECT_MAX_SGE) {
1565+
if (info->id->device->attrs.max_send_sge < SMBDIRECT_MAX_SEND_SGE ||
1566+
info->id->device->attrs.max_recv_sge < SMBDIRECT_MAX_RECV_SGE) {
15661567
log_rdma_event(ERR,
1567-
"warning: device max_send_sge = %d too small\n",
1568-
info->id->device->attrs.max_send_sge);
1569-
log_rdma_event(ERR, "Queue Pair creation may fail\n");
1570-
}
1571-
if (info->id->device->attrs.max_recv_sge < SMBDIRECT_MAX_SGE) {
1572-
log_rdma_event(ERR,
1573-
"warning: device max_recv_sge = %d too small\n",
1568+
"device %.*s max_send_sge/max_recv_sge = %d/%d too small\n",
1569+
IB_DEVICE_NAME_MAX,
1570+
info->id->device->name,
1571+
info->id->device->attrs.max_send_sge,
15741572
info->id->device->attrs.max_recv_sge);
1575-
log_rdma_event(ERR, "Queue Pair creation may fail\n");
1573+
goto config_failed;
15761574
}
15771575

15781576
info->send_cq = NULL;
@@ -1598,8 +1596,8 @@ static struct smbd_connection *_smbd_get_connection(
15981596
qp_attr.qp_context = info;
15991597
qp_attr.cap.max_send_wr = info->send_credit_target;
16001598
qp_attr.cap.max_recv_wr = info->receive_credit_max;
1601-
qp_attr.cap.max_send_sge = SMBDIRECT_MAX_SGE;
1602-
qp_attr.cap.max_recv_sge = SMBDIRECT_MAX_SGE;
1599+
qp_attr.cap.max_send_sge = SMBDIRECT_MAX_SEND_SGE;
1600+
qp_attr.cap.max_recv_sge = SMBDIRECT_MAX_RECV_SGE;
16031601
qp_attr.cap.max_inline_data = 0;
16041602
qp_attr.sq_sig_type = IB_SIGNAL_REQ_WR;
16051603
qp_attr.qp_type = IB_QPT_RC;

fs/cifs/smbdirect.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ struct smbd_connection {
9191
/* Memory registrations */
9292
/* Maximum number of RDMA read/write outstanding on this connection */
9393
int responder_resources;
94-
/* Maximum number of SGEs in a RDMA write/read */
94+
/* Maximum number of pages in a single RDMA write/read on this connection */
9595
int max_frmr_depth;
9696
/*
9797
* If payload is less than or equal to the threshold,
@@ -225,21 +225,25 @@ struct smbd_buffer_descriptor_v1 {
225225
__le32 length;
226226
} __packed;
227227

228-
/* Default maximum number of SGEs in a RDMA send/recv */
229-
#define SMBDIRECT_MAX_SGE 16
228+
/* Maximum number of SGEs used by smbdirect.c in any send work request */
229+
#define SMBDIRECT_MAX_SEND_SGE 6
230+
230231
/* The context for a SMBD request */
231232
struct smbd_request {
232233
struct smbd_connection *info;
233234
struct ib_cqe cqe;
234235

235-
/* the SGE entries for this packet */
236-
struct ib_sge sge[SMBDIRECT_MAX_SGE];
236+
/* the SGE entries for this work request */
237+
struct ib_sge sge[SMBDIRECT_MAX_SEND_SGE];
237238
int num_sge;
238239

239240
/* SMBD packet header follows this structure */
240241
u8 packet[];
241242
};
242243

244+
/* Maximum number of SGEs used by smbdirect.c in any receive work request */
245+
#define SMBDIRECT_MAX_RECV_SGE 1
246+
243247
/* The context for a SMBD response */
244248
struct smbd_response {
245249
struct smbd_connection *info;

0 commit comments

Comments
 (0)