From d10401cc07987d6c43876d2d92d7e143d2e7aa8a Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Fri, 4 May 2018 14:43:59 +0800 Subject: [PATCH] iscsi: Solve the potential no io channel issue. Reason: If we trigger the spdk_iscsi_conn_migration, we may face the issue that the io channel of lun is NULL(which means not allocated). So I think that if we trigger the migration, we need to stop the executing the further pdu of this conn by the current polling group. Also since the connection is triggered migration, we should stop execution on the current core, and let this connection be handled by next round. Change-Id: I0ab89d79c976f3233890ae25cb7eac98de5e30ac Signed-off-by: Ziye Yang Reviewed-on: https://review.gerrithub.io/409984 Reviewed-by: Shuhei Matsumoto Reviewed-by: Changpeng Liu Tested-by: SPDK Automated Test System --- lib/iscsi/conn.c | 6 ++++++ lib/iscsi/conn.h | 1 + 2 files changed, 7 insertions(+) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index d387bcde3..b49dc2d0e 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -200,6 +200,7 @@ spdk_iscsi_poll_group_add_conn(struct spdk_iscsi_conn *conn) { struct spdk_iscsi_poll_group *poll_group = &g_spdk_iscsi.poll_group[spdk_env_get_current_core()]; + conn->is_stopped = false; STAILQ_INSERT_TAIL(&poll_group->connections, conn, link); spdk_iscsi_poll_group_add_conn_sock(conn); } @@ -209,6 +210,7 @@ spdk_iscsi_poll_group_remove_conn(struct spdk_iscsi_conn *conn) { struct spdk_iscsi_poll_group *poll_group = &g_spdk_iscsi.poll_group[spdk_env_get_current_core()]; + conn->is_stopped = true; STAILQ_REMOVE(&poll_group->connections, conn, spdk_iscsi_conn, link); } @@ -1154,6 +1156,10 @@ spdk_iscsi_conn_handle_incoming_pdus(struct spdk_iscsi_conn *conn) conn->initiator_port != NULL ? spdk_scsi_port_get_name(conn->initiator_port) : "NULL"); return rc; } + + if (conn->is_stopped) { + break; + } } return i; diff --git a/lib/iscsi/conn.h b/lib/iscsi/conn.h index d6b8ceaf8..9c7e8deba 100644 --- a/lib/iscsi/conn.h +++ b/lib/iscsi/conn.h @@ -160,6 +160,7 @@ struct spdk_iscsi_conn { STAILQ_ENTRY(spdk_iscsi_conn) link; struct spdk_poller *flush_poller; + bool is_stopped; /* Set true when connection is stopped for migration */ TAILQ_HEAD(queued_r2t_tasks, spdk_iscsi_task) queued_r2t_tasks; TAILQ_HEAD(active_r2t_tasks, spdk_iscsi_task) active_r2t_tasks; TAILQ_HEAD(queued_datain_tasks, spdk_iscsi_task) queued_datain_tasks;