From dfbc33a0e5298f2840144c3a29d053918a2dd944 Mon Sep 17 00:00:00 2001 From: Tony Hutter Date: Wed, 20 Oct 2021 15:48:04 -0700 Subject: [PATCH] vdev_id: Fix enclosure_symlinks feature The vdev_id.conf "enclosure_symlinks" option persistently creates and maps /dev/by-enclosure symlinks to dynamic /dev/sg* devices. This patch fixes two issues: 1. The enclosure_symlinks feature was accidentally broken in: vdev_id: Support daisy-chained JBODs in multipath mode 2. Even when working, the feature numbered the enclosure sequentially rather than by HBA port number. That meant that if a port was down or didn't appear in sysfs, then the enclosure_sumlinks numbers would be numbered wrong. Reviewed-by: Brian Behlendorf Reviewed-by: Arshad Hussain Signed-off-by: Tony Hutter Closes #12660 --- cmd/vdev_id/vdev_id | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/vdev_id/vdev_id b/cmd/vdev_id/vdev_id index cad59c93f0..ab9d7326fc 100755 --- a/cmd/vdev_id/vdev_id +++ b/cmd/vdev_id/vdev_id @@ -622,8 +622,8 @@ enclosure_handler () { PCI_ID=$(echo "$PCI_ID_LONG" | sed -r 's/^[0-9]+://g') # Name our device according to vdev_id.conf (like "L0" or "U1"). - NAME=$(awk '/channel/{if ($1 == "channel" && $2 == "$PCI_ID" && \ - $3 == "$PORT_ID") {print ${4}int(count[$4])}; count[$4]++}' $CONFIG) + NAME=$(awk "/channel/{if (\$1 == \"channel\" && \$2 == \"$PCI_ID\" && \ + \$3 == \"$PORT_ID\") {print \$4\$3}}" $CONFIG) echo "${NAME}" }