From where does default 'scsi timeout' value get set for scsi devices ?
Environment
- Red Hat Enterprise Linux 5
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 7
Issue
- From where does default 'scsi timeout' value get set for scsi devices ?
Resolution
-
Timeout : The Linux SCSI layer sets a timer on each command. When this timer expires, the SCSI layer will quiesce the host bus adapter (HBA) and wait for all outstanding commands to either time out or complete.
-
Afterwards, the SCSI layer will activate the driver's error handler.
-
When the error handler is triggered, it attempts the following operations in order (until one returns success):
Abort the command. Reset the device. Reset the bus. Reset the host. -
If all of these operations fail, the device will be set to the offline state.
-
When this occurs, all IO to that device will be failed, until the problem is corrected and the device is returned to running state.
-
Default scsi device timeout is same across both RHEL5 and RHEL6 kernel.
-
This is defined in kernel scsi sd driver source.
// **RHEL5**
drivers/scsi/sd.c:#define SD_TIMEOUT (30 * HZ)
// **RHEL6**
drivers/scsi/sd.h:#define SD_TIMEOUT (30 * HZ)
// **RHEL7**
drivers/scsi/sd.h:#define SD_TIMEOUT (30 * HZ)
-
But in RHEL5, its increased to 60 sec using udev rules i.e.
-
If udev is not in use, the default timeout is 30 seconds.
-
The same udev rule could be applied to rhel6 as well to modify the default timeout.
-
Default timeout value in RHEL5 from udev is seen as
[root@host]# cat /sys/block/sda/device/timeout 60 -
Default scsi timeout value for scsi devices get set through udev rule in RHEL5.
-
From /etc/udev/rules.d/50-udev.rules file:
# sd: 0 TYPE_DISK, 7 TYPE_MOD, 14 TYPE_RBC # sr: 4 TYPE_WORM, 5 TYPE_ROM # st/osst: 1 TYPE_TAPE # sg: 8 changer, [36] scanner ACTION=="add", SUBSYSTEM=="scsi" , SYSFS{type}=="0|7|14", \ RUN+="/bin/sh -c 'echo 60 > /sys$$DEVPATH/timeout'" -
Also, to change the device timeout value see:
- For SAN storage devices (step could also be used):
[root@host]# echo 180 > /sys/class/scsi_device/<H>:<C>:<T>:<L>/device/timeout
Where these are the meanings of the values:
H = SCSI host number of the lpfc HBA
T = SCSI ID of the SCSI target
L = LUN number of the SCSI device.
- For internal disks:
[root@host]# echo 180 > /sys/block/sda/device/timeout
This will set device timeout value to 180 seconds.
- In RHEL6 it was reduced to 30 to allow faster error detection and hence faster recovery from failure of I/O. This is 30 as per industry standard.
- In RHEL7 it is set to 30 as well.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.