Lines Matching +full:9 +full:- +full:channel
3 # vdev_id: udev helper to generate user-friendly names for JBOD disks
6 # physical path in a storage topology to a channel name. The
7 # channel name is combined with a disk enclosure slot number to
10 # failed drives. Slot numbers may also be re-mapped in case the
12 # created as symbolic links in /dev/disk/by-vdev.
15 # A multipath mode is supported in which dm-mpath devices are
16 # handled by examining the first-listed running component disk. In
17 # multipath mode the configuration file should contain a channel
20 # The alias keyword provides a simple way to map already-existing
29 # # Example vdev_id.conf - sas_direct.
37 # # PCI_ID HBA PORT CHANNEL NAME
38 # channel 85:00.0 1 A
39 # channel 85:00.0 0 B
40 # channel 86:00.0 1 C
41 # channel 86:00.0 0 D
43 # # Custom mapping for Channel A
46 # # Slot Slot Channel
59 # # Example vdev_id.conf - sas_switch
64 # # SWITCH PORT CHANNEL NAME
65 # channel 1 A
66 # channel 2 B
67 # channel 3 C
68 # channel 4 D
71 # # Example vdev_id.conf - multipath
76 # # PCI_ID HBA PORT CHANNEL NAME
77 # channel 85:00.0 1 A
78 # channel 85:00.0 0 B
79 # channel 86:00.0 1 A
80 # channel 86:00.0 0 B
83 # # Example vdev_id.conf - multipath / multijbod-daisychaining
89 # # PCI_ID HBA PORT CHANNEL NAME
90 # channel 85:00.0 1 A
91 # channel 85:00.0 0 B
92 # channel 86:00.0 1 A
93 # channel 86:00.0 0 B
96 # # Example vdev_id.conf - multipath / mixed
102 # # PCI_ID HBA PORT CHANNEL NAME
103 # channel 85:00.0 3 A
104 # channel 85:00.0 2 B
105 # channel 86:00.0 3 A
106 # channel 86:00.0 2 B
107 # channel af:00.0 0 C
108 # channel af:00.0 1 C
111 # # Example vdev_id.conf - alias
114 # # by-vdev
116 # alias d1 /dev/disk/by-id/wwn-0x5000c5002de3b9ca
117 # alias d2 wwn-0x5000c5002def789e
131 Usage: vdev_id [-h]
132 vdev_id <-d device> [-c config_file] [-p phys_per_port]
133 [-g sas_direct|sas_switch|scsi] [-m]
135 -c specify name of an alternative config file [default=$CONFIG]
136 -d specify basename of device (i.e. sda)
137 -e Create enclose device symlinks only (/dev/by-enclosure)
138 -g Storage network topology [default="$TOPOLOGY"]
139 -m Run in multipath mode
140 -j Run in multijbod mode
141 -p number of phy's per switch port [default=$PHYS_PER_PORT]
142 -h show this summary
150 CHANNEL=$2
152 MAPPED_SLOT=$(awk -v linux_slot="$LINUX_SLOT" -v channel="$CHANNEL" \
154 ($4 ~ "^"channel"$" || $4 ~ /^$/) { print $3; exit}' $CONFIG)
155 if [ -z "$MAPPED_SLOT" ] ; then
168 MAPPED_CHAN=$(awk -v port="$PORT" \
169 '$1 == "channel" && $2 == port \
173 MAPPED_CHAN=$(awk -v pciID="$PCI_ID" -v port="$PORT" \
174 '$1 == "channel" && $2 == pciID && $3 == port \
182 set -- $(echo $1)
186 while [ $i -le $count ] ; do
205 if [ $found -eq 0 ]; then
212 # expander and fanout expander. Use hostX instance along with top-level
220 DEVEXP=$(ls -l "/sys/block/$DEV/device/" | grep enclos | awk -F/ '{print $(NF-1) }')
223 # Use "set --" to create index values (Arrays)
224 set -- $(ls -l /sys/class/enclosure | grep -v "^total" | awk '{print $9}')
240 while [ $i -le $JBOD_COUNT ] ; do
255 if [ -z "$PHYS_PER_PORT" ] ; then
259 PHYS_PER_PORT=${PHYS_PER_PORT:-4}
261 if ! echo "$PHYS_PER_PORT" | grep -q -E '^[0-9]+$' ; then
262 echo "Error: phys_per_port value $PHYS_PER_PORT is non-numeric"
266 if [ -z "$MULTIPATH_MODE" ] ; then
271 if [ -z "$MULTIJBOD_MODE" ] ; then
276 # Use first running component device if we're handling a dm-mpath device
279 if [ -z "$DM_NAME" ] ; then
280 DM_NAME=$(ls -l --full-time /dev/mapper |
281 grep "$DEV"$ | awk '{print $9}')
286 # take advantage of this to append a -part suffix. For
288 # we have to append the -part suffix directly in the
291 # Match p[number], remove the 'p' and prepend "-part"
293 awk 'match($0,/p[0-9]+$/) {print "-part"substr($0,RSTART+1,RLENGTH-1)}')
297 DM_NAME=$(echo "$DM_NAME" | sed 's/p[0-9][0-9]*$//')
298 if [ -z "$DM_NAME" ] ; then
305 # If our DEVNAME is something like /dev/dm-177, then we may be
308 if [ ! -e /sys/block/$DMDEV/slaves/* ] ; then
310 DMDEV=$(ls -l --full-time /dev/mapper | grep $DM_NAME |
314 # Use sysfs pointers in /sys/block/dm-X/slaves because using
326 if [ -z "$DEV" ] ; then
331 if echo "$DEV" | grep -q ^/devices/ ; then
334 sys_path=$(udevadm info -q path -p "/sys/block/$DEV" 2>/dev/null)
337 # Use positional parameters as an ad-hoc array
338 set -- $(echo "$sys_path" | tr / ' ')
345 while [ $i -le "$num_dirs" ] ; do
348 echo "$d" | grep -q -E '^host[0-9]+$' && break
352 # Lets grab the SAS host channel number and save it for JBOD sorting later
353 HOSTCHAN=$(echo "$d" | awk -F/ '{ gsub("host","",$NF); print $NF}')
359 PCI_ID=$(eval echo '$'{$((i -1))} | awk -F: '{print $2":"$3}')
374 while [ $i -le $j ] ; do
379 PHY=$(ls -vd "$port_dir"/phy* 2>/dev/null | head -1 | awk -F: '{print $NF}')
380 if [ -z "$PHY" ] ; then
385 # Look in /sys/.../sas_device/end_device-X for the bay_identifier
389 while [ $i -lt "$num_dirs" ] ; do
392 if echo "$d" | grep -q '^end_device' ; then
399 # Add 'mix' slot type for environments where dm-multipath devices
400 # include end-devices connected via SAS expanders or direct connection
422 SLOT=$(echo "$d" | sed -e 's/^.*://')
427 SLOT=$(echo "$d" | sed -e 's/^.*://')
432 SLOT=$(echo "$d" | sed -e 's/^.*://')
436 # multi-actuator HDDs, where one physical drive has multiple
440 LUN="-lun$(echo "$d" | sed -e 's/^.*://')"
447 enclosures=$(lsscsi -g | \
448 sed -n -e '/enclosu/s/^.* \([^ ][^ ]*\) *$/\1/p')
450 set -- $(sg_ses -p aes "$enclosure" | \
455 if [ -n "$SLOT" ] ; then
461 if [ -z "$SLOT" ] ; then
470 if [ -z "$CHAN" ] ; then
473 echo "${CHAN}"-"${JBOD}"-"${SLOT}${LUN}${PART}"
478 if [ -z "$CHAN" ] ; then
486 if [ -z "$FIRST_BAY_NUMBER" ] ; then
490 FIRST_BAY_NUMBER=${FIRST_BAY_NUMBER:-0}
492 if [ -z "$PHYS_PER_PORT" ] ; then
496 PHYS_PER_PORT=${PHYS_PER_PORT:-4}
498 if ! echo "$PHYS_PER_PORT" | grep -q -E '^[0-9]+$' ; then
499 echo "Error: phys_per_port value $PHYS_PER_PORT is non-numeric"
503 if [ -z "$MULTIPATH_MODE" ] ; then
508 # Use first running component device if we're handling a dm-mpath device
511 if [ -z "$DM_NAME" ] ; then
512 DM_NAME=$(ls -l --full-time /dev/mapper |
513 grep "$DEV"$ | awk '{print $9}')
518 # take advantage of this to append a -part suffix. For
520 # we have to append the -part suffix directly in the
523 # Match p[number], remove the 'p' and prepend "-part"
525 awk 'match($0,/p[0-9]+$/) {print "-part"substr($0,RSTART+1,RLENGTH-1)}')
529 DM_NAME=$(echo "$DM_NAME" | sed 's/p[0-9][0-9]*$//')
530 if [ -z "$DM_NAME" ] ; then
534 # Get the raw scsi device name from multipath -ll. Strip off
536 DEV=$(multipath -ll "$DM_NAME" |
538 if [ -z "$DEV" ] ; then
543 if echo "$DEV" | grep -q ^/devices/ ; then
546 sys_path=$(udevadm info -q path -p "/sys/block/$DEV" 2>/dev/null)
552 # Use positional parameters as an ad-hoc array
553 set -- $(echo "$sys_path" | tr / ' ')
560 while [ $i -le "$num_dirs" ] ; do
564 echo "$d" | grep -q -E '^host[0-9]+$' && break
572 PCI_ID=$(eval echo '$'{$((i -1))} | awk -F: '{print $2":"$3}')
580 while [ $i -le $j ] ; do
585 set -- $(echo "$port_dir" | sed -e 's/^.*:\([^:]*\):\([^:]*\)$/\1 \2/')
589 if [ -z "$SLOT" ] ; then
596 if [ -z "$CHAN" ] ; then
612 if [ ! -d "/sys/class/enclosure/$ENC" ] ; then
618 # /devices/pci0000:00/0000:00:03.0/0000:05:00.0/host0/port-0:0/ ... /enclosure/0:0:0:0
623 # /devices/pci0000:00/0000:00:03.0/0000:05:00.0/host0/port-0:0
624 PORT_DIR=$(echo "$ENC_DEVICE" | grep -Eo '.+host[0-9]+/port-[0-9]+:[0-9]+')
627 PORT_ID=$(echo "$PORT_DIR" | grep -Eo "[0-9]+$")
631 PCI_ID_LONG="$(readlink -m "/sys/$PORT_DIR/../..")"
635 PCI_ID="${PCI_ID_LONG#[0-9]*:}"
638 NAME=$(awk "/channel/{if (\$1 == \"channel\" && \$2 == \"$PCI_ID\" && \
645 # Special handling is needed to correctly append a -part suffix
654 # /dev/disk/by-id/dm-name-isw_dibgbfcije_ARRAY0 -> ../../dm-0
655 # /dev/disk/by-id/dm-name-isw_dibgbfcije_ARRAY0p1 -> ../../dm-1
656 # /dev/disk/by-id/dm-name-isw_dibgbfcije_ARRAY0p2 -> ../../dm-3
660 # alias A0 dm-name-isw_dibgbfcije_ARRAY0
665 # /dev/disk/by-vdev/A0 -> ../../dm-0
666 # /dev/disk/by-vdev/A0-part1 -> ../../dm-1
667 # /dev/disk/by-vdev/A0-part2 -> ../../dm-3
669 # Warning: The following grep pattern will misidentify whole-disk
675 if echo "$DM_NAME" | grep -q -E 'p[0-9][0-9]*$' ; then
677 # Match p[number], remove the 'p' and prepend "-part"
679 awk 'match($0,/p[0-9]+$/) {print "-part"substr($0,RSTART+1,RLENGTH-1)}')
683 # DEVLINKS attribute must have been populated by already-run udev rules.
685 # Remove partition information to match key of top-level device.
686 if [ -n "$DM_PART" ] ; then
687 link=$(echo "$link" | sed 's/p[0-9][0-9]*$//')
691 if [ ! -z "$l" ]; then
692 alias=$(awk -v var="$l" '($1 == "alias") && \
695 if [ -n "$alias" ] ; then
714 # When udev sees a scsi_generic device, it calls this script with -e to
743 if [ ! -r "$CONFIG" ] ; then
748 if [ -z "$DEV" ] && [ -z "$ENCLOSURE_MODE" ] ; then
749 echo "Error: missing required option -d"
753 if [ -z "$TOPOLOGY" ] ; then
757 if [ -z "$BAY" ] ; then
763 TOPOLOGY=${TOPOLOGY:-sas_direct}
765 # Should we create /dev/by-enclosure symlinks?
768 if [ -z "$ID_ENCLOSURE" ] ; then
774 if [ -z "$ENCLOSURE_PREFIX" ] ; then
778 echo "ID_ENCLOSURE_PATH=by-enclosure/$ENCLOSURE_PREFIX-$ID_ENCLOSURE"
785 if [ -z "$ID_VDEV" ] ; then
786 BAY=${BAY:-bay}
801 if [ -n "$ID_VDEV" ] ; then
803 echo "ID_VDEV_PATH=disk/by-vdev/${ID_VDEV}"