Commit 239a4078 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

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: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: Iff361e78b9ba077230e38d9586f7187968e33314
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/490


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 5adeda48
Loading
Loading
Loading
Loading
+23 −8
Original line number Diff line number Diff line
@@ -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);
	}
}