Linux/SCT Error Timeout

From Forza's ramblings


SCT Error Timeout[edit | edit source]

A humorous depiction of anthropomorphic computers in a chaotic boardroom meeting. The computers have varied screen faces and robotic arms, showing frustration and exhaustion from a long meeting. The table is cluttered with papers, coffee cups, and snacks, emphasizing the inefficiency and humor of the scene. Warm cinematic lighting and a modern office background with large windows complete the setting."
Too powerful for their own good? Organize them into a committee—problem solved.

The scterc.sh script configures error recovery settings for SCSI and SATA devices on Linux systems. It sets SCTERC (SCT Error Recovery Control) for supported devices or adjusts Linux kernel timeout settings for unsupported devices.

Linux uses the /sys/block/<device>/device/timeout setting to determine how long the kernel waits for an I/O operation to complete before marking it as failed and invoking the SCSI Error Handler (EH). The /sys/block/<device>/device/eh_timeout controls how long EH can attempt recovery before escalating further with high-level resets (such as LUN, bus, or host resets), or device offlining, which can cause data loss or file system corruption.

A device that supports SCTERC will limit its internal recovery/retry period and send an error response instead of trying too long. This prevents Linux from invoking the error handler, and informs the filesystem about the error so that it can take appropriate action.

It is up to the individual SCSI device drivers how they implement EH. Therefore, the consequences of EH invocation can vary between systems.

Usage[edit | edit source]

Download the script from https://git.tnonline.net/Forza/misc/src/branch/main/scsi-timeout

The script iterates standard SCSI/SATA block devices in /dev/sd[a-z] and attempts to set the SCTERC timeout value. If the device does not support SCT commands, the scripts sets a longer timeout to prevent Linux invoking the SCSI error handler. It can be modified to include other devices like /dev/vd[a-z] (QEMU) or /dev/xvd[a-z] (Xen).

For devices with SCTERC support
Variable Value Description
scterc_value 70 deciseconds SCTERC timemout
sct_device_timeout 60 seconds Linux device timeout
sct_eh_recovery_timeout 10 seconds Linux EH timeout
For devices without SCTERC support
fallback_device_timeout 300 seconds Linux device timeout
fallback_eh_recovery_timeout 30 seconds Linux EH timeout
# ./scterc.sh
Device      Model                                     Status
------------------------------------------------------------------
/dev/sda    WDC WD3000F9YZ-09N20L0                    SCTERC set ok
/dev/sdb    KINGSTON SA400S37240G                     No SCTERC support, using fallback

Use grep or cat to see the current timeout values.

# grep . /sys/block/*/device/*timeout
/sys/block/sda/device/eh_timeout:10
/sys/block/sda/device/timeout:60
/sys/block/sdb/device/eh_timeout:10
/sys/block/sdb/device/timeout:60
/sys/block/sdc/device/eh_timeout:10
/sys/block/sdc/device/timeout:60

Dependencies[edit | edit source]

The script uses smartctl tool from smartmon-tools to set and read device data.

License[edit | edit source]

This script is licensed under CC0-1.0 (Public Domain).

Further Reading[edit | edit source]

Small Computer Systems Interface, SCSI:

Linux SCSI interfaces guide:

Linux SCSI Error Handling Documentation:

Technical Committee for SCSI Storage Interfaces (T10):