Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vdev_id: multi-lun disks & slot num zero pad #16603

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion man/man5/vdev_id.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -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
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.
.
.It Sy multipath Sy yes Ns | Ns Sy no
Specifies whether
.Xr vdev_id 8
Expand Down Expand Up @@ -122,7 +127,7 @@ device is connected to.
The default is
.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
taken.
The default is
Expand All @@ -138,6 +143,9 @@ use the SAS port as the slot number.
use the scsi id as the slot number.
.It Sy lun
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
use the SCSI Enclosure Services (SES) enclosure device slot number,
as reported by
Expand Down
15 changes: 12 additions & 3 deletions udev/vdev_id
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ TOPOLOGY=
BAY=
ENCL_ID=""
UNIQ_ENCL_ID=""
ZPAD=1

usage() {
cat << EOF
Expand Down Expand Up @@ -154,7 +155,7 @@ map_slot() {
if [ -z "$MAPPED_SLOT" ] ; then
MAPPED_SLOT=$LINUX_SLOT
fi
printf "%d" "${MAPPED_SLOT}"
printf "%0${ZPAD}d" "${MAPPED_SLOT}"
}

map_channel() {
Expand Down Expand Up @@ -430,6 +431,12 @@ sas_handler() {
d=$(eval echo '$'{$i})
SLOT=$(echo "$d" | sed -e 's/^.*://')
;;
"bay_lun")
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")
# look for this SAS path in all SCSI Enclosure Services
# (SES) enclosures
Expand Down Expand Up @@ -460,15 +467,15 @@ sas_handler() {
if [ -z "$CHAN" ] ; then
return
fi
echo "${CHAN}"-"${JBOD}"-"${SLOT}${PART}"
echo "${CHAN}"-"${JBOD}"-"${SLOT}${LUN}${PART}"
else
CHAN=$(map_channel "$PCI_ID" "$PORT")
SLOT=$(map_slot "$SLOT" "$CHAN")

if [ -z "$CHAN" ] ; then
return
fi
echo "${CHAN}${SLOT}${PART}"
echo "${CHAN}${SLOT}${LUN}${PART}"
fi
}

Expand Down Expand Up @@ -748,6 +755,8 @@ if [ -z "$BAY" ] ; then
BAY=$(awk '($1 == "slot") {print $2; exit}' "$CONFIG")
fi

ZPAD=$(awk '($1 == "zpad_slot") {print $2; exit}' "$CONFIG")

TOPOLOGY=${TOPOLOGY:-sas_direct}

# Should we create /dev/by-enclosure symlinks?
Expand Down
Loading