Index: sys/dev/iscsi/iscsi.c =================================================================== --- sys/dev/iscsi/iscsi.c +++ sys/dev/iscsi/iscsi.c @@ -579,7 +579,7 @@ return; } - sbt = mstosbt(995); + sbt = mstosbt(((is->is_ping_timeout * 1000) / 3) - 5); pr = mstosbt(10); callout_schedule_sbt(&is->is_callout, sbt, pr, 0); @@ -589,19 +589,19 @@ is->is_timeout++; if (is->is_waiting_for_iscsid) { - if (iscsid_timeout > 0 && is->is_timeout > iscsid_timeout) { + if (iscsid_timeout > 0) { ISCSI_SESSION_WARN(is, "timed out waiting for iscsid(8) " "for %d seconds; reconnecting", - is->is_timeout); + iscsid_timeout); reconnect_needed = true; } goto out; } if (is->is_login_phase) { - if (is->is_login_timeout > 0 && is->is_timeout > is->is_login_timeout) { + if (is->is_login_timeout > 0) { ISCSI_SESSION_WARN(is, "login timed out after %d seconds; " - "reconnecting", is->is_timeout); + "reconnecting", is->is_login_timeout); reconnect_needed = true; } goto out; @@ -617,7 +617,7 @@ goto out; } - if (is->is_timeout >= is->is_ping_timeout) { + if (is->is_timeout >= 3) { ISCSI_SESSION_WARN(is, "no ping reply (NOP-In) after %d seconds; " "reconnecting", is->is_ping_timeout); reconnect_needed = true; @@ -1393,6 +1393,7 @@ struct iscsi_session *is; struct icl_drv_limits idl; int error; + sbintime_t sbt, pr; sx_slock(&sc->sc_lock); for (;;) { @@ -1427,6 +1428,12 @@ is->is_waiting_for_iscsid = false; is->is_login_phase = true; + is->is_timeout = 0; + sbt = mstosbt(995); + pr = mstosbt(10); + if (login_timeout > 0) + sbt = mstosbt(login_timeout * 1000 - 5); + callout_schedule_sbt(&is->is_callout, sbt, pr, 0); is->is_reason[0] = '\0'; ISCSI_SESSION_UNLOCK(is); @@ -1467,6 +1474,7 @@ struct iscsi_session *is; struct icl_conn *ic; int error; + sbintime_t sbt, pr; sx_slock(&sc->sc_lock); @@ -1539,6 +1547,11 @@ if (is->is_login_timeout < 0) is->is_login_timeout = login_timeout; is->is_connected = true; + sbt = mstosbt(995); + pr = mstosbt(10); + if (is->is_ping_timeout > 0) + sbt = mstosbt(((is->is_ping_timeout * 1000) / 3) - 5); + callout_schedule_sbt(&is->is_callout, sbt, pr, 0); is->is_reason[0] = '\0'; ISCSI_SESSION_UNLOCK(is); @@ -1648,6 +1661,7 @@ struct iscsi_session *is; struct sockaddr *from_sa, *to_sa; int error; + sbintime_t sbt, pr; sx_slock(&sc->sc_lock); TAILQ_FOREACH(is, &sc->sc_sessions, is_next) { @@ -1686,6 +1700,11 @@ is->is_waiting_for_iscsid = false; is->is_login_phase = true; is->is_timeout = 0; + sbt = mstosbt(995); + pr = mstosbt(10); + if (is->is_login_timeout > 0) + sbt = mstosbt(is->is_login_timeout * 1000 - 5); + callout_schedule_sbt(&is->is_callout, sbt, pr, 0); ISCSI_SESSION_UNLOCK(is); error = icl_conn_connect(is->is_conn, idc->idc_domain, @@ -1953,6 +1972,9 @@ sbt = mstosbt(995); pr = mstosbt(10); + if (iscsid_timeout > 0) { + sbt = mstosbt(iscsid_timeout * 1000 - 5); + } callout_reset_sbt(&is->is_callout, sbt, pr, iscsi_callout, is, 0); TAILQ_INSERT_TAIL(&sc->sc_sessions, is, is_next);