vdev_id: multi-lun disks & slot num zero pad

Add ability to generate disk names that contain both a slot number
and a lun number in order to support multi-actuator SAS hard drives
with multiple luns. Also add the ability to zero pad slot numbers to
a desired digit length for easier sorting.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matthew Heller <matthew.f.heller@accre.vanderbilt.edu>
Closes #16603
This commit is contained in:
Matthew Heller 2024-10-08 20:43:04 -04:00 committed by GitHub
parent 75dda92dc3
commit cefef28e98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 4 deletions

View File

@ -92,6 +92,11 @@ before a generic mapping for the same slot.
In this way a custom mapping may be applied to a particular channel In this way a custom mapping may be applied to a particular channel
and a default mapping applied to the others. and a default mapping applied to the others.
. .
.It Sy zpad_slot Ar digits
Pad slot numbers with zeros to make them
.Ar digits
long, which can help to make disk names a consistent length and easier to sort.
.
.It Sy multipath Sy yes Ns | Ns Sy no .It Sy multipath Sy yes Ns | Ns Sy no
Specifies whether Specifies whether
.Xr vdev_id 8 .Xr vdev_id 8
@ -122,7 +127,7 @@ device is connected to.
The default is The default is
.Sy 4 . .Sy 4 .
. .
.It Sy slot Sy bay Ns | Ns Sy phy Ns | Ns Sy port Ns | Ns Sy id Ns | Ns Sy lun Ns | Ns Sy ses .It Sy slot Sy bay Ns | Ns Sy phy Ns | Ns Sy port Ns | Ns Sy id Ns | Ns Sy lun Ns | Ns Sy bay_lun Ns | Ns Sy ses
Specifies from which element of a SAS identifier the slot number is Specifies from which element of a SAS identifier the slot number is
taken. taken.
The default is The default is
@ -138,6 +143,9 @@ use the SAS port as the slot number.
use the scsi id as the slot number. use the scsi id as the slot number.
.It Sy lun .It Sy lun
use the scsi lun as the slot number. use the scsi lun as the slot number.
.It Sy bay_lun
read the slot number from the bay identifier and append the lun number.
Useful for multi-lun multi-actuator hard drives.
.It Sy ses .It Sy ses
use the SCSI Enclosure Services (SES) enclosure device slot number, use the SCSI Enclosure Services (SES) enclosure device slot number,
as reported by as reported by

View File

@ -124,6 +124,7 @@ TOPOLOGY=
BAY= BAY=
ENCL_ID="" ENCL_ID=""
UNIQ_ENCL_ID="" UNIQ_ENCL_ID=""
ZPAD=1
usage() { usage() {
cat << EOF cat << EOF
@ -154,7 +155,7 @@ map_slot() {
if [ -z "$MAPPED_SLOT" ] ; then if [ -z "$MAPPED_SLOT" ] ; then
MAPPED_SLOT=$LINUX_SLOT MAPPED_SLOT=$LINUX_SLOT
fi fi
printf "%d" "${MAPPED_SLOT}" printf "%0${ZPAD}d" "${MAPPED_SLOT}"
} }
map_channel() { map_channel() {
@ -430,6 +431,15 @@ sas_handler() {
d=$(eval echo '$'{$i}) d=$(eval echo '$'{$i})
SLOT=$(echo "$d" | sed -e 's/^.*://') SLOT=$(echo "$d" | sed -e 's/^.*://')
;; ;;
"bay_lun")
# Like 'bay' but with the LUN number appened. Added for SAS
# multi-actuator HDDs, where one physical drive has multiple
# LUNs, thus multiple logical drives share the same bay number
i=$((i + 2))
d=$(eval echo '$'{$i})
LUN="-lun$(echo "$d" | sed -e 's/^.*://')"
SLOT=$(cat "$end_device_dir/bay_identifier" 2>/dev/null)
;;
"ses") "ses")
# look for this SAS path in all SCSI Enclosure Services # look for this SAS path in all SCSI Enclosure Services
# (SES) enclosures # (SES) enclosures
@ -460,7 +470,7 @@ sas_handler() {
if [ -z "$CHAN" ] ; then if [ -z "$CHAN" ] ; then
return return
fi fi
echo "${CHAN}"-"${JBOD}"-"${SLOT}${PART}" echo "${CHAN}"-"${JBOD}"-"${SLOT}${LUN}${PART}"
else else
CHAN=$(map_channel "$PCI_ID" "$PORT") CHAN=$(map_channel "$PCI_ID" "$PORT")
SLOT=$(map_slot "$SLOT" "$CHAN") SLOT=$(map_slot "$SLOT" "$CHAN")
@ -468,7 +478,7 @@ sas_handler() {
if [ -z "$CHAN" ] ; then if [ -z "$CHAN" ] ; then
return return
fi fi
echo "${CHAN}${SLOT}${PART}" echo "${CHAN}${SLOT}${LUN}${PART}"
fi fi
} }
@ -748,6 +758,8 @@ if [ -z "$BAY" ] ; then
BAY=$(awk '($1 == "slot") {print $2; exit}' "$CONFIG") BAY=$(awk '($1 == "slot") {print $2; exit}' "$CONFIG")
fi fi
ZPAD=$(awk '($1 == "zpad_slot") {print $2; exit}' "$CONFIG")
TOPOLOGY=${TOPOLOGY:-sas_direct} TOPOLOGY=${TOPOLOGY:-sas_direct}
# Should we create /dev/by-enclosure symlinks? # Should we create /dev/by-enclosure symlinks?