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: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Signed-off-by: Sochin Jiang <jiangxiaoqing.sochin@bytedance.com>
Change-Id: I9483a5b5540b433df6235aa7fc13b99eaca0bfa4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4609
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Shuhei Matsumoto 2020-10-13 12:07:47 +09:00 committed by Tomasz Zawadzki
parent da58e37709
commit 9eefbc5b10
4 changed files with 24 additions and 0 deletions

View File

@ -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

View File

@ -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;

View File

@ -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");

View File

@ -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
* */