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 <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2056
This commit is contained in:
Ned Bass 2014-01-13 13:32:41 -08:00 committed by Brian Behlendorf
parent 35d3e32274
commit 09d0b30fd1
3 changed files with 65 additions and 81 deletions

View File

@ -39,18 +39,20 @@
# channel 86:00.0 1 C # channel 86:00.0 1 C
# channel 86:00.0 0 D # channel 86:00.0 0 D
# #
# # Linux Mapped # # Custom mapping for Channel A
# # Slot Slot #
# slot 1 7 # # Linux Mapped
# slot 2 10 # # Slot Slot Channel
# slot 3 3 # slot 1 7 A
# slot 4 6 # slot 2 10 A
# slot 5 2 # slot 3 3 A
# slot 6 8 # slot 4 6 A
# slot 7 1 #
# slot 8 4 # # Default mapping for B, C, and D
# slot 9 9 # slot 1 4
# slot 10 5 # slot 2 2
# slot 3 1
# slot 4 3
# # # #
# # Example vdev_id.conf - sas_switch # # Example vdev_id.conf - sas_switch
@ -110,10 +112,11 @@ EOF
map_slot() { map_slot() {
local LINUX_SLOT=$1 local LINUX_SLOT=$1
local CHANNEL=$2
local MAPPED_SLOT= local MAPPED_SLOT=
MAPPED_SLOT=`awk "\\$1 == \"slot\" && \\$2 == ${LINUX_SLOT} \ MAPPED_SLOT=`awk "\\$1 == \"slot\" && \\$2 == ${LINUX_SLOT} && \
{ print \\$3; exit }" $CONFIG` \\$4 ~ /^(${CHANNEL}|)$/ { print \\$3; exit }" $CONFIG`
if [ -z "$MAPPED_SLOT" ] ; then if [ -z "$MAPPED_SLOT" ] ; then
MAPPED_SLOT=$LINUX_SLOT MAPPED_SLOT=$LINUX_SLOT
fi fi
@ -254,8 +257,8 @@ sas_handler() {
return return
fi fi
SLOT=`map_slot $SLOT`
CHAN=`map_channel $PCI_ID $PORT` CHAN=`map_channel $PCI_ID $PORT`
SLOT=`map_slot $SLOT $CHAN`
if [ -z "$CHAN" ] ; then if [ -z "$CHAN" ] ; then
return return
fi fi

View File

@ -8,15 +8,18 @@ channel 85:00.0 0 B
channel 86:00.0 1 C channel 86:00.0 1 C
channel 86:00.0 0 D channel 86:00.0 0 D
# Custom mapping for Channel A
# Linux Mapped # Linux Mapped
# Slot Slot # Slot Slot Channel
slot 1 7 slot 1 7 A
slot 2 10 slot 2 10 A
slot 3 3 slot 3 3 A
slot 4 6 slot 4 6 A
slot 5 2
slot 6 8 # Default mapping for B, C, and D
slot 7 1 slot 1 4
slot 8 4 slot 2 2
slot 9 9 slot 3 1
slot 10 5 slot 4 3

View File

@ -49,9 +49,17 @@ connected to the disk enclosure being mapped.
\fIname\fR - specifies the name of the channel. \fIname\fR - specifies the name of the channel.
.TP .TP
\fIslot\fR <old> <new> \fIslot\fR <old> <new> [channel]
Maps a disk slot number as reported by the operating system Maps a disk slot number as reported by the operating system to an
to an alternative slot number. alternative slot number. If the \fIchannel\fR parameter is specified
then the mapping is only applied to slots in the named channel,
otherwise the mapping is applied to all channels. The first-specified
\fIslot\fR rule that can match a slot takes precedence. Therefore a
channel-specific mapping for a given slot should generally appear 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.
.TP .TP
\fImultipath\fR <yes|no> \fImultipath\fR <yes|no>
Specifies whether Specifies whether
@ -84,99 +92,69 @@ device is connected to. The default is 4.
A non-multipath configuration with direct-attached SAS enclosures and an A non-multipath configuration with direct-attached SAS enclosures and an
arbitrary slot re-mapping. arbitrary slot re-mapping.
.P .P
.nf
multipath no multipath no
.br
topology sas_direct topology sas_direct
.br
phys_per_port 4 phys_per_port 4
.br
.br
# PCI_SLOT HBA PORT CHANNEL NAME # PCI_SLOT HBA PORT CHANNEL NAME
.br
channel 85:00.0 1 A channel 85:00.0 1 A
.br
channel 85:00.0 0 B channel 85:00.0 0 B
.br
channel 86:00.0 1 C channel 86:00.0 1 C
.br
channel 86:00.0 0 D channel 86:00.0 0 D
.br
.br # Custom mapping for Channel A
# Linux Mapped # Linux Mapped
.br # Slot Slot Channel
# Slot Slot slot 1 7 A
.br slot 2 10 A
slot 1 7 slot 3 3 A
.br slot 4 6 A
slot 2 10
.br # Default mapping for B, C, and D
slot 3 3
.br slot 1 4
slot 4 6 slot 2 2
.br slot 3 1
slot 5 2 slot 4 3
.br .fi
slot 6 8
.br
slot 7 1
.br
slot 8 4
.br
slot 9 9
.br
slot 10 5
.br
.P .P
A SAS-switch topology. Note that the A SAS-switch topology. Note that the
.I channel .I channel
keyword takes only two arguments in this example. keyword takes only two arguments in this example.
.P .P
.nf
topology sas_switch topology sas_switch
.br
.br
# SWITCH PORT CHANNEL NAME # SWITCH PORT CHANNEL NAME
.br
channel 1 A channel 1 A
.br
channel 2 B channel 2 B
.br
channel 3 C channel 3 C
.br
channel 4 D channel 4 D
.br .fi
.P .P
A multipath configuration. Note that channel names have multiple A multipath configuration. Note that channel names have multiple
definitions - one per physical path. definitions - one per physical path.
.P .P
.nf
multipath yes multipath yes
.br
.br
# PCI_SLOT HBA PORT CHANNEL NAME # PCI_SLOT HBA PORT CHANNEL NAME
.br
channel 85:00.0 1 A channel 85:00.0 1 A
.br
channel 85:00.0 0 B channel 85:00.0 0 B
.br
channel 86:00.0 1 A channel 86:00.0 1 A
.br
channel 86:00.0 0 B channel 86:00.0 0 B
.br .fi
.P .P
A configuration using device link aliases. A configuration using device link aliases.
.P .P
.br .nf
# by-vdev # by-vdev
.br
# name fully qualified or base name of device link # name fully qualified or base name of device link
.br
alias d1 /dev/disk/by-id/wwn-0x5000c5002de3b9ca alias d1 /dev/disk/by-id/wwn-0x5000c5002de3b9ca
.br
alias d2 wwn-0x5000c5002def789e alias d2 wwn-0x5000c5002def789e
.br .fi
.P .P
.SH FILES .SH FILES