From nobody Sat Nov 07 23:02:23 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jMWln4nltz6xytr for ; Sat, 07 Nov 2026 23:02:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jMWln0qGTz4XQb for ; Sat, 07 Nov 2026 23:02:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794092549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CcgI8UVIPxF6j9mUYJHsJLzvGh5Q1GUsP+rYdNvOWR4=; b=GIrzALJwvdc1lg9wzYV9suMWwc+KYR8TajerXnHxb4Lf6YrfXMksMHAH/WjYDzc+bSQzP6 p9qrp0WVReCHSWzF+/Ira7OpboONPR8USGdzU2ipDaUZJcUK8xF5jdePx2z/IgKDstoL9j 52UVSTJMOlBClSUReIBptNP/VMjsC6PH1d5Svi9F0kw+z9Q2S2+NJ9jRcC+eNrIKENYhPS PWVolseZAKY8nRgZkyVckg2zrEntq3Gf+Irg8DmTJ/ilVNZ/fCrqpS8PRcMM2DCDGzg6Mo 9x2d81ykN94uLeXHrmMNpcgwkgqa+egc2OcZSeDIDssVwLfLBOJh5zLtpMvuBw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794092549; b=Db4iUdYKseVGfGQL0YMW0im3nYxEKAU0Mbi/y8o2WWL4pvdLyTmOtIlRubZLxS4QGRuTUo PuGIzEARncVMLWvATJL5nejSBhR4EWvJbz0LfUHJbR6JSAbMa6jGoP24XrvP9OvseCNUVx ufr5LtI3mys5wxTdEYw3pNPgRZik18W7pkSX6haGQHGDP2Q41r5al0PGLT+bMiaqnhVr6P pok0K3h9OICbHH60fJ8WkHtRGJavYJDj4Ys+OjYvmIB38YrJVdLDxgPgoqUSOJDYN9+4r3 BjXF6b3DS2XmDLx/3VbBUozQJaOKN9F5ZzNoWMEyCRT33u68ejNz1GoGFz1CnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794092549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CcgI8UVIPxF6j9mUYJHsJLzvGh5Q1GUsP+rYdNvOWR4=; b=w+DNegZchlP+2Ki283Ds4O9cAix5o14HCm/MNfoqtfMYeI+XfZs8z/cMsubJPOIisn/5vY G+YuAVwchwhxid5jmSWhrmbIjSwBd6Z4HqyA89wjsOqLE7YFiWiOiI4EoEInSST0G6i4jl yZV/L24vAFvuciQfIrZnGUZlvtCryZ7MxVhr30EKAu5TzYeF+2wHg8Em8mV3VAihEcSPJh We5j/kgphvH12fvfDHMKaV9HoApgJBcG+fRA7/uvVJJ0gpFrW+1OVbQWtV6XEYbFuGomy3 QIy/gtPQcmlkUNkV241Iv3YKmyL8Gc4ATSdWetOJMn2jufWLPn/DnMTktaF6wg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jMWln0Qznzhs8 for ; Sat, 07 Nov 2026 23:02:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 44d16 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 07 Nov 2026 23:02:23 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Richard Scheffenegger Subject: git: 0c248bdf1d63 - main - iSCSI: Fast and per-session timeouts List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rscheff X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0c248bdf1d63625c40a541397d6e601cf9a51141 Auto-Submitted: auto-generated Date: Sat, 07 Nov 2026 23:02:23 +0000 Message-Id: <6aefadff.44d16.152bb29c@gitrepo.freebsd.org> The branch main has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=0c248bdf1d63625c40a541397d6e601cf9a51141 commit 0c248bdf1d63625c40a541397d6e601cf9a51141 Author: Richard Scheffenegger AuthorDate: 2026-11-07 18:06:09 +0000 Commit: Richard Scheffenegger CommitDate: 2026-11-07 23:00:04 +0000 iSCSI: Fast and per-session timeouts Support per-session configurable ping (SCSI NOP) and login timeouts similar to what is supported in the Linux iSCSI initiator configuration file. Reduce iscsi timer granularity to 0.1 sec. For backwards compatibility, when all timers are selected on integer numbers, all status messages are unchanged. If the higher granularity is used, the log messages include sub-second granularity. The sysctl(3) interface has changed from pure int to string, in order to support fractional seconds in a human-readable, dotted notation. Reviewed By: #netapp, #manpages, jhb, pauamma_chezdork.com, siderop1_netapp.com Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D32540 --- share/man/man4/iscsi.4 | 7 +++--- sys/dev/iscsi/iscsi.c | 53 ++++++++++++++++++++++++++++--------------- sys/dev/iscsi/iscsi_ioctl.h | 2 ++ usr.bin/iscsictl/iscsi.conf.5 | 6 ++--- usr.bin/iscsictl/iscsictl.c | 14 +++++++----- usr.bin/iscsictl/parse.y | 26 +++++++++++++++++++-- usr.bin/iscsictl/token.l | 1 + usr.sbin/iscsid/iscsid.c | 8 +++++-- 8 files changed, 83 insertions(+), 34 deletions(-) diff --git a/share/man/man4/iscsi.4 b/share/man/man4/iscsi.4 index 77a5e816294f..57422c6f8d22 100644 --- a/share/man/man4/iscsi.4 +++ b/share/man/man4/iscsi.4 @@ -20,7 +20,7 @@ .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. -.Dd May 28, 2017 +.Dd November 6, 2026 .Dt ISCSI 4 .Os .Sh NAME @@ -72,6 +72,7 @@ In the event that there is no response within that time the session gets forcibly restarted. Set to 0 to disable sending NOP-Out PDUs. Defaults to 5. +This can be set in increments of 0.1 seconds. .It Va kern.iscsi.iscsid_timeout The number of seconds to wait for .Xr iscsid 8 @@ -79,13 +80,13 @@ to establish a session. After that time .Nm will abort and retry. -Defaults to 60. +Defaults to 60 and accepts increments of 0.1. .It Va kern.iscsi.login_timeout The number of seconds to wait for a login attempt to succeed. After that time .Nm will abort and retry. -Defaults to 60. +Defaults to 60 and accepts increments of 0.1. .It Va kern.iscsi.maxtags The maximum number of outstanding IO requests. Defaults to 255. diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index 4ed8f086ccde..01f1e15bbc52 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -104,15 +104,15 @@ static int debug = 1; SYSCTL_INT(_kern_iscsi, OID_AUTO, debug, CTLFLAG_RWTUN, &debug, 0, "Enable debug messages"); -static int ping_timeout = 5; +static int ping_timeout = 5000; SYSCTL_INT(_kern_iscsi, OID_AUTO, ping_timeout, CTLFLAG_RWTUN, &ping_timeout, - 0, "Timeout for ping (NOP-Out) requests, in seconds"); -static int iscsid_timeout = 60; + 0, "Timeout for ping (NOP-Out) requests, in milliseconds"); +static int iscsid_timeout = 60000; SYSCTL_INT(_kern_iscsi, OID_AUTO, iscsid_timeout, CTLFLAG_RWTUN, &iscsid_timeout, - 0, "Time to wait for iscsid(8) to handle reconnection, in seconds"); -static int login_timeout = 60; + 0, "Time to wait for iscsid(8) to handle reconnection, in milliseconds"); +static int login_timeout = 60000; SYSCTL_INT(_kern_iscsi, OID_AUTO, login_timeout, CTLFLAG_RWTUN, &login_timeout, - 0, "Time to wait for iscsid(8) to finish Login Phase, in seconds"); + 0, "Time to wait for iscsid(8) to finish Login Phase, in milliseconds"); static int maxtags = 255; SYSCTL_INT(_kern_iscsi, OID_AUTO, maxtags, CTLFLAG_RWTUN, &maxtags, 0, "Max number of IO requests queued"); @@ -585,6 +585,8 @@ iscsi_callout(void *context) struct iscsi_session *is; bool reconnect_needed = false; sbintime_t sbt, pr; + bool fast_timer = false; + char tmpstr[5]; is = context; @@ -594,29 +596,38 @@ iscsi_callout(void *context) return; } - sbt = mstosbt(995); + fast_timer = ((is->is_ping_timeout <= 2000) || + (is->is_login_timeout <= 2000)); + sbt = mstosbt(fast_timer ? 95 : 995); pr = mstosbt(10); callout_schedule_sbt(&is->is_callout, sbt, pr, 0); if (is->is_conf.isc_enable == 0) goto out; - is->is_timeout++; + is->is_timeout += (fast_timer ? 100 : 1000); + tmpstr[0] = '\0'; if (is->is_waiting_for_iscsid) { - if (iscsid_timeout > 0 && is->is_timeout > iscsid_timeout) { + if (iscsid_timeout > 0 && is->is_timeout >= iscsid_timeout) { + if (fast_timer && ((is->is_timeout % 1000) != 0)) + snprintf(tmpstr, sizeof(tmpstr), ".%d", + (is->is_timeout % 1000) / 100); ISCSI_SESSION_WARN(is, "timed out waiting for iscsid(8) " - "for %d seconds; reconnecting", - is->is_timeout); + "for %d%s seconds; reconnecting", + is->is_timeout / 1000, tmpstr); reconnect_needed = true; } goto out; } if (is->is_login_phase) { - if (is->is_login_timeout > 0 && is->is_timeout > is->is_login_timeout) { - ISCSI_SESSION_WARN(is, "login timed out after %d seconds; " - "reconnecting", is->is_timeout); + if (is->is_login_timeout > 0 && is->is_timeout >= is->is_login_timeout) { + if (fast_timer && ((is->is_timeout % 1000) != 0)) + snprintf(tmpstr, sizeof(tmpstr), ".%d", + (is->is_timeout % 1000) / 100); + ISCSI_SESSION_WARN(is, "login timed out after %d%s seconds; " + "reconnecting", is->is_timeout / 1000, tmpstr); reconnect_needed = true; } goto out; @@ -633,8 +644,11 @@ iscsi_callout(void *context) } if (is->is_timeout >= is->is_ping_timeout) { - ISCSI_SESSION_WARN(is, "no ping reply (NOP-In) after %d seconds; " - "reconnecting", is->is_ping_timeout); + if (fast_timer && ((is->is_timeout % 1000) != 0)) + snprintf(tmpstr, sizeof(tmpstr), ".%d", + (is->is_timeout % 1000) / 100); + ISCSI_SESSION_WARN(is, "no ping reply (NOP-In) after %d%s seconds; " + "reconnecting", is->is_timeout / 1000, tmpstr); reconnect_needed = true; goto out; } @@ -649,7 +663,7 @@ iscsi_callout(void *context) * (It's 2 - one for one second, and one for incrementing is_timeout * earlier in this routine.) */ - if (is->is_timeout < 2) + if (is->is_timeout < (fast_timer ? 200 : 2000)) return; request = icl_pdu_new(is->is_conn, M_NOWAIT); @@ -1965,6 +1979,7 @@ iscsi_ioctl_session_add(struct iscsi_softc *sc, struct iscsi_session_add *isa) const struct iscsi_session *is2; int error; sbintime_t sbt, pr; + bool fast_timer; iscsi_sanitize_session_conf(&isa->isa_conf); if (iscsi_valid_session_conf(&isa->isa_conf) == false) @@ -2048,7 +2063,9 @@ iscsi_ioctl_session_add(struct iscsi_softc *sc, struct iscsi_session_add *isa) if (is->is_login_timeout < 0) is->is_login_timeout = login_timeout; - sbt = mstosbt(995); + fast_timer = ((is->is_ping_timeout <= 2000) || + (is->is_ping_timeout <= 2000)); + sbt = mstosbt(fast_timer ? 95 : 995); pr = mstosbt(10); callout_reset_sbt(&is->is_callout, sbt, pr, iscsi_callout, is, 0); TAILQ_INSERT_TAIL(&sc->sc_sessions, is, is_next); diff --git a/sys/dev/iscsi/iscsi_ioctl.h b/sys/dev/iscsi/iscsi_ioctl.h index d995dbc981a9..a8f4d5383cc6 100644 --- a/sys/dev/iscsi/iscsi_ioctl.h +++ b/sys/dev/iscsi/iscsi_ioctl.h @@ -142,6 +142,8 @@ struct iscsi_daemon_handoff { int idh_max_send_data_segment_length; int idh_max_burst_length; int idh_first_burst_length; + int idh_ping_timeout; + int idh_login_timeout; }; struct iscsi_daemon_fail { diff --git a/usr.bin/iscsictl/iscsi.conf.5 b/usr.bin/iscsictl/iscsi.conf.5 index 325d00bfabe6..b99dc9263a8c 100644 --- a/usr.bin/iscsictl/iscsi.conf.5 +++ b/usr.bin/iscsictl/iscsi.conf.5 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd February 25, 2022 +.Dd February 6, 2026 .Dt ISCSI.CONF 5 .Os .Sh NAME @@ -170,7 +170,7 @@ configured using seconds) is taken by the driver. If present, the PingTimeout can be set to any positive value starting with -.Qq Ar 1 . +.Qq Ar 0.1 . .It Cm LoginTimeout Specify the time in seconds to wait for a login PDU to be sent or received after trying to establish a new session. @@ -181,7 +181,7 @@ If this entry is not present in the conf file, the default value of seconds is used, as configured by .Qq Ar kern.iscsi.login_timeout . The LoginTimeout can be set to any positive value starting with -.Qq Ar 1 . +.Qq Ar 0.1 . .El .Sh FILES .Bl -tag -width indent diff --git a/usr.bin/iscsictl/iscsictl.c b/usr.bin/iscsictl/iscsictl.c index f78e47d226bf..f78fe6ebe0f3 100644 --- a/usr.bin/iscsictl/iscsictl.c +++ b/usr.bin/iscsictl/iscsictl.c @@ -448,13 +448,15 @@ kernel_list(int iscsi_fd, const struct target *targ __unused, xo_emit("{L:/%-26s}{V:pcp/0x%02x}\n", "Target PCP:", conf->isc_pcp); if (conf->isc_ping_timeout != -1) - xo_emit("{L:/%-26s}{V:PingTimeout/%d}\n", - "Target PingTimeout:", - conf->isc_ping_timeout); + xo_emit("{L:/%-26s}{V:PingTimeout/%d.%d}\n", + "Target Ping Timeout:", + conf->isc_ping_timeout / 1000, + (conf->isc_ping_timeout % 1000) / 100); if (conf->isc_login_timeout != -1) - xo_emit("{L:/%-26s}{V:LoginTimeout/%d}\n", - "Target LoginTimeout:", - conf->isc_login_timeout); + xo_emit("{L:/%-26s}{V:LoginTimeout/%d.%d}\n", + "Target Login Timeout:", + conf->isc_login_timeout / 1000, + (conf->isc_login_timeout % 1000) / 100); xo_close_container("target"); xo_open_container("auth"); diff --git a/usr.bin/iscsictl/parse.y b/usr.bin/iscsictl/parse.y index 90e0e6320317..c32217ec3314 100644 --- a/usr.bin/iscsictl/parse.y +++ b/usr.bin/iscsictl/parse.y @@ -29,6 +29,7 @@ * SUCH DAMAGE. */ +#include #include #include #include @@ -66,9 +67,11 @@ extern void yyrestart(FILE *); %union { char *str; + double floating; } %token STR +%token FLOAT %% @@ -381,7 +384,16 @@ ping_timeout: PINGTIMEOUT EQUALS STR free($3); return(1); } - target->t_pingtimeout = tmp; + target->t_pingtimeout = tmp * 1000; + } + | PINGTIMEOUT EQUALS FLOAT + { + float tmp; + + if (target->t_pingtimeout != -1) + xo_errx(1, "duplicated PingTimeout at line %d", lineno); + tmp = $3; + target->t_pingtimeout = roundup((int)(tmp * 1000), 100); } ; @@ -397,7 +409,17 @@ login_timeout: LOGINTIMEOUT EQUALS STR free($3); return(1); } - target->t_logintimeout = tmp; + target->t_logintimeout = tmp * 1000; + } + | LOGINTIMEOUT EQUALS FLOAT + { + float tmp; + + if (target->t_logintimeout != -1) + xo_errx(1, "duplicated LoginTimeout at line %d", lineno); + + tmp = $3; + target->t_logintimeout = roundup((int)(tmp * 1000), 100); } ; diff --git a/usr.bin/iscsictl/token.l b/usr.bin/iscsictl/token.l index efe075958ca1..08cd0f4c174f 100644 --- a/usr.bin/iscsictl/token.l +++ b/usr.bin/iscsictl/token.l @@ -111,6 +111,7 @@ cs6 { return CS6; } cs7 { return CS7; } \"[^"]+\" { yylval.str = strndup(yytext + 1, strlen(yytext) - 2); return STR; } +[0-9]*\.[0-9]+ { yylval.floating = atof(yytext); return FLOAT; } [a-zA-Z0-9\.\-_/\:\[\]]+ { yylval.str = strdup(yytext); return STR; } \{ { return OPENING_BRACKET; } \} { return CLOSING_BRACKET; } diff --git a/usr.sbin/iscsid/iscsid.c b/usr.sbin/iscsid/iscsid.c index 7230a8bda6fe..3cf6d370a302 100644 --- a/usr.sbin/iscsid/iscsid.c +++ b/usr.sbin/iscsid/iscsid.c @@ -357,7 +357,7 @@ connection_new(int iscsi_fd, const struct iscsi_daemon_request *request) int keepinit = 0; if (conn->conn_conf.isc_login_timeout > 0) { keepinit = conn->conn_conf.isc_login_timeout; - log_debugx("session specific LoginTimeout at %d sec", + log_debugx("session specific LoginTimeout at %d ms", keepinit); } if (conn->conn_conf.isc_login_timeout == -1) { @@ -366,11 +366,13 @@ connection_new(int iscsi_fd, const struct iscsi_daemon_request *request) if (sysctlbyname("kern.iscsi.login_timeout", &value, &size, NULL, 0) == 0) { keepinit = value; - log_debugx("global login_timeout at %d sec", + log_debugx("global login_timeout at %d ms", keepinit); } } if (keepinit > 0) { + /* setsockopt only supports full seconds */ + keepinit = roundup(keepinit, 1000); if (setsockopt(conn->conn.conn_socket, IPPROTO_TCP, TCP_KEEPINIT, &keepinit, sizeof(keepinit)) == -1) @@ -476,6 +478,8 @@ handoff(struct iscsid_connection *conn) conn->conn.conn_max_send_data_segment_length; idh.idh_max_burst_length = conn->conn.conn_max_burst_length; idh.idh_first_burst_length = conn->conn.conn_first_burst_length; + idh.idh_ping_timeout = conn->conn_conf.isc_ping_timeout; + idh.idh_login_timeout = conn->conn_conf.isc_login_timeout; error = ioctl(conn->conn_iscsi_fd, ISCSIDHANDOFF, &idh); if (error != 0)