From c18562d69459dac4cf14f8f301486945202d09a6 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Tue, 23 Oct 2018 12:55:05 +0900 Subject: [PATCH] iscsi: Refactor spdk_iscsi_conn_destruct() as a preparation to fix the issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-on: https://review.gerrithub.io/430402 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Piotr Pelpliński Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris --- lib/iscsi/conn.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index 5ab3c41dd..97c1e5503 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -474,15 +474,18 @@ static void spdk_iscsi_conn_cleanup_backend(struct spdk_iscsi_conn *conn) { int rc; + struct spdk_iscsi_tgt_node *target; if (conn->sess->connections > 1) { /* connection specific cleanup */ } else if (!g_spdk_iscsi.AllowDuplicateIsid) { /* clean up all tasks to all LUNs for session */ - rc = spdk_iscsi_tgt_node_cleanup_luns(conn, - conn->sess->target); - if (rc < 0) { - SPDK_ERRLOG("target abort failed\n"); + target = conn->sess->target; + if (target != NULL) { + rc = spdk_iscsi_tgt_node_cleanup_luns(conn, target); + if (rc < 0) { + SPDK_ERRLOG("target abort failed\n"); + } } } } @@ -517,16 +520,12 @@ _spdk_iscsi_conn_check_shutdown(void *arg) void 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; if (conn->sess != NULL && conn->pending_task_cnt > 0) { - target = conn->sess->target; - if (target != NULL) { - spdk_iscsi_conn_cleanup_backend(conn); - } + spdk_iscsi_conn_cleanup_backend(conn); } spdk_clear_all_transfer_task(conn, NULL);