Index: sys/dev/iscsi/iscsi.c =================================================================== --- sys/dev/iscsi/iscsi.c +++ sys/dev/iscsi/iscsi.c @@ -556,7 +556,7 @@ return; } - sbt = mstosbt(995); + sbt = mstosbt((ping_timeout * 1000) / 3) - 5); pr = mstosbt(10); callout_schedule_sbt(&is->is_callout, sbt, pr, 0); @@ -566,7 +566,7 @@ is->is_timeout++; if (is->is_waiting_for_iscsid) { - if (iscsid_timeout > 0 && is->is_timeout > iscsid_timeout) { + if (iscsid_timeout > 0 && is->is_timeout > 0) { ISCSI_SESSION_WARN(is, "timed out waiting for iscsid(8) " "for %d seconds; reconnecting", is->is_timeout); @@ -576,7 +576,7 @@ } if (is->is_login_phase) { - if (login_timeout > 0 && is->is_timeout > login_timeout) { + if (login_timeout > 0 && is->is_timeout > 0) { ISCSI_SESSION_WARN(is, "login timed out after %d seconds; " "reconnecting", is->is_timeout); reconnect_needed = true; @@ -594,7 +594,7 @@ goto out; } - if (is->is_timeout >= ping_timeout) { + if (is->is_timeout >= 3) { ISCSI_SESSION_WARN(is, "no ping reply (NOP-In) after %d seconds; " "reconnecting", ping_timeout); reconnect_needed = true; @@ -1404,6 +1404,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); @@ -1510,6 +1516,11 @@ is->is_login_phase = false; is->is_timeout = 0; is->is_connected = true; + sbt = mstosbt(995); + pr = mstosbt(10); + if (ping_timeout > 0) + sbt = mstosbt((ping_timeout * 1000) / 3) - 5); + callout_schedule(&is->is_callout, sbt, pr, 0); is->is_reason[0] = '\0'; ISCSI_SESSION_UNLOCK(is); @@ -1619,6 +1630,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) { @@ -1657,6 +1669,11 @@ 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); ISCSI_SESSION_UNLOCK(is); error = icl_conn_connect(is->is_conn, idc->idc_domain, @@ -1918,6 +1935,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);