From 239a4078978524a12473816563c254bbeed1bf81 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Sun, 26 Jan 2020 19:06:54 -0500 Subject: [PATCH] lib/iscsi: Send message to request logout to active connection The next patch will create a SPDK thread for each poll group at startup. Hence iSCSI connection will be created or destroyed on these threads. On the other hand, logout request to the active connection will be still invoked by the default thread. This unmatch will hit assertion such that poller is unregistered different thread that registered it. Fix this unmatch by sending message to the thread explicitly to request logout and wait for the logout process to start. Signed-off-by: Shuhei Matsumoto Change-Id: Iff361e78b9ba077230e38d9586f7187968e33314 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/490 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/iscsi/conn.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index 7adbe876b..37c49a33b 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -828,22 +828,37 @@ logout_request_timeout(void *arg) return -1; } +/* If the connection is running and logout is not requested yet, request logout + * to initiator and wait for the logout process to start. + */ +static void +_iscsi_conn_request_logout(void *ctx) +{ + struct spdk_iscsi_conn *conn = ctx; + + if (conn->state > ISCSI_CONN_STATE_RUNNING || + conn->logout_request_timer != NULL) { + return; + } + + iscsi_send_logout_request(conn); + + conn->logout_request_timer = spdk_poller_register(logout_request_timeout, + conn, ISCSI_LOGOUT_REQUEST_TIMEOUT * 1000000); +} + static void iscsi_conn_request_logout(struct spdk_iscsi_conn *conn) { + struct spdk_thread *thread; + if (conn->state == ISCSI_CONN_STATE_INVALID) { /* Move it to EXITING state if the connection is in login. */ conn->state = ISCSI_CONN_STATE_EXITING; } else if (conn->state == ISCSI_CONN_STATE_RUNNING && conn->logout_request_timer == NULL) { - /* If the connection is running and logout is not requested yet, - * request logout to initiator and wait for the logout process - * to start. - */ - iscsi_send_logout_request(conn); - - conn->logout_request_timer = spdk_poller_register(logout_request_timeout, - conn, ISCSI_LOGOUT_REQUEST_TIMEOUT * 1000000); + thread = spdk_io_channel_get_thread(spdk_io_channel_from_ctx(conn->pg)); + spdk_thread_send_msg(thread, _iscsi_conn_request_logout, conn); } }