Skip to content

Commit 5a0d5ae

Browse files
metze-sambasmfrench
authored andcommitted
smb: client: make only use of wake_up[_all]() in smbdirect.c
wake_up_interruptible[_all]() doesn't wake up tasks waiting with wait_event(). So we better wake_up[_all]() in order to wake up all tasks in order to simplify the logic. As we currently don't use any wait_event_*_exclusive() it doesn't really matter if we use wake_up() or wake_up_all(). But in this patch I try to use wake_up() for expected situations and wake_up_all() for situations of a broken connection. So don't need to adjust things in future when we may use wait_event_*_exclusive() in order to wake up only one process that should make progress. Changing the wait_event_*() code in order to keep wait_event(), wait_event_interruptible() and wait_event_interruptible_timeout() or changing them to wait_event_killable(), wait_event_killable_timeout(), wait_event_killable_exclusive() is something to think about in a future patch. The goal here is to avoid that some tasks are not woken and freeze forever. Also note that this patch only changes the existing wake_up*() calls. Adding more wake_up*() calls for other wait queues is also deferred to a future patch. Link: https://lore.kernel.org/linux-cifs/13851363-0dc9-465c-9ced-3ede4904eef0@samba.org/T/#t Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: Long Li <longli@microsoft.com> Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent d9140ef commit 5a0d5ae

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

fs/smb/client/smbdirect.c

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -217,27 +217,27 @@ static int smbd_conn_upcall(
217217
case RDMA_CM_EVENT_ADDR_RESOLVED:
218218
WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RESOLVE_ADDR_RUNNING);
219219
sc->status = SMBDIRECT_SOCKET_RESOLVE_ROUTE_NEEDED;
220-
wake_up_interruptible(&sc->status_wait);
220+
wake_up(&sc->status_wait);
221221
break;
222222

223223
case RDMA_CM_EVENT_ROUTE_RESOLVED:
224224
WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RESOLVE_ROUTE_RUNNING);
225225
sc->status = SMBDIRECT_SOCKET_RDMA_CONNECT_NEEDED;
226-
wake_up_interruptible(&sc->status_wait);
226+
wake_up(&sc->status_wait);
227227
break;
228228

229229
case RDMA_CM_EVENT_ADDR_ERROR:
230230
log_rdma_event(ERR, "connecting failed event=%s\n", event_name);
231231
WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RESOLVE_ADDR_RUNNING);
232232
sc->status = SMBDIRECT_SOCKET_RESOLVE_ADDR_FAILED;
233-
wake_up_interruptible(&sc->status_wait);
233+
wake_up_all(&sc->status_wait);
234234
break;
235235

236236
case RDMA_CM_EVENT_ROUTE_ERROR:
237237
log_rdma_event(ERR, "connecting failed event=%s\n", event_name);
238238
WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RESOLVE_ROUTE_RUNNING);
239239
sc->status = SMBDIRECT_SOCKET_RESOLVE_ROUTE_FAILED;
240-
wake_up_interruptible(&sc->status_wait);
240+
wake_up_all(&sc->status_wait);
241241
break;
242242

243243
case RDMA_CM_EVENT_ESTABLISHED:
@@ -323,7 +323,7 @@ static int smbd_conn_upcall(
323323

324324
WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RDMA_CONNECT_RUNNING);
325325
sc->status = SMBDIRECT_SOCKET_NEGOTIATE_NEEDED;
326-
wake_up_interruptible(&sc->status_wait);
326+
wake_up(&sc->status_wait);
327327
break;
328328

329329
case RDMA_CM_EVENT_CONNECT_ERROR:
@@ -332,7 +332,7 @@ static int smbd_conn_upcall(
332332
log_rdma_event(ERR, "connecting failed event=%s\n", event_name);
333333
WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_RDMA_CONNECT_RUNNING);
334334
sc->status = SMBDIRECT_SOCKET_RDMA_CONNECT_FAILED;
335-
wake_up_interruptible(&sc->status_wait);
335+
wake_up_all(&sc->status_wait);
336336
break;
337337

338338
case RDMA_CM_EVENT_DEVICE_REMOVAL:
@@ -341,14 +341,14 @@ static int smbd_conn_upcall(
341341
if (sc->status == SMBDIRECT_SOCKET_NEGOTIATE_FAILED) {
342342
log_rdma_event(ERR, "event=%s during negotiation\n", event_name);
343343
sc->status = SMBDIRECT_SOCKET_DISCONNECTED;
344-
wake_up(&sc->status_wait);
344+
wake_up_all(&sc->status_wait);
345345
break;
346346
}
347347

348348
sc->status = SMBDIRECT_SOCKET_DISCONNECTED;
349-
wake_up_interruptible(&sc->status_wait);
350-
wake_up_interruptible(&sc->recv_io.reassembly.wait_queue);
351-
wake_up_interruptible_all(&info->wait_send_queue);
349+
wake_up_all(&sc->status_wait);
350+
wake_up_all(&sc->recv_io.reassembly.wait_queue);
351+
wake_up_all(&info->wait_send_queue);
352352
break;
353353

354354
default:
@@ -525,7 +525,7 @@ static void smbd_post_send_credits(struct work_struct *work)
525525
struct smbdirect_socket *sc = &info->socket;
526526

527527
if (sc->status != SMBDIRECT_SOCKET_CONNECTED) {
528-
wake_up(&info->wait_receive_queues);
528+
wake_up_all(&info->wait_receive_queues);
529529
return;
530530
}
531531

@@ -605,12 +605,14 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
605605
process_negotiation_response(response, wc->byte_len);
606606
put_receive_buffer(info, response);
607607
WARN_ON_ONCE(sc->status != SMBDIRECT_SOCKET_NEGOTIATE_RUNNING);
608-
if (!negotiate_done)
608+
if (!negotiate_done) {
609609
sc->status = SMBDIRECT_SOCKET_NEGOTIATE_FAILED;
610-
else
610+
wake_up_all(&sc->status_wait);
611+
} else {
611612
sc->status = SMBDIRECT_SOCKET_CONNECTED;
613+
wake_up(&sc->status_wait);
614+
}
612615

613-
wake_up_interruptible(&sc->status_wait);
614616
return;
615617

616618
/* SMBD data transfer packet */
@@ -653,7 +655,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
653655
* We have new send credits granted from remote peer
654656
* If any sender is waiting for credits, unblock it
655657
*/
656-
wake_up_interruptible(&info->wait_send_queue);
658+
wake_up(&info->wait_send_queue);
657659
}
658660

659661
log_incoming(INFO, "data flags %d data_offset %d data_length %d remaining_data_length %d\n",
@@ -675,7 +677,7 @@ static void recv_done(struct ib_cq *cq, struct ib_wc *wc)
675677
*/
676678
if (data_length) {
677679
enqueue_reassembly(info, response, data_length);
678-
wake_up_interruptible(&sc->recv_io.reassembly.wait_queue);
680+
wake_up(&sc->recv_io.reassembly.wait_queue);
679681
} else
680682
put_receive_buffer(info, response);
681683

@@ -1536,7 +1538,7 @@ void smbd_destroy(struct TCP_Server_Info *server)
15361538
* path when sending data, and then release memory registrations.
15371539
*/
15381540
log_rdma_event(INFO, "freeing mr list\n");
1539-
wake_up_interruptible_all(&info->wait_mr);
1541+
wake_up_all(&info->wait_mr);
15401542
while (atomic_read(&info->mr_used_count)) {
15411543
cifs_server_unlock(server);
15421544
msleep(1000);
@@ -2235,7 +2237,7 @@ static void smbd_mr_recovery_work(struct work_struct *work)
22352237
* get_mr() from the I/O issuing CPUs
22362238
*/
22372239
if (atomic_inc_return(&info->mr_ready_count) == 1)
2238-
wake_up_interruptible(&info->wait_mr);
2240+
wake_up(&info->wait_mr);
22392241
}
22402242
}
22412243

@@ -2546,7 +2548,7 @@ int smbd_deregister_mr(struct smbd_mr *smbdirect_mr)
25462548
smbdirect_mr->dir);
25472549
smbdirect_mr->state = MR_READY;
25482550
if (atomic_inc_return(&info->mr_ready_count) == 1)
2549-
wake_up_interruptible(&info->wait_mr);
2551+
wake_up(&info->wait_mr);
25502552
} else
25512553
/*
25522554
* Schedule the work to do MR recovery for future I/Os MR

0 commit comments

Comments
 (0)