From nobody Fri Nov 06 21:21:19 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 4jLsYX0Tflz6yt8K for ; Fri, 06 Nov 2026 21:21:20 +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 4jLsYW6fbzz4kSq for ; Fri, 06 Nov 2026 21:21:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794000079; 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=iJTAN1wjt5/+iKvFxdBpuOHGFf+lOjIpw97wrm8HBYk=; b=fvqay60Jqkyhsb/aaXbLlQDcLFxcrOp2oUvTzwpT0aJ+Mt8MxF066XXOE7JWQUIE7YPy6G VOOFmvY/NN9uny4aCwRKHbxopEzz/t/4bxqYp8+MPmZ9QP9gtrcjAbP6+aZUwx/Uv40XLY AS4tc/6miV8G6cdaPrKk0z/Efgtn9sg2e4ppuK/9LGD38cCKyvU176AFT8wBqpEUk9yimu uN+zeqluyw9gSKcMGG7G9+rwcwCgj3DNPxPsye4QWh8r19XTx+3UdoYVcSmzaYazOV4b0B C8KrswLMPVARYYURZb0msvp7HvySgAqSOewPIw/BRQGFQJPlfvhO/GlF/poOpA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794000079; b=lah/0d0xy20yLqd72L2te/w0czf8rcriZsX6eYrAqWdvZf6T3lpqljgzE/sNaZH10T6DZE BdGDRETFjUnBHdsQYjWCFjXk+SW88Htw4VA6UuuDS6TEsadmBuMRapLGJamBzoUj0xin+X TnYakYDDHJzz4WVk5nwiKY2OiokAsUENAYUlZdiEojHKw2ADkzz0f//D4UIXm9ol8neSZA 0Yecz41v3qJSoJ9C6Nkt9gvcpV9idTwh/HrvUcmpgEJpvCNsIQ8kCOyHYHtK38I4/am26B zZy8SM0SbD5ven3GriudUZnRDhHGCuNdPcwLGG2gstmi+SjWeFI0sWB/0i8SYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794000079; 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=iJTAN1wjt5/+iKvFxdBpuOHGFf+lOjIpw97wrm8HBYk=; b=GN50jpvX4zpU0I9Qh1NgK7C9nDRi/Ls2qjmXCgufZaUVJygczwFukrr0xCU+jofVEgsbsZ 9K/jbNgj7JAKtINpG9i/IYsmdFaZjRZsw467SLbTzaVRatgUi24ERv8rZi5WTB9gwAY03K yHUNmY7qjss6d4bLqHk3W/5sdkMoFb4/4GNvmIQKKeSPF54p0wSe14IhBzxjVyxkdfelnl 2zXp2kvSch4wdNEGGcIA+gW3TFjWbGei0dT97o7940cHmavIbOXb5k40E9le1hOqVK71U6 DOMJ7zROTDVHDu/xbQo9zrP7Ix1r8uJ9xSS72z8soNtWH8cPd8bZfF1R9Ws84w== 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 4jLsYW6JwKztrW for ; Fri, 06 Nov 2026 21:21:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 26ab9 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 06 Nov 2026 21:21:19 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Richard Scheffenegger Subject: git: 6129bc4b65d8 - 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: 6129bc4b65d8f00570bdcf2b2d36f3717e4b4741 Auto-Submitted: auto-generated Date: Fri, 06 Nov 2026 21:21:19 +0000 Message-Id: <6aee44cf.26ab9.381eaf44@gitrepo.freebsd.org> The branch main has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=6129bc4b65d8f00570bdcf2b2d36f3717e4b4741 commit 6129bc4b65d8f00570bdcf2b2d36f3717e4b4741 Author: Richard Scheffenegger AuthorDate: 2026-11-06 21:13:23 +0000 Commit: Richard Scheffenegger CommitDate: 2026-11-06 21:21:12 +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 | 25 ++++++++++++++++++-- usr.bin/iscsictl/token.l | 1 + usr.sbin/iscsid/iscsid.c | 8 +++++-- 8 files changed, 82 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..abdfb2daf6aa 100644 --- a/usr.bin/iscsictl/parse.y +++ b/usr.bin/iscsictl/parse.y @@ -66,9 +66,11 @@ extern void yyrestart(FILE *); %union { char *str; + double floating; } %token STR +%token FLOAT %% @@ -381,7 +383,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 +408,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)