Skip to content

Commit

Permalink
target: login should wait until tx/rx threads have properly started. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pcd1193182 authored and Delphix Engineering committed Nov 18, 2022
1 parent 9c48035 commit 596ac27
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/target/iscsi/iscsi_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -3813,6 +3813,7 @@ int iscsi_target_tx_thread(void *arg)
* connection recovery / failure event can be triggered externally.
*/
allow_signal(SIGINT);
complete(&conn->kthr_start_comp);

while (!kthread_should_stop()) {
/*
Expand Down Expand Up @@ -4041,6 +4042,7 @@ int iscsi_target_rx_thread(void *arg)
* connection recovery / failure event can be triggered externally.
*/
allow_signal(SIGINT);
complete(&conn->kthr_start_comp);
/*
* Wait for iscsi_post_login_handler() to complete before allowing
* incoming iscsi/tcp socket I/O, and/or failing the connection.
Expand Down
3 changes: 3 additions & 0 deletions drivers/target/iscsi/iscsi_target_login.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ int iscsit_start_kthreads(struct iscsi_conn *conn)
ret = PTR_ERR(conn->tx_thread);
goto out_bitmap;
}
wait_for_completion(&conn->kthr_start_comp);
conn->tx_thread_active = true;

conn->rx_thread = kthread_run(iscsi_target_rx_thread, conn,
Expand All @@ -655,6 +656,7 @@ int iscsit_start_kthreads(struct iscsi_conn *conn)
ret = PTR_ERR(conn->rx_thread);
goto out_tx;
}
wait_for_completion(&conn->kthr_start_comp);
conn->rx_thread_active = true;

return 0;
Expand Down Expand Up @@ -1127,6 +1129,7 @@ static struct iscsi_conn *iscsit_alloc_conn(struct iscsi_np *np)
init_completion(&conn->rx_half_close_comp);
init_completion(&conn->tx_half_close_comp);
init_completion(&conn->rx_login_comp);
init_completion(&conn->kthr_start_comp);
spin_lock_init(&conn->cmd_lock);
spin_lock_init(&conn->conn_usage_lock);
spin_lock_init(&conn->immed_queue_lock);
Expand Down
1 change: 1 addition & 0 deletions include/target/iscsi/iscsi_target_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ struct iscsi_conn {
struct completion conn_logout_comp;
struct completion tx_half_close_comp;
struct completion rx_half_close_comp;
struct completion kthr_start_comp;
/* socket used by this connection */
struct socket *sock;
void (*orig_data_ready)(struct sock *);
Expand Down

0 comments on commit 596ac27

Please sign in to comment.