diff options
author | Tony Hutter <[email protected]> | 2021-03-08 08:43:30 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-08 08:43:30 -0800 |
commit | 4fdbd434508fac4013b856d804f9f191baea5690 (patch) | |
tree | fb91dc39a8debe70e9231baf1b7720016b42622b /cmd/vdev_id | |
parent | b2eebe3ae7e301b084e47e243356c17d94ca98de (diff) |
vdev_id: Create symlinks even if no /dev/mapper/
vdev_id uses the /dev/mapper/ symlinks to resolve a UUID to a dm name
(like dm-1). However on some multipath setups, there is no /dev/mapper/
entry for the UUID at the time vdev_id is called by udev. However,
this isn't necessarily needed, as we may be able to resolve the dm
name from the $DEVNAME that udev passes us (like DEVNAME="/dev/dm-1").
This patch tries to resolve the dm name from $DEVNAME first, before
falling back to looking in /dev/mapper/. This fixed an issue where the
by-vdev names weren't reliably showing up on one of our nodes.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Tony Hutter <[email protected]>
Closes #11698
Diffstat (limited to 'cmd/vdev_id')
-rwxr-xr-x | cmd/vdev_id/vdev_id | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/cmd/vdev_id/vdev_id b/cmd/vdev_id/vdev_id index 8a379a726..d8918da10 100755 --- a/cmd/vdev_id/vdev_id +++ b/cmd/vdev_id/vdev_id @@ -298,8 +298,15 @@ sas_handler() { # Utilize DM device name to gather subordinate block devices # using sysfs to avoid userspace utilities - DMDEV=$(ls -l --full-time /dev/mapper | grep $DM_NAME | + + # If our DEVNAME is something like /dev/dm-177, then we may be + # able to get our DMDEV from it. + DMDEV=$(echo $DEVNAME | sed 's;/dev/;;g') + if [ ! -e /sys/block/$DMDEV/slaves/* ] ; then + # It's not there, try looking in /dev/mapper + DMDEV=$(ls -l --full-time /dev/mapper | grep $DM_NAME | awk '{gsub("../", " "); print $NF}') + fi # Use sysfs pointers in /sys/block/dm-X/slaves because using # userspace tools creates lots of overhead and should be avoided |