Skip to content

Commit 08842c6

Browse files
pcd1193182Delphix Engineering
authored and
Delphix Engineering
committed
target: login should wait until tx/rx threads have properly started. (#21)
1 parent 24ab726 commit 08842c6

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
@@ -3813,6 +3813,7 @@ int iscsi_target_tx_thread(void *arg)
38133813
* connection recovery / failure event can be triggered externally.
38143814
*/
38153815
allow_signal(SIGINT);
3816+
complete(&conn->kthr_start_comp);
38163817

38173818
while (!kthread_should_stop()) {
38183819
/*
@@ -4041,6 +4042,7 @@ int iscsi_target_rx_thread(void *arg)
40414042
* connection recovery / failure event can be triggered externally.
40424043
*/
40434044
allow_signal(SIGINT);
4045+
complete(&conn->kthr_start_comp);
40444046
/*
40454047
* Wait for iscsi_post_login_handler() to complete before allowing
40464048
* 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
@@ -646,6 +646,7 @@ int iscsit_start_kthreads(struct iscsi_conn *conn)
646646
ret = PTR_ERR(conn->tx_thread);
647647
goto out_bitmap;
648648
}
649+
wait_for_completion(&conn->kthr_start_comp);
649650
conn->tx_thread_active = true;
650651

651652
conn->rx_thread = kthread_run(iscsi_target_rx_thread, conn,
@@ -655,6 +656,7 @@ int iscsit_start_kthreads(struct iscsi_conn *conn)
655656
ret = PTR_ERR(conn->rx_thread);
656657
goto out_tx;
657658
}
659+
wait_for_completion(&conn->kthr_start_comp);
658660
conn->rx_thread_active = true;
659661

660662
return 0;
@@ -1127,6 +1129,7 @@ static struct iscsi_conn *iscsit_alloc_conn(struct iscsi_np *np)
11271129
init_completion(&conn->rx_half_close_comp);
11281130
init_completion(&conn->tx_half_close_comp);
11291131
init_completion(&conn->rx_login_comp);
1132+
init_completion(&conn->kthr_start_comp);
11301133
spin_lock_init(&conn->cmd_lock);
11311134
spin_lock_init(&conn->conn_usage_lock);
11321135
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
@@ -562,6 +562,7 @@ struct iscsi_conn {
562562
struct completion conn_logout_comp;
563563
struct completion tx_half_close_comp;
564564
struct completion rx_half_close_comp;
565+
struct completion kthr_start_comp;
565566
/* socket used by this connection */
566567
struct socket *sock;
567568
void (*orig_data_ready)(struct sock *);

0 commit comments

Comments
 (0)