Skip to content

Commit

Permalink
Rescan enclosure sysfs path on import
Browse files Browse the repository at this point in the history
When you create a pool, zfs writes vd->vdev_enc_sysfs_path with the
enclosure sysfs path to the fault LEDs, like:

  vdev_enc_sysfs_path = /sys/class/enclosure/0:0:1:0/SLOT8

However, this enclosure path doesn't get updated on successive imports
even if enclosure path to the disk changes.  This patch fixes the issue.

Signed-off-by: Tony Hutter <[email protected]>
Fixes: #11950
  • Loading branch information
tonyhutter committed May 20, 2021
1 parent 6ac2d7f commit 5abff7a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions module/zfs/vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2406,6 +2406,22 @@ vdev_copy_path_strict(vdev_t *svd, vdev_t *dvd)
return (SET_ERROR(EINVAL));
}

/* Our enclosure sysfs path may have changed between imports */
if (svd->vdev_enc_sysfs_path != dvd->vdev_enc_sysfs_path) {
zfs_dbgmsg("vdev_copy_path: vdev %llu: vdev_enc_sysfs_path changed "
"from '%s' to '%s'", (u_longlong_t)dvd->vdev_guid,
dvd->vdev_enc_sysfs_path, svd->vdev_enc_sysfs_path);

if (dvd->vdev_enc_sysfs_path)
spa_strfree(dvd->vdev_enc_sysfs_path);

if (svd->vdev_enc_sysfs_path) {
dvd->vdev_enc_sysfs_path = spa_strdup(svd->vdev_enc_sysfs_path);
} else {
dvd->vdev_enc_sysfs_path = NULL;
}
}

if (svd->vdev_guid != dvd->vdev_guid) {
vdev_dbgmsg(svd, "vdev_copy_path: guids mismatch (%llu != "
"%llu)", (u_longlong_t)svd->vdev_guid,
Expand Down

0 comments on commit 5abff7a

Please sign in to comment.