diff options
author | Long Li <longli@microsoft.com> | 2020-03-30 11:04:07 -0700 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2020-04-07 12:41:16 -0500 |
commit | 3ffbe78aff93586d3e09e8af4501c563ab367c75 (patch) | |
tree | b6450147a9a1092f6b445dcbde85dba5cba07b9d /fs/cifs/smbdirect.c | |
parent | 072a14ec6386829314ca96c725175ac1631360da (diff) |
cifs: smbd: Check send queue size before posting a send
Sometimes the remote peer may return more send credits than the send queue
depth. If all the send credits are used to post senasd, we may overflow the
send queue.
Fix this by checking the send queue size before posting a send.
Signed-off-by: Long Li <longli@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/smbdirect.c')
-rw-r--r-- | fs/cifs/smbdirect.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c index 79d8dcbd0034..c7ef2d7ce0ef 100644 --- a/fs/cifs/smbdirect.c +++ b/fs/cifs/smbdirect.c @@ -287,6 +287,7 @@ static void send_done(struct ib_cq *cq, struct ib_wc *wc) if (atomic_dec_and_test(&request->info->send_pending)) wake_up(&request->info->wait_send_pending); + wake_up(&request->info->wait_post_send); mempool_free(request, request->info->request_mempool); } @@ -939,7 +940,14 @@ static int smbd_post_send(struct smbd_connection *info, send_wr.opcode = IB_WR_SEND; send_wr.send_flags = IB_SEND_SIGNALED; - atomic_inc(&info->send_pending); +wait_sq: + wait_event(info->wait_post_send, + atomic_read(&info->send_pending) < info->send_credit_target); + if (unlikely(atomic_inc_return(&info->send_pending) > + info->send_credit_target)) { + atomic_dec(&info->send_pending); + goto wait_sq; + } rc = ib_post_send(info->id->qp, &send_wr, NULL); if (rc) { @@ -1733,6 +1741,7 @@ static struct smbd_connection *_smbd_get_connection( init_waitqueue_head(&info->wait_send_pending); atomic_set(&info->send_pending, 0); + init_waitqueue_head(&info->wait_post_send); INIT_WORK(&info->disconnect_work, smbd_disconnect_rdma_work); INIT_WORK(&info->post_send_credits_work, smbd_post_send_credits); |