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
This commit is contained in:
Warner Losh
2025-12-11 12:05:32 -07:00
parent b9915c27a7
commit 8ac7a3801c
3 changed files with 66 additions and 7 deletions
+11
View File
@@ -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
+33 -1
View File
@@ -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
+22 -6
View File
@@ -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 @@ probestart(struct cam_periph *periph, union ccb *start_ccb)
probedone,
MSG_SIMPLE_Q_TAG,
SSD_FULL_SIZE,
/*timeout*/60000);
/*timeout*/tur_timeout);
break;
}
case PROBE_INQUIRY:
@@ -816,7 +832,7 @@ probestart(struct cam_periph *periph, union ccb *start_ccb)
/*evpd*/FALSE,
/*page_code*/0,
SSD_MIN_SIZE,
/*timeout*/60 * 1000);
/*timeout*/inquiry_timeout);
break;
}
case PROBE_REPORT_WLUNS:
@@ -856,7 +872,7 @@ probestart(struct cam_periph *periph, union ccb *start_ccb)
}
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 @@ probestart(struct cam_periph *periph, union ccb *start_ccb)
mode_buf,
mode_buf_len,
SSD_FULL_SIZE,
/*timeout*/60000);
/*timeout*/modesense_timeout);
break;
}
xpt_print(periph->path,
@@ -1026,7 +1042,7 @@ probestart(struct cam_periph *periph, union ccb *start_ccb)
probedone,
MSG_SIMPLE_Q_TAG,
SSD_FULL_SIZE,
/*timeout*/60000);
/*timeout*/tur_timeout);
break;
}
@@ -1039,7 +1055,7 @@ probestart(struct cam_periph *periph, union ccb *start_ccb)
/*evpd*/FALSE,
/*page_code*/0,
SSD_MIN_SIZE,
/*timeout*/60 * 1000);
/*timeout*/inquiry_timeout);
break;
}
default: