freebsd-dev/sys/cam/scsi
Kenneth D. Merry 5719b5a1bb Switch to using drive-supplied timeouts for the sa(4) driver.
Summary:
The sa(4) driver has historically used tape drive timeouts that
were one-size fits all, with compile-time options to adjust a few
of them.

LTO-9 drives (and presumably other tape drives in the future)
implement a tape characterization process that happens the first
time a tape is loaded.  The characterization process formats the
tape to account for the temperature and humidity in the environment
it is being used in.  The process for LTO-9 tapes can take from 20
minutes (I have observed 17-18 minutes) to 2 hours according to the
documentation.

As a result, LTO-9 drives have significantly longer recommended
load times than previous LTO generations.

To handle this, change the sa(4) driver over to using timeouts
supplied by the tape drive using the timeout descriptors obtained
through the REPORT SUPPORTED OPERATION CODES command.  That command
was introduced in SPC-4.  IBM tape drives going back to at least
LTO-5 report timeout values.  Oracle/Sun/StorageTek tape drives
going back to at least the T10000C report timeout values.  HP LTO-5
and newer drives report timeout values.  The sa(4) driver only
queries drives that claim to support SPC-4.

This makes the timeout settings automatic and accurate for newer
tape drives.

Also, add loader tunable and sysctl support so that the user can
override individual command type timeouts for all tape drives in
the system, or only for specific drives.

The new global (these affect all tape drives) loader tunables are:

	kern.cam.sa.timeout.erase
	kern.cam.sa.timeout.load
	kern.cam.sa.timeout.locate
	kern.cam.sa.timeout.mode_select
	kern.cam.sa.timeout.mode_sense
	kern.cam.sa.timeout.prevent
	kern.cam.sa.timeout.read
	kern.cam.sa.timeout.read_position
	kern.cam.sa.timeout.read_block_limits
	kern.cam.sa.timeout.report_density
	kern.cam.sa.timeout.reserve
	kern.cam.sa.timeout.rewind
	kern.cam.sa.timeout.space
	kern.cam.sa.timeout.tur
	kern.cam.sa.timeout.write
	kern.cam.sa.timeout.write_filemarks

The new per-instance loader tunable / sysctl variables are:

	kern.cam.sa.%d.timeout.erase
	kern.cam.sa.%d.timeout.load
	kern.cam.sa.%d.timeout.locate
	kern.cam.sa.%d.timeout.mode_select
	kern.cam.sa.%d.timeout.mode_sense
	kern.cam.sa.%d.timeout.prevent
	kern.cam.sa.%d.timeout.read
	kern.cam.sa.%d.timeout.read_position
	kern.cam.sa.%d.timeout.read_block_limits
	kern.cam.sa.%d.timeout.report_density
	kern.cam.sa.%d.timeout.reserve
	kern.cam.sa.%d.timeout.rewind
	kern.cam.sa.%d.timeout.space
	kern.cam.sa.%d.timeout.tur
	kern.cam.sa.%d.timeout.write
	kern.cam.sa.%d.timeout.write_filemarks

The values are reported and set in units of thousandths of a
second.

share/man/man4/sa.4:
	Document the new loader tunables in the sa(4) man page.

sys/cam/scsi/scsi_sa.c:
	Add a new timeout_info array to the softc.

	Add a default timeouts array, along with descriptions.

	Add a new sysctl tree to the softc to handle the timeout
	sysctl values.

	Add a new function, saloadtotunables(), that will load
	the global loader tunables first and then any per-instance
	loader tunables second.

	Add creation of the new timeout sysctl variables in
	sasysctlinit().

	Add a new, optional probe state to the sa(4) driver.  We
	previously didn't do any probing, but now we probe for
	timeout descriptors if the drive claims to support SPC-4 or
	later.  In saregister(), we check the SCSI revision and
	either launch the probe state machine, or announce the
	device and become ready.

	In sastart() and sadone(), add support for the new
	SA_STATE_PROBE.  If we're probing, we don't go through
	saerror(), since that is currently only written to handle
	I/O errors in the normal state.

	Change every place in the sa(4) driver that fills in
	timeout values in a CCB to use the new timeout_info[] array
	in the softc.

	Add a new saloadtimeouts() routine to parse the returned
	timeout descriptors from a completed REPORT SUPPORTED
	OPERATION CODES command, and set the values for the
	commands we support.

MFC after:	1 week
Sponsored by:	Spectra Logic

Test Plan:
Try this out with a variety of tape drives and make sure the timeouts that
result (sysctl kern.cam.sa to see them) are reasonable.

Reviewers: #manpages, #cam

Subscribers: imp

Differential Revision: https://reviews.freebsd.org/D33883
2022-01-18 13:50:30 -05:00
..
scsi_all.c CAM: List few missed opcodes. 2021-12-31 11:48:03 -05:00
scsi_all.h libcam: Define depop structures and introduce scsi_wrap 2021-09-20 16:27:59 -06:00
scsi_cd.c cam: Relax callouts precisions. 2022-01-07 12:59:16 -05:00
scsi_cd.h cam: clean up empty lines in .c and .h files 2020-09-01 22:13:48 +00:00
scsi_ch.c cam: Remove all the write-only variables 2021-11-23 21:21:18 -07:00
scsi_ch.h sys/cam: further adoption of SPDX licensing ID tags. 2017-11-27 15:12:43 +00:00
scsi_da.c cam: Optimize write protection MODE SENSE in da(4). 2022-01-14 18:24:52 -05:00
scsi_da.h cam: clean up empty lines in .c and .h files 2020-09-01 22:13:48 +00:00
scsi_enc_internal.h cam: Fix type of elm_idx in struct enc_element. 2022-01-13 21:43:34 -05:00
scsi_enc_safte.c cam: clean up empty lines in .c and .h files 2020-09-01 22:13:48 +00:00
scsi_enc_ses.c cam: Remove all the write-only variables 2021-11-23 21:21:18 -07:00
scsi_enc.c cam: Relax callouts precisions. 2022-01-07 12:59:16 -05:00
scsi_enc.h ses: Guard the elm_type_names declaration by _KERNEL 2021-09-02 14:47:18 -06:00
scsi_iu.h
scsi_message.h cam: clean up empty lines in .c and .h files 2020-09-01 22:13:48 +00:00
scsi_pass.c Free UMA zones when a pass(4) instance goes away. 2022-01-13 10:54:56 -05:00
scsi_pass.h sys/cam: further adoption of SPDX licensing ID tags. 2017-11-27 15:12:43 +00:00
scsi_pt.c Fix "set but not used" warnings in CAM. 2021-11-25 03:17:54 +00:00
scsi_pt.h sys/cam: further adoption of SPDX licensing ID tags. 2017-11-27 15:12:43 +00:00
scsi_sa.c Switch to using drive-supplied timeouts for the sa(4) driver. 2022-01-18 13:50:30 -05:00
scsi_sa.h cam: clean up empty lines in .c and .h files 2020-09-01 22:13:48 +00:00
scsi_ses.h sesutil: Avoid setting reserved bits. 2022-01-13 13:57:35 -05:00
scsi_sg.c Fix "set but not used" warnings in CAM. 2021-11-25 03:17:54 +00:00
scsi_sg.h
scsi_targ_bh.c cam: clear stack-allocated CCB in the target layer 2021-07-21 10:18:28 +01:00
scsi_target.c Fix "set but not used" warnings in CAM. 2021-11-25 03:17:54 +00:00
scsi_targetio.h sys/cam: further adoption of SPDX licensing ID tags. 2017-11-27 15:12:43 +00:00
scsi_xpt.c cam: Remove trailing spaces from serial numbers too 2021-11-05 08:56:41 -06:00
smp_all.c cam: clean up empty lines in .c and .h files 2020-09-01 22:13:48 +00:00
smp_all.h sys/cam: further adoption of SPDX licensing ID tags. 2017-11-27 15:12:43 +00:00