Skip to content

Commit 52012ae

Browse files
pcd1193182palash-gandhi
authored andcommitted
target: login should wait until tx/rx threads have properly started. (#21)
1 parent 0768aea commit 52012ae

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
@@ -3922,6 +3922,7 @@ int iscsi_target_tx_thread(void *arg)
39223922
* connection recovery / failure event can be triggered externally.
39233923
*/
39243924
allow_signal(SIGINT);
3925+
complete(&conn->kthr_start_comp);
39253926

39263927
while (!kthread_should_stop()) {
39273928
/*
@@ -4170,6 +4171,7 @@ int iscsi_target_rx_thread(void *arg)
41704171
* connection recovery / failure event can be triggered externally.
41714172
*/
41724173
allow_signal(SIGINT);
4174+
complete(&conn->kthr_start_comp);
41734175
/*
41744176
* Wait for iscsi_post_login_handler() to complete before allowing
41754177
* 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
@@ -660,6 +660,7 @@ int iscsit_start_kthreads(struct iscsit_conn *conn)
660660
ret = PTR_ERR(conn->tx_thread);
661661
goto out_bitmap;
662662
}
663+
wait_for_completion(&conn->kthr_start_comp);
663664
conn->tx_thread_active = true;
664665

665666
conn->rx_thread = kthread_run(iscsi_target_rx_thread, conn,
@@ -669,6 +670,7 @@ int iscsit_start_kthreads(struct iscsit_conn *conn)
669670
ret = PTR_ERR(conn->rx_thread);
670671
goto out_tx;
671672
}
673+
wait_for_completion(&conn->kthr_start_comp);
672674
conn->rx_thread_active = true;
673675

674676
return 0;
@@ -1064,6 +1066,7 @@ static struct iscsit_conn *iscsit_alloc_conn(struct iscsi_np *np)
10641066
init_completion(&conn->rx_half_close_comp);
10651067
init_completion(&conn->tx_half_close_comp);
10661068
init_completion(&conn->rx_login_comp);
1069+
init_completion(&conn->kthr_start_comp);
10671070
spin_lock_init(&conn->cmd_lock);
10681071
spin_lock_init(&conn->conn_usage_lock);
10691072
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
@@ -550,6 +550,7 @@ struct iscsit_conn {
550550
struct completion conn_logout_comp;
551551
struct completion tx_half_close_comp;
552552
struct completion rx_half_close_comp;
553+
struct completion kthr_start_comp;
553554
/* socket used by this connection */
554555
struct socket *sock;
555556
void (*orig_data_ready)(struct sock *);

0 commit comments

Comments
 (0)