diff options
author | Tony Hutter <[email protected]> | 2016-10-19 12:55:59 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-10-19 12:55:59 -0700 |
commit | 6078881aa18a45ea065a887e2a8606279cdc0329 (patch) | |
tree | d6af96c545969994afdf2bf84ee1484b09cdf76c /cmd/zed/zed.d | |
parent | 7c502b0b1de8d3d341c026760df5915ad4be794a (diff) |
Multipath autoreplace, control enclosure LEDs, event rate limiting
1. Enable multipath autoreplace support for FMA.
This extends FMA autoreplace to work with multipath disks. This
requires libdevmapper to be installed at build time.
2. Turn on/off fault LEDs when VDEVs become degraded/faulted/online
Set ZED_USE_ENCLOSURE_LEDS=1 in zed.rc to have ZED turn on/off the enclosure
LED for a drive when a drive becomes FAULTED/DEGRADED. Your enclosure must
be supported by the Linux SES driver for this to work. The enclosure LED
scripts work for multipath devices as well. The scripts will clear the LED
when the fault is cleared.
3. Rate limit ZIO delay and checksum events so as not to flood ZED
ZIO delay and checksum events are rate limited to 5/sec in the zfs module.
Reviewed-by: Richard Laager <[email protected]>
Reviewed by: Don Brady <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Tony Hutter <[email protected]>
Closes #2449
Closes #3017
Closes #5159
Diffstat (limited to 'cmd/zed/zed.d')
-rwxr-xr-x | cmd/zed/zed.d/statechange-led.sh | 88 | ||||
l--------- | cmd/zed/zed.d/vdev_clear-led.sh | 1 | ||||
-rw-r--r-- | cmd/zed/zed.d/zed.rc | 8 |
3 files changed, 97 insertions, 0 deletions
diff --git a/cmd/zed/zed.d/statechange-led.sh b/cmd/zed/zed.d/statechange-led.sh new file mode 100755 index 000000000..ca911d2b9 --- /dev/null +++ b/cmd/zed/zed.d/statechange-led.sh @@ -0,0 +1,88 @@ +#!/bin/bash +# +# Turn off/on the VDEV's enclosure fault LEDs when the pool's state changes. +# +# Turn LED on if the VDEV becomes faulted/degraded, and turn it back off when +# it's healthy again. This requires that your enclosure be supported by the +# Linux SCSI enclosure services (ses) driver. The script will do nothing +# if you have no enclosure, or if your enclosure isn't supported. +# +# This script also requires ZFS to be built with libdevmapper support. +# +# Exit codes: +# 0: enclosure led successfully set +# 1: enclosure leds not not available +# 2: enclosure leds administratively disabled +# 3: ZED built without libdevmapper + +[ -f "${ZED_ZEDLET_DIR}/zed.rc" ] && . "${ZED_ZEDLET_DIR}/zed.rc" +. "${ZED_ZEDLET_DIR}/zed-functions.sh" + +# ZEVENT_VDEV_UPATH will not be present if ZFS is not built with libdevmapper +[ -n "${ZEVENT_VDEV_UPATH}" ] || exit 3 + +if [ "${ZED_USE_ENCLOSURE_LEDS}" != "1" ] ; then + exit 2 +fi + +if [ ! -d /sys/class/enclosure ] ; then + exit 1 +fi + +# Turn on/off enclosure LEDs +function led +{ + name=$1 + val=$2 + + # We want to check the current state first, since writing to the + # 'fault' entry always always causes a SES command, even if the + # current state is already what you want. + if [ -e /sys/block/$name/device/enclosure_device*/fault ] ; then + # We have to do some monkey business to deal with spaces in + # enclosure_device names. I've seen horrible things like this: + # + # '/sys/block/sdfw/device/enclosure_device:SLOT 43 41 /fault' + # + # ...so escape all spaces. + file=`ls /sys/block/$name/device/enclosure_device*/fault | sed 's/\s/\\ /g'` + + current=`cat "$file"` + + # On some enclosures if you write 1 to fault, and read it back, + # it will return 2. Treat all non-zero values as 1 for + # simplicity. + if [ "$current" != "0" ] ; then + current=1 + fi + + if [ "$current" != "$val" ] ; then + # Set the value twice. I've seen enclosures that were + # flakey about setting it the first time. + echo $val > "$file" + echo $val > "$file" + fi + fi +} + +# Decide whether to turn on/off an LED based on the state +# Pass in path name and fault string ("ONLINE"/"FAULTED"/"DEGRADED"...etc) +function process { + # path=/dev/sda, fault= + + path=$1 + fault=$2 + name=`basename $path` + + if [ -z "$name" ] ; then + return + fi + + if [ "$fault" == "FAULTED" ] || [ "$fault" == "DEGRADED" ] ; then + led $name 1 + else + led $name 0 + fi +} + +process "$ZEVENT_VDEV_UPATH" "$ZEVENT_VDEV_STATE_STR" diff --git a/cmd/zed/zed.d/vdev_clear-led.sh b/cmd/zed/zed.d/vdev_clear-led.sh new file mode 120000 index 000000000..7d7404398 --- /dev/null +++ b/cmd/zed/zed.d/vdev_clear-led.sh @@ -0,0 +1 @@ +statechange-led.sh
\ No newline at end of file diff --git a/cmd/zed/zed.d/zed.rc b/cmd/zed/zed.d/zed.rc index f80fa3338..2dce04828 100644 --- a/cmd/zed/zed.d/zed.rc +++ b/cmd/zed/zed.d/zed.rc @@ -86,6 +86,14 @@ #ZED_SPARE_ON_IO_ERRORS=1 ## +# Turn on/off enclosure LEDs when drives get DEGRADED/FAULTED. This works for +# device mapper and multipath devices as well. Your enclosure must be +# supported by the Linux SES driver for this to work. +# +ZED_USE_ENCLOSURE_LEDS=1 + + +## # The syslog priority (e.g., specified as a "facility.level" pair). # #ZED_SYSLOG_PRIORITY="daemon.notice" |