Lines Matching +full:port +full:- +full:expander
3 # vdev_id: udev helper to generate user-friendly names for JBOD disks
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
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
59 # # Example vdev_id.conf - sas_switch
64 # # SWITCH PORT CHANNEL NAME
71 # # Example vdev_id.conf - multipath
76 # # PCI_ID HBA PORT CHANNEL NAME
83 # # Example vdev_id.conf - multipath / multijbod-daisychaining
89 # # PCI_ID HBA PORT CHANNEL NAME
96 # # Example vdev_id.conf - multipath / mixed
102 # # PCI_ID HBA PORT CHANNEL NAME
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
152 MAPPED_SLOT=$(awk -v linux_slot="$LINUX_SLOT" -v channel="$CHANNEL" \
155 if [ -z "$MAPPED_SLOT" ] ; then
164 PORT=$2
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
213 # (whole enclosure) expander instances in /sys/class/enclosure and
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}')
231 # Different expander instances for each paths.
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 |
286 # take advantage of this to append a -part suffix. For
288 # we have to append the -part suffix directly in the
291 # WWNs end with number -> p<partition>, alphabet -> <partition>
295 # Match p[number], remove the 'p' and prepend "-part"
297 … awk 'match($0,/p[0-9]+$/) {print "-part"substr($0,RSTART+1,RLENGTH-1)}')
299 PART="-part"${PART}
305 if [ -z "$DM_NAME" ] ; then
312 # If our DEVNAME is something like /dev/dm-177, then we may be
315 if [ -n "$DMDEV" ]; then
318 if [[ $elm == "dm-"* ]]; then
325 if [ ! -e /sys/block/$DMDEV/slaves/* ] ; then
327 DMDEV=$(ls -l --full-time /dev/mapper | grep $DM_NAME |
328 awk '{gsub("../", " "); print $NF}' | head -n 1)
331 # Use sysfs pointers in /sys/block/dm-X/slaves because using
343 if [ -z "$DEV" ] ; then
348 if echo "$DEV" | grep -q ^/devices/ ; then
351 sys_path=$(udevadm info -q path -p "/sys/block/$DEV" 2>/dev/null)
354 # Use positional parameters as an ad-hoc array
355 set -- $(echo "$sys_path" | tr / ' ')
362 while [ $i -le "$num_dirs" ] ; do
365 echo "$d" | grep -q -E '^host[0-9]+$' && break
370 HOSTCHAN=$(echo "$d" | awk -F/ '{ gsub("host","",$NF); print $NF}')
376 PCI_ID=$(eval echo '$'{$((i -1))} | awk -F: '{print $2":"$3}')
380 # the switch port number. In sas_direct mode, the phy links one
381 # directory down reveal the HBA port.
391 while [ $i -le $j ] ; do
396 PHY=$(ls -vd "$port_dir"/phy* 2>/dev/null | head -1 | awk -F: '{print $NF}')
397 if [ -z "$PHY" ] ; then
400 PORT=$((PHY / PHYS_PER_PORT))
402 # Look in /sys/.../sas_device/end_device-X for the bay_identifier
406 while [ $i -lt "$num_dirs" ] ; do
409 if echo "$d" | grep -q '^end_device' ; then
416 # Add 'mix' slot type for environments where dm-multipath devices
417 # include end-devices connected via SAS expanders or direct connection
437 "port")
439 SLOT=$(echo "$d" | sed -e 's/^.*://')
444 SLOT=$(echo "$d" | sed -e 's/^.*://')
449 SLOT=$(echo "$d" | sed -e 's/^.*://')
453 # multi-actuator HDDs, where one physical drive has multiple
457 LUN="-lun$(echo "$d" | sed -e 's/^.*://')"
464 enclosures=$(lsscsi -g | \
465 sed -n -e '/enclosu/s/^.* \([^ ][^ ]*\) *$/\1/p')
467 set -- $(sg_ses -p aes "$enclosure" | \
472 if [ -n "$SLOT" ] ; then
478 if [ -z "$SLOT" ] ; then
483 CHAN=$(map_channel "$PCI_ID" "$PORT")
487 if [ -z "$CHAN" ] ; then
490 echo "${CHAN}"-"${JBOD}"-"${SLOT}${LUN}${PART}"
492 CHAN=$(map_channel "$PCI_ID" "$PORT")
495 if [ -z "$CHAN" ] ; then
503 if [ -z "$FIRST_BAY_NUMBER" ] ; then
507 FIRST_BAY_NUMBER=${FIRST_BAY_NUMBER:-0}
509 if [ -z "$PHYS_PER_PORT" ] ; then
513 PHYS_PER_PORT=${PHYS_PER_PORT:-4}
515 if ! echo "$PHYS_PER_PORT" | grep -q -E '^[0-9]+$' ; then
516 echo "Error: phys_per_port value $PHYS_PER_PORT is non-numeric"
520 if [ -z "$MULTIPATH_MODE" ] ; then
525 # Use first running component device if we're handling a dm-mpath device
528 if [ -z "$DM_NAME" ] ; then
529 DM_NAME=$(ls -l --full-time /dev/mapper |
535 # take advantage of this to append a -part suffix. For
537 # we have to append the -part suffix directly in the
540 # WWNs end with number -> p<partition>, alphabet -> <partition>
544 # Match p[number], remove the 'p' and prepend "-part"
546 … awk 'match($0,/p[0-9]+$/) {print "-part"substr($0,RSTART+1,RLENGTH-1)}')
548 PART="-part"${PART}
554 if [ -z "$DM_NAME" ] ; then
558 # Get the raw scsi device name from multipath -ll. Strip off
560 DEV=$(multipath -ll "$DM_NAME" |
562 if [ -z "$DEV" ] ; then
567 if echo "$DEV" | grep -q ^/devices/ ; then
570 sys_path=$(udevadm info -q path -p "/sys/block/$DEV" 2>/dev/null)
576 # Use positional parameters as an ad-hoc array
577 set -- $(echo "$sys_path" | tr / ' ')
584 while [ $i -le "$num_dirs" ] ; do
588 echo "$d" | grep -q -E '^host[0-9]+$' && break
596 PCI_ID=$(eval echo '$'{$((i -1))} | awk -F: '{print $2":"$3}')
599 # /sys/.../hostX reveals the port and slot.
604 while [ $i -le $j ] ; do
609 set -- $(echo "$port_dir" | sed -e 's/^.*:\([^:]*\):\([^:]*\)$/\1 \2/')
610 PORT=$1
613 if [ -z "$SLOT" ] ; then
617 CHAN=$(map_channel "$PCI_ID" "$PORT")
620 if [ -z "$CHAN" ] ; then
636 if [ ! -d "/sys/class/enclosure/$ENC" ] ; then
642 # /devices/pci0000:00/0000:00:03.0/0000:05:00.0/host0/port-0:0/ ... /enclosure/0:0:0:0
646 # Grab the full path to the hosts port dir:
647 # /devices/pci0000:00/0000:00:03.0/0000:05:00.0/host0/port-0:0
648 PORT_DIR=$(echo "$ENC_DEVICE" | grep -Eo '.+host[0-9]+/port-[0-9]+:[0-9]+')
650 # Get the port number
651 PORT_ID=$(echo "$PORT_DIR" | grep -Eo "[0-9]+$")
653 # The PCI directory is two directories up from the port directory
655 PCI_ID_LONG="$(readlink -m "/sys/$PORT_DIR/../..")"
659 PCI_ID="${PCI_ID_LONG#[0-9]*:}"
669 # Special handling is needed to correctly append a -part suffix
678 # /dev/disk/by-id/dm-name-isw_dibgbfcije_ARRAY0 -> ../../dm-0
679 # /dev/disk/by-id/dm-name-isw_dibgbfcije_ARRAY0p1 -> ../../dm-1
680 # /dev/disk/by-id/dm-name-isw_dibgbfcije_ARRAY0p2 -> ../../dm-3
684 # alias A0 dm-name-isw_dibgbfcije_ARRAY0
689 # /dev/disk/by-vdev/A0 -> ../../dm-0
690 # /dev/disk/by-vdev/A0-part1 -> ../../dm-1
691 # /dev/disk/by-vdev/A0-part2 -> ../../dm-3
693 # Warning: The following grep pattern will misidentify whole-disk
699 if echo "$DM_NAME" | grep -q -E 'p[0-9][0-9]*$' ; then
701 # Match p[number], remove the 'p' and prepend "-part"
703 awk 'match($0,/p[0-9]+$/) {print "-part"substr($0,RSTART+1,RLENGTH-1)}')
707 # DEVLINKS attribute must have been populated by already-run udev rules.
709 # Remove partition information to match key of top-level device.
710 if [ -n "$DM_PART" ] ; then
711 link=$(echo "$link" | sed 's/p[0-9][0-9]*$//')
715 if [ ! -z "$l" ]; then
716 alias=$(awk -v var="$l" '($1 == "alias") && \
719 if [ -n "$alias" ] ; then
738 # When udev sees a scsi_generic device, it calls this script with -e to
767 if [ ! -r "$CONFIG" ] ; then
772 if [ -z "$DEV" ] && [ -z "$ENCLOSURE_MODE" ] ; then
773 echo "Error: missing required option -d"
777 if [ -z "$TOPOLOGY" ] ; then
781 if [ -z "$BAY" ] ; then
787 TOPOLOGY=${TOPOLOGY:-sas_direct}
789 # Should we create /dev/by-enclosure symlinks?
792 if [ -z "$ID_ENCLOSURE" ] ; then
798 if [ -z "$ENCLOSURE_PREFIX" ] ; then
802 echo "ID_ENCLOSURE_PATH=by-enclosure/$ENCLOSURE_PREFIX-$ID_ENCLOSURE"
809 if [ -z "$ID_VDEV" ] ; then
810 BAY=${BAY:-bay}
825 if [ -n "$ID_VDEV" ] ; then
827 echo "ID_VDEV_PATH=disk/by-vdev/${ID_VDEV}"