Shutdown the network portal thread and close the socket without freeing the np structure, so that it can be reused later. Signed-off-by: David Disseldorp <ddiss@xxxxxxx> --- drivers/target/iscsi/iscsi_target.c | 32 ++++++++++++++++++++++++++++++++ drivers/target/iscsi/iscsi_target.h | 2 ++ 2 files changed, 34 insertions(+) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 6b78061..e730249 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -450,6 +450,38 @@ int iscsit_reset_np_thread( return 0; } +int iscsit_shutdown_np_thread( + struct iscsi_np *np, + struct iscsi_tpg_np *tpg_np, + struct iscsi_portal_group *tpg) +{ + spin_lock_bh(&np->np_thread_lock); + if (np->np_thread_state == ISCSI_NP_THREAD_INACTIVE) { + spin_unlock_bh(&np->np_thread_lock); + return 0; + } + np->np_thread_state = ISCSI_NP_THREAD_SHUTDOWN; + spin_unlock_bh(&np->np_thread_lock); + + if (np->np_thread) { + /* + * We need to send the signal to wakeup Linux/Net + * which may be sleeping in sock_accept().. + */ + send_sig(SIGINT, np->np_thread, 1); + kthread_stop(np->np_thread); + np->np_thread = NULL; + WARN_ON(np->np_thread_state != ISCSI_NP_THREAD_EXIT); + np->np_thread_state = ISCSI_NP_THREAD_INACTIVE; + } + + /* close socket */ + np->np_transport->iscsit_free_np(np); + np->enabled = false; + + return 0; +} + int iscsit_enable_np_thread( struct iscsi_np *np) { diff --git a/drivers/target/iscsi/iscsi_target.h b/drivers/target/iscsi/iscsi_target.h index 398a23d..86051fa 100644 --- a/drivers/target/iscsi/iscsi_target.h +++ b/drivers/target/iscsi/iscsi_target.h @@ -16,6 +16,8 @@ extern struct iscsi_np *iscsit_add_np(struct __kernel_sockaddr_storage *, char *, int); extern int iscsit_reset_np_thread(struct iscsi_np *, struct iscsi_tpg_np *, struct iscsi_portal_group *, bool); +extern int iscsit_shutdown_np_thread(struct iscsi_np *, struct iscsi_tpg_np *, + struct iscsi_portal_group *); int iscsit_enable_np_thread(struct iscsi_np *); extern int iscsit_del_np(struct iscsi_np *); extern int iscsit_reject_cmd(struct iscsi_cmd *cmd, u8, unsigned char *); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html