Fix statechange-led.sh & unnecessary libdevmapper warning

- Fix autoreplace behaviour on statechange-led.sh script.

ZED sends the following events on an auto-replace:

1. statechange: Disk goes UNAVAIL->ONLINE
2. statechange: Disk goes ONLINE->UNAVAIL
3. vdev_attach: Disk goes ONLINE

Events 1-2 happen when ZED first attempts to do an auto-online.  When that
fails, ZED then tries an auto-replace, generating the vdev_attach event in #3.

In the previous code, statechange-led was only looking at the UNAVAIL->ONLINE
transition to turn off the LED.  It ignored the #2 ONLINE->UNAVAIL transition,
assuming it was just the "old" VDEV going offline.  This is problematic, as
a drive can go from ONLINE->UNAVAIL when it's malfunctioning, and we don't want
to ignore that.

This new patch correctly turns on the fault LED every time a drive becomes
UNAVAIL.  It also monitors vdev_attach events to trigger turning off the LED
when an auto-replaced disk comes online.

- Remove unnecessary libdevmapper warning with --with-config=kernel

This fixes an unnecessary libdevmapper warning when building
--with-config=kernel.  Kernel code does not use libdevmapper, so the warning
is not needed.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #2375 
Closes #5312 
Closes #5331
This commit is contained in:
Tony Hutter
2016-10-25 11:05:30 -07:00
committed by Brian Behlendorf
parent 402c7c27b0
commit 6568379eea
4 changed files with 15 additions and 22 deletions
+3 -2
View File
@@ -304,6 +304,7 @@ AC_CONFIG_FILES([
AC_OUTPUT
AS_IF([test "x$user_libdevmapper" != xyes ], [
AC_MSG_WARN([Building without libdevmapper. Auto-replace, auto-online, and statechange-led.sh may not work correctly with device mapper vdevs.])
AS_IF([test "x$user_libdevmapper" != xyes && test "$ZFS_CONFIG" != kernel ], [
AC_MSG_WARN([Building without libdevmapper. Auto-replace, auto-online, \
and statechange-led.sh may not work correctly with device mapper vdevs.])
])