Skip to content

Commit 2609d93

Browse files
hellermfbehlendorf
authored andcommitted
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Matthew Heller <[email protected]> Closes openzfs#16603
1 parent 10f46d2 commit 2609d93

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

Diff for: man/man5/vdev_id.conf.5

+9-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ before a generic mapping for the same slot.
9292
In this way a custom mapping may be applied to a particular channel
9393
and a default mapping applied to the others.
9494
.
95+
.It Sy zpad_slot Ar digits
96+
Pad slot numbers with zeros to make them
97+
.Ar digits
98+
long, which can help to make disk names a consistent length and easier to sort.
99+
.
95100
.It Sy multipath Sy yes Ns | Ns Sy no
96101
Specifies whether
97102
.Xr vdev_id 8
@@ -122,7 +127,7 @@ device is connected to.
122127
The default is
123128
.Sy 4 .
124129
.
125-
.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
130+
.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
126131
Specifies from which element of a SAS identifier the slot number is
127132
taken.
128133
The default is
@@ -138,6 +143,9 @@ use the SAS port as the slot number.
138143
use the scsi id as the slot number.
139144
.It Sy lun
140145
use the scsi lun as the slot number.
146+
.It Sy bay_lun
147+
read the slot number from the bay identifier and append the lun number.
148+
Useful for multi-lun multi-actuator hard drives.
141149
.It Sy ses
142150
use the SCSI Enclosure Services (SES) enclosure device slot number,
143151
as reported by

Diff for: udev/vdev_id

+15-3
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ TOPOLOGY=
124124
BAY=
125125
ENCL_ID=""
126126
UNIQ_ENCL_ID=""
127+
ZPAD=1
127128

128129
usage() {
129130
cat << EOF
@@ -154,7 +155,7 @@ map_slot() {
154155
if [ -z "$MAPPED_SLOT" ] ; then
155156
MAPPED_SLOT=$LINUX_SLOT
156157
fi
157-
printf "%d" "${MAPPED_SLOT}"
158+
printf "%0${ZPAD}d" "${MAPPED_SLOT}"
158159
}
159160

160161
map_channel() {
@@ -430,6 +431,15 @@ sas_handler() {
430431
d=$(eval echo '$'{$i})
431432
SLOT=$(echo "$d" | sed -e 's/^.*://')
432433
;;
434+
"bay_lun")
435+
# Like 'bay' but with the LUN number appened. Added for SAS
436+
# multi-actuator HDDs, where one physical drive has multiple
437+
# LUNs, thus multiple logical drives share the same bay number
438+
i=$((i + 2))
439+
d=$(eval echo '$'{$i})
440+
LUN="-lun$(echo "$d" | sed -e 's/^.*://')"
441+
SLOT=$(cat "$end_device_dir/bay_identifier" 2>/dev/null)
442+
;;
433443
"ses")
434444
# look for this SAS path in all SCSI Enclosure Services
435445
# (SES) enclosures
@@ -460,15 +470,15 @@ sas_handler() {
460470
if [ -z "$CHAN" ] ; then
461471
return
462472
fi
463-
echo "${CHAN}"-"${JBOD}"-"${SLOT}${PART}"
473+
echo "${CHAN}"-"${JBOD}"-"${SLOT}${LUN}${PART}"
464474
else
465475
CHAN=$(map_channel "$PCI_ID" "$PORT")
466476
SLOT=$(map_slot "$SLOT" "$CHAN")
467477

468478
if [ -z "$CHAN" ] ; then
469479
return
470480
fi
471-
echo "${CHAN}${SLOT}${PART}"
481+
echo "${CHAN}${SLOT}${LUN}${PART}"
472482
fi
473483
}
474484

@@ -748,6 +758,8 @@ if [ -z "$BAY" ] ; then
748758
BAY=$(awk '($1 == "slot") {print $2; exit}' "$CONFIG")
749759
fi
750760

761+
ZPAD=$(awk '($1 == "zpad_slot") {print $2; exit}' "$CONFIG")
762+
751763
TOPOLOGY=${TOPOLOGY:-sas_direct}
752764

753765
# Should we create /dev/by-enclosure symlinks?

0 commit comments

Comments
 (0)