From 65a736bc0df16561bac14bee6bf9a6752cf8bc39 Mon Sep 17 00:00:00 2001 From: Tony Hutter Date: Fri, 10 Feb 2017 15:18:31 -0800 Subject: [PATCH] Clear enclosure sysfs path from VDEV label when sysfs path isn't present This clears vdev_enc_sysfs_path from the label if the VDEV's /sys/class/block//device/enclosure_device path isn't present. This is important in the case where a disk that is labeled with vdev_enc_sysfs_path is pulled out and put into another enclosure. In that case, it's possible that the old sysfs path would be used to turn on the fault LED for the disk's old slot postion, assuming the new slot didn't have a LED sysfs entry. Reviewed-by: Don Brady Reviewed-by: Brian Behlendorf Signed-off-by: Tony Hutter Closes #5524 Closes #5773 --- lib/libzfs/libzfs_import.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/libzfs/libzfs_import.c b/lib/libzfs/libzfs_import.c index 1e378321c6..ce65840905 100644 --- a/lib/libzfs/libzfs_import.c +++ b/lib/libzfs/libzfs_import.c @@ -476,7 +476,6 @@ update_vdev_config_dev_strs(nvlist_t *nv) !strncasecmp(env, "YES", 3) || !strncasecmp(env, "ON", 2))) { (void) nvlist_remove_all(nv, ZPOOL_CONFIG_DEVID); (void) nvlist_remove_all(nv, ZPOOL_CONFIG_PHYS_PATH); - (void) nvlist_remove_all(nv, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH); return; } @@ -504,6 +503,9 @@ update_vdev_config_dev_strs(nvlist_t *nv) if (spath) nvlist_add_string(nv, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH, spath); + else + nvlist_remove_all(nv, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH); + free(upath); free(spath); } else {