Date: Thu, 11 Dec 2025 19:08:05 +0000 From: Warner Losh <imp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 8ac7a3801c6a - main - cam: Reduce overly long timeout values for initial device probing Message-ID: <693b1695.268a9.145b4f4f@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=8ac7a3801c6a780edf6166c14915d7ac6e36e816 commit 8ac7a3801c6a780edf6166c14915d7ac6e36e816 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2025-12-11 19:05:32 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2025-12-11 19:07:17 +0000 cam: Reduce overly long timeout values for initial device probing Currently, we have very long timeouts for the initial probing commands. However, these are not appropriate for modern (post 2010) SCSI disks. Sandards since SPC3 state that these commands should not wait for media access. Since we retry them several times during the initial bus scan, these delays can delay the boot by minutes (5 minutes per errant disk in our expereince). These delays don't help and only hurt, so reduce the TESTUNITREADY, INQUIRY and MODESENSE commands (during the initial probe). Provide sysctl/tuneables to change the time for these and also the REPORTLUNS commands for people that might need to adjust them for devices that violate this belief but none-the-less work with longer timeouts. kern.cam.tur_timeout (default was 60s, now 1s) kern.cam.inquiry_timeout (default was 60s, now 1s) kern.cam.reportluns_timeout (default is 60s) kern.cam.modesense_timeout (default was 60s, now 1s) This can be partially merged: the sysctls can, but the new defaults likely shouldn't. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D52427 --- UPDATING | 11 +++++++++++ share/man/man4/scsi.4 | 34 +++++++++++++++++++++++++++++++++- sys/cam/scsi/scsi_xpt.c | 28 ++++++++++++++++++++++------ 3 files changed, 66 insertions(+), 7 deletions(-) diff --git a/UPDATING b/UPDATING index aaef0e5b4cd3..f6cf0109f894 100644 --- a/UPDATING +++ b/UPDATING @@ -27,6 +27,17 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 16.x IS SLOW: world, or to merely disable the most expensive debugging functionality at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20251212: + Timeouts for SCSI bus probing have been drastically reduced. They are + now tuneables that can be set in the boot loader should you have a + device that requires a longer-than-standards imply timeout but + none-the-less works. + + kern.cam.tur_timeout (default was 60s, now 1s) + kern.cam.inquiry_timeout (default was 60s, now 1s) + kern.cam.reportluns_timeout (default is 60s) + kern.cam.modesense_timeout (default was 60s, now 1s) + 20251115: The FreeBSD-base repository is now defined in /etc/pkg/FreeBSD.conf, disabled by default. In -CURRENT and -STABLE this points at nightly diff --git a/share/man/man4/scsi.4 b/share/man/man4/scsi.4 index 380768c2d7c1..c922f3f56d15 100644 --- a/share/man/man4/scsi.4 +++ b/share/man/man4/scsi.4 @@ -22,7 +22,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 December 11, 2023 +.Dd December 11, 2025 .Dt CAM 4 .Os .Sh NAME @@ -69,6 +69,38 @@ appropriate drivers. The .Xr pass 4 driver, if it is configured in the kernel, will attach to all devices. +.Sh SYSCTL VARIABLES +The following variables are available as both +.Xr sysctl 8 +variables and +.Xr loader 8 +tunables: +.Bl -tag -width 12 +.It Va kern.cam.cam_srch_hi +Search above LUN 7 for SCSI3 and greater devices. +.It Va kern.cam.tur_timeout +Timeout, in ms, for the initial TESTUNITREADY command we send to the devices +during their initial probing. +Defaults to 1s. +.Fx 15 +and earlier set this to 60s. +.It Va kern.cam.inquiry_timeout +Timeout, in ms, for the initial INQUIRY command we send to the devices +during their initial probing. +Defaults to 1s. +.Fx 15 +and earlier set this to 60s. +.It Va kern.cam.reportluns_timeout +Timeout, in ms, for the initial REPORTLUNS command we send to the devices +during their initial probing. +Defaults to 50s. +.It Va kern.cam.modesense_timeout +Timeout, in ms, for the initial MODESENSE command we send to the devices +during their initial probing. +Defaults to 1s. +.Fx 15 +and earlier set this to 60s. +.El .Sh KERNEL CONFIGURATION There are a number of generic kernel configuration options for the .Nm diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index d0c170867b97..835c7c8ad825 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -78,6 +78,22 @@ static int cam_srch_hi = 0; SYSCTL_INT(_kern_cam, OID_AUTO, cam_srch_hi, CTLFLAG_RWTUN, &cam_srch_hi, 0, "Search above LUN 7 for SCSI3 and greater devices"); +static int tur_timeout = 1000; /* 1s now, 60s before */ +SYSCTL_INT(_kern_cam, OID_AUTO, tur_timeout, CTLFLAG_RWTUN, + &tur_timeout, 0, "TESTUNITREADY timeout on probing"); + +static int inquiry_timeout = 1000; /* 1s now, 60s before */ +SYSCTL_INT(_kern_cam, OID_AUTO, inquiry_timeout, CTLFLAG_RWTUN, + &inquiry_timeout, 0, "INQUIRY timeout on probing"); + +static int reportluns_timeout = 60000; /* 60s */ +SYSCTL_INT(_kern_cam, OID_AUTO, reportluns_timeout, CTLFLAG_RWTUN, + &reportluns_timeout, 0, "REPORTLUNS timeout on probing"); + +static int modesense_timeout = 1000; /* 1s now, 60s */ +SYSCTL_INT(_kern_cam, OID_AUTO, modesense_timeout, CTLFLAG_RWTUN, + &modesense_timeout, 0, "MODESENSE timeout on probing"); + #define CAM_SCSI2_MAXLUN 8 #define CAM_CAN_GET_SIMPLE_LUN(x, i) \ ((((x)->luns[i].lundata[0] & RPL_LUNDATA_ATYP_MASK) == \ @@ -760,7 +776,7 @@ again: probedone, MSG_SIMPLE_Q_TAG, SSD_FULL_SIZE, - /*timeout*/60000); + /*timeout*/tur_timeout); break; } case PROBE_INQUIRY: @@ -816,7 +832,7 @@ again: /*evpd*/FALSE, /*page_code*/0, SSD_MIN_SIZE, - /*timeout*/60 * 1000); + /*timeout*/inquiry_timeout); break; } case PROBE_REPORT_WLUNS: @@ -856,7 +872,7 @@ again: } scsi_report_luns(csio, 5, probedone, MSG_SIMPLE_Q_TAG, RPL_REPORT_DEFAULT, rp, periph->path->target->rpl_size, - SSD_FULL_SIZE, 60000); + SSD_FULL_SIZE, reportluns_timeout); break; } case PROBE_MODE_SENSE: @@ -879,7 +895,7 @@ again: mode_buf, mode_buf_len, SSD_FULL_SIZE, - /*timeout*/60000); + /*timeout*/modesense_timeout); break; } xpt_print(periph->path, @@ -1026,7 +1042,7 @@ done: probedone, MSG_SIMPLE_Q_TAG, SSD_FULL_SIZE, - /*timeout*/60000); + /*timeout*/tur_timeout); break; } @@ -1039,7 +1055,7 @@ done: /*evpd*/FALSE, /*page_code*/0, SSD_MIN_SIZE, - /*timeout*/60 * 1000); + /*timeout*/inquiry_timeout); break; } default:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?693b1695.268a9.145b4f4f>
