From 09d0b30fd1ba08a95e86909d2e1abb2997b0a871 Mon Sep 17 00:00:00 2001 From: Ned Bass Date: Mon, 13 Jan 2014 13:32:41 -0800 Subject: vdev_id: support per-channel slot mappings The vdev_id udev helper currently applies slot renumbering rules to every channel (JBOD) in the system. This is too inflexible for systems with non-homogeneous storage topologies. The "slot" keyword now takes an optional third parameter which names a channel to which the mapping will apply. If the third parameter is omitted then the rule applies to all channels. The first-specified rule that can match a slot takes precedence. Therefore a channel-specific rule for a given slot should generally appear before a generic rule for the same slot number. In this way a custom slot mapping can be applied to a particular channel and a default mapping applied to the rest. Signed-off-by: Ned Bass Signed-off-by: Brian Behlendorf Closes #2056 --- cmd/vdev_id/vdev_id | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'cmd') diff --git a/cmd/vdev_id/vdev_id b/cmd/vdev_id/vdev_id index 713ff9865..b6752ba1b 100755 --- a/cmd/vdev_id/vdev_id +++ b/cmd/vdev_id/vdev_id @@ -39,18 +39,20 @@ # channel 86:00.0 1 C # channel 86:00.0 0 D # -# # Linux Mapped -# # Slot Slot -# slot 1 7 -# slot 2 10 -# slot 3 3 -# slot 4 6 -# slot 5 2 -# slot 6 8 -# slot 7 1 -# slot 8 4 -# slot 9 9 -# slot 10 5 +# # Custom mapping for Channel A +# +# # Linux Mapped +# # Slot Slot Channel +# slot 1 7 A +# slot 2 10 A +# slot 3 3 A +# slot 4 6 A +# +# # Default mapping for B, C, and D +# slot 1 4 +# slot 2 2 +# slot 3 1 +# slot 4 3 # # # # Example vdev_id.conf - sas_switch @@ -110,10 +112,11 @@ EOF map_slot() { local LINUX_SLOT=$1 + local CHANNEL=$2 local MAPPED_SLOT= - MAPPED_SLOT=`awk "\\$1 == \"slot\" && \\$2 == ${LINUX_SLOT} \ - { print \\$3; exit }" $CONFIG` + MAPPED_SLOT=`awk "\\$1 == \"slot\" && \\$2 == ${LINUX_SLOT} && \ + \\$4 ~ /^(${CHANNEL}|)$/ { print \\$3; exit }" $CONFIG` if [ -z "$MAPPED_SLOT" ] ; then MAPPED_SLOT=$LINUX_SLOT fi @@ -254,8 +257,8 @@ sas_handler() { return fi - SLOT=`map_slot $SLOT` CHAN=`map_channel $PCI_ID $PORT` + SLOT=`map_slot $SLOT $CHAN` if [ -z "$CHAN" ] ; then return fi -- cgit v1.2.3