aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcmd/zpool_layout/zpool_layout67
-rwxr-xr-xconfigure3
-rw-r--r--configure.ac1
-rw-r--r--scripts/Makefile.am2
-rw-r--r--scripts/Makefile.in2
-rw-r--r--scripts/zpool-layout/Makefile.am22
-rw-r--r--scripts/zpool-layout/dragon.ddn.conf67
-rw-r--r--scripts/zpool-layout/dragon.llnl.conf67
8 files changed, 211 insertions, 20 deletions
diff --git a/cmd/zpool_layout/zpool_layout b/cmd/zpool_layout/zpool_layout
index 19cd12807..432c1576e 100755
--- a/cmd/zpool_layout/zpool_layout
+++ b/cmd/zpool_layout/zpool_layout
@@ -12,26 +12,30 @@
# /etc/zfs/zdev.conf file, it allows the by-path naming convertion
# to change and still keep the simple <channel><rank> naming.
#
+AWK=${AWK:-/bin/awk}
CONFIG=${CONFIG:-/etc/zfs/zdev.conf}
BUSES=( 01 02 03 )
PORTS=( 4 0 )
CHANNELS=( A B C D E F G H I J K L M N O P Q R S T U V W X Y Z )
-TRIGGER=
+TRIGGER="no"
+MAPPING=linux
+
usage() {
cat << EOF
-Usage: zpool_layout [-th] [-c file] [-b buses] [-p ports] [-n channels]
- -c Alternate config file [default=/etc/zfs/zdev.conf]
- -b Enumerate buses [default="01 02 03"]
- -p Enumerate ports [default="4 0"]
+Usage: zpool_layout [-th] [-c file] [-b buses] [-p ports] [-n channels] [-m map]
+ -c Alternate config file [default=${CONFIG}]
+ -b Enumerate buses [default="${BUSES[*]}"]
+ -p Enumerate ports [default="${PORTS[*]}"]
-n Channel names [default="A..Z"]
- -t Trigger and wait for udev to settle [default=no]
+ -t Trigger and wait for udev to settle [default=${TRIGGER}]
+ -m Slot mapping [default=${MAPPING}]
-h Show this message
EOF
exit 0
}
-while getopts 'c:b:p:n:th' OPTION; do
+while getopts 'c:b:p:n:m:th' OPTION; do
case ${OPTION} in
c)
CONFIG=${OPTARG}
@@ -45,8 +49,11 @@ while getopts 'c:b:p:n:th' OPTION; do
n)
CHANNELS=(${OPTARG})
;;
+ m)
+ MAPPING=`readlink -e ${OPTARG}`
+ ;;
t)
- TRIGGER=1
+ TRIGGER=yes
;;
h)
usage
@@ -54,11 +61,31 @@ while getopts 'c:b:p:n:th' OPTION; do
esac
done
+# Verify mapping file exists if specified.
+# Linux-Slot Custom-Slot
+if [ ${MAPPING} != "linux" ] && [ ! -e ${MAPPING} ]; then
+ echo "Error: Mapping file '${MAPPING}' does not exist"
+ exit 1
+fi
+
# Save stdout as fd #8, then redirect stdout to the config file.
exec 8>&1
exec >${CONFIG}
pushd /dev/disk/by-path >/dev/null
+map_slot() {
+ local LINUX_SLOT=$1
+ local MAPPED_SLOT=
+
+ if [ ${MAPPING} = "linux" ]; then
+ MAPPED_SLOT=${LINUX_SLOT}
+ else
+ MAPPED_SLOT=`${AWK} "\\$1 == ${LINUX_SLOT} && !/^#/ \
+ { print \\$2; exit }" $MAPPING`
+ fi
+ printf "%d" ${MAPPED_SLOT}
+}
+
# Generate comment header.
echo "#"
echo "# Custom /dev/disk/by-path to /dev/disk/zpool mapping, "
@@ -98,28 +125,34 @@ done
echo "#"
# Generate mapping from <channel><rank> to by-path name.
-TMP_FILE=`mktemp`
-AWK=${AWK:-/bin/awk}
-
for (( i=0, k=0; i<${#BUSES[*]}; i++ )); do
for (( j=0; j<${#PORTS[*]}; j++, k++ )); do
- ls *:${BUSES[$i]}:*:${PORTS[$j]}* 2>/dev/null | \
- grep -v part | sort -n -k7 -t'-'>${TMP_FILE}
+ BYPATH=(`ls *:${BUSES[$i]}:*:${PORTS[$j]}* 2>/dev/null | \
+ grep -v part | sort -n -k7 -t'-' | cut -f1-6 -d'-'`)
+ SLOTS=(`ls *:${BUSES[$i]}:*:${PORTS[$j]}* 2>/dev/null | \
+ grep -v part | sort -n -k7 -t'-' | cut -f7 -d'-'`)
+ TMP_FILE=`mktemp`
+
+ for (( l=0; l<${#SLOTS[*]}; l++ )); do
+ MAPPED_SLOT=`map_slot ${SLOTS[$l]}`
+ printf "%s%d\t%s-%d\n" \
+ ${CHANNELS[$k]} ${MAPPED_SLOT} \
+ ${BYPATH[$l]} ${SLOTS[$l]} >>${TMP_FILE}
+ done
echo
echo -n "# Channel ${CHANNELS[$k]}, "
echo "Bus ${BUSES[$i]}, Port ${PORTS[$j]}"
- ${AWK} -F '-' -v ch="${CHANNELS[$k]}" \
- '{print ch$7 "\t" $0 }' ${TMP_FILE}
+ cat ${TMP_FILE} | sort -n -k2 -t${CHANNELS[$k]}
+ rm -f ${TMP_FILE}
done
done
# Restore stdout from fd #8 and close fd #8.
exec 1>&8 8>&-
-rm -f ${TMP_FILE}
popd >/dev/null
-if [ ${TRIGGER} ]; then
+if [ ${TRIGGER} = "yes" ]; then
udevadm trigger
udevadm settle
fi
diff --git a/configure b/configure
index f386dd8bd..7bb25aba6 100755
--- a/configure
+++ b/configure
@@ -17904,7 +17904,7 @@ fi
$as_echo "$enable_debug" >&6; }
-ac_config_files="$ac_config_files Makefile etc/Makefile man/Makefile man/man8/Makefile lib/Makefile lib/libspl/Makefile lib/libspl/asm-generic/Makefile lib/libspl/asm-i386/Makefile lib/libspl/asm-x86_64/Makefile lib/libspl/include/Makefile lib/libspl/include/ia32/Makefile lib/libspl/include/ia32/sys/Makefile lib/libspl/include/rpc/Makefile lib/libspl/include/sys/Makefile lib/libspl/include/sys/sysevent/Makefile lib/libspl/include/sys/dktp/Makefile lib/libspl/include/util/Makefile lib/libavl/Makefile lib/libefi/Makefile lib/libnvpair/Makefile lib/libunicode/Makefile lib/libuutil/Makefile lib/libzpool/Makefile lib/libzfs/Makefile cmd/Makefile cmd/zdb/Makefile cmd/zfs/Makefile cmd/zinject/Makefile cmd/zpool/Makefile cmd/zpool_id/Makefile cmd/zpool_layout/Makefile cmd/ztest/Makefile cmd/zpios/Makefile module/Makefile module/avl/Makefile module/nvpair/Makefile module/unicode/Makefile module/zcommon/Makefile module/zfs/Makefile module/zpios/Makefile include/Makefile include/sys/Makefile include/sys/fs/Makefile include/sys/fm/Makefile include/sys/fm/fs/Makefile scripts/Makefile scripts/zpios-profile/Makefile scripts/zpios-test/Makefile scripts/zpool-config/Makefile scripts/common.sh zfs.spec zfs-modules.spec zfs-script-config.sh"
+ac_config_files="$ac_config_files Makefile etc/Makefile man/Makefile man/man8/Makefile lib/Makefile lib/libspl/Makefile lib/libspl/asm-generic/Makefile lib/libspl/asm-i386/Makefile lib/libspl/asm-x86_64/Makefile lib/libspl/include/Makefile lib/libspl/include/ia32/Makefile lib/libspl/include/ia32/sys/Makefile lib/libspl/include/rpc/Makefile lib/libspl/include/sys/Makefile lib/libspl/include/sys/sysevent/Makefile lib/libspl/include/sys/dktp/Makefile lib/libspl/include/util/Makefile lib/libavl/Makefile lib/libefi/Makefile lib/libnvpair/Makefile lib/libunicode/Makefile lib/libuutil/Makefile lib/libzpool/Makefile lib/libzfs/Makefile cmd/Makefile cmd/zdb/Makefile cmd/zfs/Makefile cmd/zinject/Makefile cmd/zpool/Makefile cmd/zpool_id/Makefile cmd/zpool_layout/Makefile cmd/ztest/Makefile cmd/zpios/Makefile module/Makefile module/avl/Makefile module/nvpair/Makefile module/unicode/Makefile module/zcommon/Makefile module/zfs/Makefile module/zpios/Makefile include/Makefile include/sys/Makefile include/sys/fs/Makefile include/sys/fm/Makefile include/sys/fm/fs/Makefile scripts/Makefile scripts/zpios-profile/Makefile scripts/zpios-test/Makefile scripts/zpool-config/Makefile scripts/zpool-layout/Makefile scripts/common.sh zfs.spec zfs-modules.spec zfs-script-config.sh"
cat >confcache <<\_ACEOF
@@ -18869,6 +18869,7 @@ do
"scripts/zpios-profile/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/zpios-profile/Makefile" ;;
"scripts/zpios-test/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/zpios-test/Makefile" ;;
"scripts/zpool-config/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/zpool-config/Makefile" ;;
+ "scripts/zpool-layout/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/zpool-layout/Makefile" ;;
"scripts/common.sh") CONFIG_FILES="$CONFIG_FILES scripts/common.sh" ;;
"zfs.spec") CONFIG_FILES="$CONFIG_FILES zfs.spec" ;;
"zfs-modules.spec") CONFIG_FILES="$CONFIG_FILES zfs-modules.spec" ;;
diff --git a/configure.ac b/configure.ac
index d42b0c9f5..593271061 100644
--- a/configure.ac
+++ b/configure.ac
@@ -103,6 +103,7 @@ AC_CONFIG_FILES([
scripts/zpios-profile/Makefile
scripts/zpios-test/Makefile
scripts/zpool-config/Makefile
+ scripts/zpool-layout/Makefile
scripts/common.sh
zfs.spec
zfs-modules.spec
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index cc8c69602..4df4b277c 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = zpool-config zpios-test zpios-profile
+SUBDIRS = zpool-config zpool-layout zpios-test zpios-profile
pkglibexecdir = $(libexecdir)/@PACKAGE@
dist_pkglibexec_SCRIPTS = \
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index 3154ed7d7..cd9971b0a 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -311,7 +311,7 @@ target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = zpool-config zpios-test zpios-profile
+SUBDIRS = zpool-config zpool-layout zpios-test zpios-profile
dist_pkglibexec_SCRIPTS = \
$(top_builddir)/scripts/common.sh \
$(top_srcdir)/scripts/zconfig.sh \
diff --git a/scripts/zpool-layout/Makefile.am b/scripts/zpool-layout/Makefile.am
new file mode 100644
index 000000000..3eef2412d
--- /dev/null
+++ b/scripts/zpool-layout/Makefile.am
@@ -0,0 +1,22 @@
+pkglibexecdir = $(libexecdir)/@PACKAGE@/zpool-layout
+dist_pkglibexec_SCRIPTS = \
+ $(top_srcdir)/scripts/zpool-layout/dragon.ddn.conf \
+ $(top_srcdir)/scripts/zpool-layout/dragon.llnl.conf
+
+all:
+ @list='$(dist_pkglibexec_SCRIPTS)'; \
+ for file in $$list; do \
+ link=$$(basename $$file); \
+ if [ ! -e $$link ]; then \
+ $(LN_S) $$file $$link; \
+ fi \
+ done
+
+clean:
+ @list='$(dist_pkglibexec_SCRIPTS)'; \
+ for file in $$list; do \
+ link=$$(basename $$file); \
+ if [ -L $$link ]; then \
+ $(RM) $$link; \
+ fi \
+ done
diff --git a/scripts/zpool-layout/dragon.ddn.conf b/scripts/zpool-layout/dragon.ddn.conf
new file mode 100644
index 000000000..c797b4dba
--- /dev/null
+++ b/scripts/zpool-layout/dragon.ddn.conf
@@ -0,0 +1,67 @@
+#
+# Custom DDN slot mapping for zpool_layout command and
+# StorageScaler 6000 enclosures (Dragon Drawer).
+#
+# Linux DDN
+# Slot Slot
+#
+1 1
+2 13
+3 25
+4 37
+5 49
+6 2
+7 14
+8 26
+9 38
+10 50
+11 3
+12 15
+13 27
+14 39
+15 51
+16 4
+17 16
+18 28
+19 40
+20 52
+21 5
+22 17
+23 29
+24 41
+25 53
+26 6
+27 18
+28 30
+29 42
+30 54
+31 7
+32 19
+33 31
+34 43
+35 55
+36 8
+37 20
+38 32
+39 44
+40 56
+41 9
+42 21
+43 33
+44 45
+45 57
+46 10
+47 22
+48 34
+49 46
+50 58
+51 11
+52 23
+53 35
+54 47
+55 59
+56 12
+57 24
+58 36
+59 48
+60 60
diff --git a/scripts/zpool-layout/dragon.llnl.conf b/scripts/zpool-layout/dragon.llnl.conf
new file mode 100644
index 000000000..0c684c784
--- /dev/null
+++ b/scripts/zpool-layout/dragon.llnl.conf
@@ -0,0 +1,67 @@
+#
+# Custom LLNL slot mapping for zpool_layout command and
+# StorageScaler 6000 enclosures (Dragon Drawer).
+#
+# Linux LLNL
+# Slot Slot
+#
+1 25
+2 19
+3 13
+4 7
+5 1
+6 26
+7 20
+8 14
+9 8
+10 2
+11 27
+12 21
+13 15
+14 9
+15 3
+16 28
+17 22
+18 16
+19 10
+20 4
+21 29
+22 23
+23 17
+24 11
+25 5
+26 30
+27 24
+28 18
+29 12
+30 6
+31 60
+32 54
+33 48
+34 42
+35 36
+36 59
+37 53
+38 47
+39 41
+40 35
+41 58
+42 52
+43 46
+44 40
+45 34
+46 57
+47 51
+48 45
+49 39
+50 33
+51 56
+52 50
+53 44
+54 38
+55 32
+56 55
+57 49
+58 43
+59 37
+60 31