How to set eh_deadline and eh_timeout persistently, using a udev rule
Environment
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 7
Issue
- Need to set eh_deadline and eh_timeout
- Settings need to be persistent
Resolution
These settings can be easily applied through udev rules. The eh_deadline setting and eh_timeout setting are different in that they are applied through different /sys/class directories, scsi_host and scsi_device, respectively. We can use the information gathered by udev and stored in the udev database to create a rule that can persistently set these values based on any number of attributes.
To get the full udev attribute list that contains eh_deadline, the command udevadm info --attribute-walk --path can be used. In this example, we have 2-2port HBAs, one Emulex and one QLogic. They correspond to host2(QLogic), host3(QLogic), host4(Emulex), and host5(Emulex). Sample attribute gathering output for host2:
[root@host]# udevadm info --attribute-walk --path=/sys/class/scsi_host/host2Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.looking at device '/devices/pci0000:00/0000:00:09.0/0000:04:00.0/host2/scsi_host/host2':
KERNEL=="host2"
SUBSYSTEM=="scsi_host"
DRIVER==""
ATTR{unique_id}=="2"
ATTR{host_busy}=="0"
ATTR{cmd_per_lun}=="3"
ATTR{can_queue}=="2038"
ATTR{sg_tablesize}=="1024"
ATTR{unchecked_isa_dma}=="0"
ATTR{proc_name}=="(null)"
ATTR{state}=="running"
ATTR{supported_mode}=="Initiator"
ATTR{active_mode}=="Initiator"
ATTR{prot_capabilities}=="0"
ATTR{prot_guard_type}=="0"
ATTR{eh_deadline}=="20" <== See FN.1 below
ATTR{driver_version}=="8.07.00.26.06.8-k"
ATTR{fw_version}=="7.03.00 (9496)"
ATTR{serial_num}=="LFC0441N81107"
ATTR{isp_name}=="ISP2432"
ATTR{isp_id}=="0000 0000 0000 0000"
ATTR{model_name}=="QLE2462"
ATTR{model_desc}=="QLogic 4GB FC Dual-Port PCI-E HBA for IBM System x"
ATTR{pci_info}=="PCIe (2.5GT/s x4)"
ATTR{link_state}=="Link Up - F_Port"
ATTR{zio}=="Disabled"
ATTR{zio_timer}=="200 us"
ATTR{beacon}=="Disabled"
ATTR{optrom_bios_version}=="2.16"
ATTR{optrom_efi_version}=="2.27"
ATTR{optrom_fcode_version}=="3.13"
ATTR{optrom_fw_version}=="5.03.06 1154"
.......snip
Footnotes
- FN.1 : if the driver does not support the
eh_deadlineattribute, then this entry may not be shown. Usually if found in the syfs tree and seen as OFF, its means its just not enabled.
When not supported by the driver, this attribute cannot be set via udev rules. This can be tested as follows:
# lsscsi -H [0] hpsa [1] lpfc [2] ata_piix # grep -Hv "zzz" /sys/class/scsi_host/host*/eh_deadline /sys/class/scsi_host/host0/eh_deadline:off /sys/class/scsi_host/host1/eh_deadline:off /sys/class/scsi_host/host2/eh_deadline:off # echo off < /sys/class/scsi_host/host0/eh_deadline bash: echo: write error: Invalid argument <== hpsa driver version does not support eh_deadline # echo off >echo off < /sys/class/scsi_host/host2/eh_deadline <== lpfc driver version supports eh_deadline # echo off >echo off < /sys/class/scsi_host/host3/eh_deadline bash: echo: write error: Invalid argument <== ata_piix driver version does not support eh_deadline
And to get the full udev attribute list that contains `eh_timeout` for a specific disk attached to the scsi host, the below commands can be used. **Note** thta device 4:0:0:1 is just an example scsi address for a disk used within this example. You will need to replace that with the scsi address of the device you are interested in.
[root@dell-per510-2 ~]# udevadm info --attribute-walk --path=/sys/class/scsi_device/4:0:0:1Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.looking at device '/devices/pci0000:00/0000:00:0a.0/0000:05:00.0/host4/rport-4:0-2/target4:0:0/4:0:0:1/scsi_device/4:0:0:1':
KERNEL=="4:0:0:1"
SUBSYSTEM=="scsi_device"
DRIVER==""looking at parent device '/devices/pci0000:00/0000:00:0a.0/0000:05:00.0/host4/rport-4:0-2/target4:0:0/4:0:0:1':
KERNELS=="4:0:0:1"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
ATTRS{device_blocked}=="0"
ATTRS{type}=="0"
ATTRS{scsi_level}=="5"
ATTRS{vendor}=="NETAPP "
ATTRS{model}=="LUN "
ATTRS{rev}=="7350"
ATTRS{state}=="running"
ATTRS{timeout}=="30"
ATTRS{eh_timeout}=="9" <== See FN.1 above
ATTRS{iocounterbits}=="32"
ATTRS{iorequest_cnt}=="0xd633a"
ATTRS{iodone_cnt}=="0xd633a"
ATTRS{ioerr_cnt}=="0x10"
ATTRS{modalias}=="scsi:t-0x00"
ATTRS{evt_media_change}=="0"
ATTRS{evt_inquiry_change_reported}=="0"
ATTRS{evt_capacity_change_reported}=="0"
ATTRS{evt_soft_threshold_reached}=="0"
ATTRS{evt_mode_parameter_change_reported}=="0"
ATTRS{evt_lun_change_reported}=="0"
ATTRS{dh_state}=="alua"
ATTRS{queue_depth}=="127"
ATTRS{queue_ramp_up_period}=="120000"
ATTRS{queue_type}=="none"looking at parent device '/devices/pci0000:00/0000:00:0a.0/0000:05:00.0/host4/rport-4:0-2/target4:0:0':
KERNELS=="target4:0:0"
SUBSYSTEMS=="scsi"
DRIVERS==""looking at parent device '/devices/pci0000:00/0000:00:0a.0/0000:05:00.0/host4/rport-4:0-2':
KERNELS=="rport-4:0-2"
SUBSYSTEMS==""
DRIVERS==""looking at parent device '/devices/pci0000:00/0000:00:0a.0/0000:05:00.0/host4':
KERNELS=="host4"
SUBSYSTEMS=="scsi"
DRIVERS==""
......snip
Using the information gained by the previous commands, we can build a udev rule to set our values. Each HBA should have a unique serial number, so as an example, we will set the eh_deadline by using this identifier. The below rule, added to
/etc/udev/rules.d/99-eh_timers.rules will set both QLogic ports to an eh_deadline of 30 and both Emulex ports to an eh_deadline of 60. It will also set the individual path 4:0:1:1 to a eh_timeout of 15.
ACTION!="add|change", GOTO="eh_end"
KERNEL=="host*", SUBSYSTEM=="scsi_host", ATTR{serial_num}=="LFC0441N81107", ATTR{eh_deadline}="30"
KERNEL=="host*", SUBSYSTEM=="scsi_host", ATTR{serialnum}=="VM64133127", ATTR{eh_deadline}="60"
KERNEL=="4:0:1:1", SUBSYSTEM=="scsi_device", ATTR{device/eh_timeout}="15"
LABEL="eh_end"
As a second example we will set all ports on all adapters using the `qla2xxx` driver to an eh_deadline of 90 and all scsi devices using that same driver to an eh_timeout of 5.
ACTION!="add|change", GOTO="eh_end"
KERNEL=="host*", SUBSYSTEM=="scsi_host", DRIVERS=="qla2xxx", ATTR{eh_deadline}="90"
SUBSYSTEM=="scsi_device", DRIVERS=="qla2xxx", ATTR{device/eh_timeout}="5"
LABEL="eh_end"
To apply the rules, a reload and a trigger should be used (reboot will set as well). Reload the ruleset and database:
#RHEL6
[root@host]# udevadm control --reload-rules
#RHEL7
[root@host]# udevadm control --reload
Trigger an add event:
[root@host]# udevadm trigger --subsystem-match=scsi_host
[root@host]# udevadm trigger --subsystem-match=scsi_device
Mapping a scsi(x) in RHEL6 or host(x) in RHEL7 to a particular HBA or HBA port should be as easy as checking `/var/log/dmesg`:
[root@host]# grep "scsi[2-5] " /var/log/dmesg
[ 2.755820] scsi2 : qla2xxx
[ 3.080129] scsi3 : qla2xxx
[ 3.596644] scsi4 : Emulex LPe11000 PCIe Fibre Channel Adapter on PCI bus 05 device 00 irq 41
[ 5.117922] scsi5 : Emulex LPe11000 PCIe Fibre Channel Adapter on PCI bus 05 device 01 irq 39
For additional, detailed mappings the below can be used:
[root@host]# yum -y install sysfstools
[root@host]# systool -v -c scsi_host
[root@host]# systool -v -c scsi_device
Note: After adding udev rules, they should be added to the ramdisk by [rebuilding the ramdisk](https://access.redhat.com/solutions/365693). Note: To set `dev_loss_tmo` or `fast_io_fail_tmo` via a udev rule, please use [How to set dev_loss_tmo and fast_io_fail_tmo persistently, using a udev rule](https://access.redhat.com/solutions/3234351).
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.