Commit 9eefbc5b authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

lib/iscsi: Add login timeout not to leave hunged connection



An issue is reported that connections were left forever without any
progress during login processing.

Not to leave these connections, add the login timeout feature as
described in the iSCSI specification.

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Signed-off-by: default avatarSochin Jiang <jiangxiaoqing.sochin@bytedance.com>
Change-Id: I9483a5b5540b433df6235aa7fc13b99eaca0bfa4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4609


Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent da58e377
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -170,12 +170,26 @@ iscsi_poll_group_remove_conn(struct spdk_iscsi_poll_group *pg, struct spdk_iscsi
	STAILQ_REMOVE(&pg->connections, conn, spdk_iscsi_conn, pg_link);
}

static int
login_timeout(void *arg)
{
	struct spdk_iscsi_conn *conn = arg;

	if (conn->state < ISCSI_CONN_STATE_EXITING) {
		conn->state = ISCSI_CONN_STATE_EXITING;
	}

	return SPDK_POLLER_BUSY;
}

static void
iscsi_conn_start(void *ctx)
{
	struct spdk_iscsi_conn *conn = ctx;

	iscsi_poll_group_add_conn(conn->pg, conn);

	conn->login_timer = SPDK_POLLER_REGISTER(login_timeout, conn, ISCSI_LOGIN_TIMEOUT * 1000000);
}

int
+5 −0
Original line number Diff line number Diff line
@@ -131,6 +131,11 @@ struct spdk_iscsi_conn {
	 */
	struct spdk_poller *shutdown_timer;

	/* Timer used to destroy connection after creating this connection
	 *  if login process does not complete.
	 */
	struct spdk_poller *login_timer;

	struct spdk_iscsi_pdu *pdu_in_progress;
	enum iscsi_pdu_recv_state pdu_recv_state;

+2 −0
Original line number Diff line number Diff line
@@ -1148,6 +1148,8 @@ iscsi_conn_login_pdu_success_complete(void *arg)
{
	struct spdk_iscsi_conn *conn = arg;

	spdk_poller_unregister(&conn->login_timer);

	if (conn->state >= ISCSI_CONN_STATE_EXITING) {
		/* Connection is being exited before this callback is executed. */
		SPDK_DEBUGLOG(iscsi, "Connection is already exited.\n");
+3 −0
Original line number Diff line number Diff line
@@ -132,6 +132,9 @@
 */
#define ISCSI_LOGOUT_TIMEOUT 5 /* in seconds */

/** Defines how long we should wait until login process completes. */
#define ISCSI_LOGIN_TIMEOUT 30 /* in seconds */

/* For spdk_iscsi_login_in related function use, we need to avoid the conflict
 * with other errors
 * */