Skip to content

Commit 79160f2

Browse files
pcd1193182Delphix Engineering
authored and
Delphix Engineering
committed
target: login should wait until tx/rx threads have properly started. (#21)
1 parent 6b04c4c commit 79160f2

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

drivers/target/iscsi/iscsi_target.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3815,6 +3815,7 @@ int iscsi_target_tx_thread(void *arg)
38153815
* connection recovery / failure event can be triggered externally.
38163816
*/
38173817
allow_signal(SIGINT);
3818+
complete(&conn->kthr_start_comp);
38183819

38193820
while (!kthread_should_stop()) {
38203821
/*
@@ -4043,6 +4044,7 @@ int iscsi_target_rx_thread(void *arg)
40434044
* connection recovery / failure event can be triggered externally.
40444045
*/
40454046
allow_signal(SIGINT);
4047+
complete(&conn->kthr_start_comp);
40464048
/*
40474049
* Wait for iscsi_post_login_handler() to complete before allowing
40484050
* incoming iscsi/tcp socket I/O, and/or failing the connection.

drivers/target/iscsi/iscsi_target_login.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ int iscsit_start_kthreads(struct iscsi_conn *conn)
647647
ret = PTR_ERR(conn->tx_thread);
648648
goto out_bitmap;
649649
}
650+
wait_for_completion(&conn->kthr_start_comp);
650651
conn->tx_thread_active = true;
651652

652653
conn->rx_thread = kthread_run(iscsi_target_rx_thread, conn,
@@ -656,6 +657,7 @@ int iscsit_start_kthreads(struct iscsi_conn *conn)
656657
ret = PTR_ERR(conn->rx_thread);
657658
goto out_tx;
658659
}
660+
wait_for_completion(&conn->kthr_start_comp);
659661
conn->rx_thread_active = true;
660662

661663
return 0;
@@ -1104,6 +1106,7 @@ static struct iscsi_conn *iscsit_alloc_conn(struct iscsi_np *np)
11041106
init_completion(&conn->rx_half_close_comp);
11051107
init_completion(&conn->tx_half_close_comp);
11061108
init_completion(&conn->rx_login_comp);
1109+
init_completion(&conn->kthr_start_comp);
11071110
spin_lock_init(&conn->cmd_lock);
11081111
spin_lock_init(&conn->conn_usage_lock);
11091112
spin_lock_init(&conn->immed_queue_lock);

include/target/iscsi/iscsi_target_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ struct iscsi_conn {
552552
struct completion conn_logout_comp;
553553
struct completion tx_half_close_comp;
554554
struct completion rx_half_close_comp;
555+
struct completion kthr_start_comp;
555556
/* socket used by this connection */
556557
struct socket *sock;
557558
void (*orig_data_ready)(struct sock *);

0 commit comments

Comments
 (0)