iscsi: Refactor spdk_iscsi_conn_destruct() as a preparation to fix the issue

The next patch will change spdk_iscsi_conn_destruct() to fix the
Github issue #457. This patch is a preparation to that.

Change-Id: Iaf1c8a3fe8514d6bbd9f61f19f87b0bb2c27e76e
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/430402
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Piotr Pelpliński <piotr.pelplinski@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2018-10-23 12:55:05 +09:00 committed by Jim Harris
parent 3f12b5fa1e
commit c18562d694

View File

@ -474,15 +474,18 @@ static void
spdk_iscsi_conn_cleanup_backend(struct spdk_iscsi_conn *conn) spdk_iscsi_conn_cleanup_backend(struct spdk_iscsi_conn *conn)
{ {
int rc; int rc;
struct spdk_iscsi_tgt_node *target;
if (conn->sess->connections > 1) { if (conn->sess->connections > 1) {
/* connection specific cleanup */ /* connection specific cleanup */
} else if (!g_spdk_iscsi.AllowDuplicateIsid) { } else if (!g_spdk_iscsi.AllowDuplicateIsid) {
/* clean up all tasks to all LUNs for session */ /* clean up all tasks to all LUNs for session */
rc = spdk_iscsi_tgt_node_cleanup_luns(conn, target = conn->sess->target;
conn->sess->target); if (target != NULL) {
if (rc < 0) { rc = spdk_iscsi_tgt_node_cleanup_luns(conn, target);
SPDK_ERRLOG("target abort failed\n"); if (rc < 0) {
SPDK_ERRLOG("target abort failed\n");
}
} }
} }
} }
@ -517,16 +520,12 @@ _spdk_iscsi_conn_check_shutdown(void *arg)
void void
spdk_iscsi_conn_destruct(struct spdk_iscsi_conn *conn) spdk_iscsi_conn_destruct(struct spdk_iscsi_conn *conn)
{ {
struct spdk_iscsi_tgt_node *target; int rc;
int rc;
conn->state = ISCSI_CONN_STATE_EXITED; conn->state = ISCSI_CONN_STATE_EXITED;
if (conn->sess != NULL && conn->pending_task_cnt > 0) { if (conn->sess != NULL && conn->pending_task_cnt > 0) {
target = conn->sess->target; spdk_iscsi_conn_cleanup_backend(conn);
if (target != NULL) {
spdk_iscsi_conn_cleanup_backend(conn);
}
} }
spdk_clear_all_transfer_task(conn, NULL); spdk_clear_all_transfer_task(conn, NULL);