mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 18:59:33 +03:00
Add [-m map] option to zpool_layout
By default the zpool_layout command would always use the slot number assigned by Linux when generating the zdev.conf file. This is a reasonable default there are cases when it makes sense to remap the slot id assigned by Linux using your own custom mapping. This commit adds support to zpool_layout to provide a custom slot mapping file. The file contains in the first column the Linux slot it and in the second column the custom slot mapping. By passing this map file with '-m map' to zpool_config the mapping will be applied when generating zdev.conf. Additionally, two sample mapping have been added which reflect different ways to map the slots in the dragon drawers.
This commit is contained in:
parent
bbf3a3575c
commit
a5b4d63582
@ -12,26 +12,30 @@
|
|||||||
# /etc/zfs/zdev.conf file, it allows the by-path naming convertion
|
# /etc/zfs/zdev.conf file, it allows the by-path naming convertion
|
||||||
# to change and still keep the simple <channel><rank> naming.
|
# to change and still keep the simple <channel><rank> naming.
|
||||||
#
|
#
|
||||||
|
AWK=${AWK:-/bin/awk}
|
||||||
CONFIG=${CONFIG:-/etc/zfs/zdev.conf}
|
CONFIG=${CONFIG:-/etc/zfs/zdev.conf}
|
||||||
BUSES=( 01 02 03 )
|
BUSES=( 01 02 03 )
|
||||||
PORTS=( 4 0 )
|
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 )
|
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() {
|
usage() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
Usage: zpool_layout [-th] [-c file] [-b buses] [-p ports] [-n channels]
|
Usage: zpool_layout [-th] [-c file] [-b buses] [-p ports] [-n channels] [-m map]
|
||||||
-c Alternate config file [default=/etc/zfs/zdev.conf]
|
-c Alternate config file [default=${CONFIG}]
|
||||||
-b Enumerate buses [default="01 02 03"]
|
-b Enumerate buses [default="${BUSES[*]}"]
|
||||||
-p Enumerate ports [default="4 0"]
|
-p Enumerate ports [default="${PORTS[*]}"]
|
||||||
-n Channel names [default="A..Z"]
|
-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
|
-h Show this message
|
||||||
EOF
|
EOF
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts 'c:b:p:n:th' OPTION; do
|
while getopts 'c:b:p:n:m:th' OPTION; do
|
||||||
case ${OPTION} in
|
case ${OPTION} in
|
||||||
c)
|
c)
|
||||||
CONFIG=${OPTARG}
|
CONFIG=${OPTARG}
|
||||||
@ -45,8 +49,11 @@ while getopts 'c:b:p:n:th' OPTION; do
|
|||||||
n)
|
n)
|
||||||
CHANNELS=(${OPTARG})
|
CHANNELS=(${OPTARG})
|
||||||
;;
|
;;
|
||||||
|
m)
|
||||||
|
MAPPING=`readlink -e ${OPTARG}`
|
||||||
|
;;
|
||||||
t)
|
t)
|
||||||
TRIGGER=1
|
TRIGGER=yes
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
@ -54,11 +61,31 @@ while getopts 'c:b:p:n:th' OPTION; do
|
|||||||
esac
|
esac
|
||||||
done
|
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.
|
# Save stdout as fd #8, then redirect stdout to the config file.
|
||||||
exec 8>&1
|
exec 8>&1
|
||||||
exec >${CONFIG}
|
exec >${CONFIG}
|
||||||
pushd /dev/disk/by-path >/dev/null
|
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.
|
# Generate comment header.
|
||||||
echo "#"
|
echo "#"
|
||||||
echo "# Custom /dev/disk/by-path to /dev/disk/zpool mapping, "
|
echo "# Custom /dev/disk/by-path to /dev/disk/zpool mapping, "
|
||||||
@ -98,28 +125,34 @@ done
|
|||||||
echo "#"
|
echo "#"
|
||||||
|
|
||||||
# Generate mapping from <channel><rank> to by-path name.
|
# 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 (( i=0, k=0; i<${#BUSES[*]}; i++ )); do
|
||||||
for (( j=0; j<${#PORTS[*]}; j++, k++ )); do
|
for (( j=0; j<${#PORTS[*]}; j++, k++ )); do
|
||||||
ls *:${BUSES[$i]}:*:${PORTS[$j]}* 2>/dev/null | \
|
BYPATH=(`ls *:${BUSES[$i]}:*:${PORTS[$j]}* 2>/dev/null | \
|
||||||
grep -v part | sort -n -k7 -t'-'>${TMP_FILE}
|
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
|
||||||
echo -n "# Channel ${CHANNELS[$k]}, "
|
echo -n "# Channel ${CHANNELS[$k]}, "
|
||||||
echo "Bus ${BUSES[$i]}, Port ${PORTS[$j]}"
|
echo "Bus ${BUSES[$i]}, Port ${PORTS[$j]}"
|
||||||
${AWK} -F '-' -v ch="${CHANNELS[$k]}" \
|
cat ${TMP_FILE} | sort -n -k2 -t${CHANNELS[$k]}
|
||||||
'{print ch$7 "\t" $0 }' ${TMP_FILE}
|
rm -f ${TMP_FILE}
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
# Restore stdout from fd #8 and close fd #8.
|
# Restore stdout from fd #8 and close fd #8.
|
||||||
exec 1>&8 8>&-
|
exec 1>&8 8>&-
|
||||||
rm -f ${TMP_FILE}
|
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
|
|
||||||
if [ ${TRIGGER} ]; then
|
if [ ${TRIGGER} = "yes" ]; then
|
||||||
udevadm trigger
|
udevadm trigger
|
||||||
udevadm settle
|
udevadm settle
|
||||||
fi
|
fi
|
||||||
|
3
configure
vendored
3
configure
vendored
@ -17904,7 +17904,7 @@ fi
|
|||||||
$as_echo "$enable_debug" >&6; }
|
$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
|
cat >confcache <<\_ACEOF
|
||||||
@ -18869,6 +18869,7 @@ do
|
|||||||
"scripts/zpios-profile/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/zpios-profile/Makefile" ;;
|
"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/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-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" ;;
|
"scripts/common.sh") CONFIG_FILES="$CONFIG_FILES scripts/common.sh" ;;
|
||||||
"zfs.spec") CONFIG_FILES="$CONFIG_FILES zfs.spec" ;;
|
"zfs.spec") CONFIG_FILES="$CONFIG_FILES zfs.spec" ;;
|
||||||
"zfs-modules.spec") CONFIG_FILES="$CONFIG_FILES zfs-modules.spec" ;;
|
"zfs-modules.spec") CONFIG_FILES="$CONFIG_FILES zfs-modules.spec" ;;
|
||||||
|
@ -103,6 +103,7 @@ AC_CONFIG_FILES([
|
|||||||
scripts/zpios-profile/Makefile
|
scripts/zpios-profile/Makefile
|
||||||
scripts/zpios-test/Makefile
|
scripts/zpios-test/Makefile
|
||||||
scripts/zpool-config/Makefile
|
scripts/zpool-config/Makefile
|
||||||
|
scripts/zpool-layout/Makefile
|
||||||
scripts/common.sh
|
scripts/common.sh
|
||||||
zfs.spec
|
zfs.spec
|
||||||
zfs-modules.spec
|
zfs-modules.spec
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
SUBDIRS = zpool-config zpios-test zpios-profile
|
SUBDIRS = zpool-config zpool-layout zpios-test zpios-profile
|
||||||
|
|
||||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||||
dist_pkglibexec_SCRIPTS = \
|
dist_pkglibexec_SCRIPTS = \
|
||||||
|
@ -311,7 +311,7 @@ target_vendor = @target_vendor@
|
|||||||
top_build_prefix = @top_build_prefix@
|
top_build_prefix = @top_build_prefix@
|
||||||
top_builddir = @top_builddir@
|
top_builddir = @top_builddir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
SUBDIRS = zpool-config zpios-test zpios-profile
|
SUBDIRS = zpool-config zpool-layout zpios-test zpios-profile
|
||||||
dist_pkglibexec_SCRIPTS = \
|
dist_pkglibexec_SCRIPTS = \
|
||||||
$(top_builddir)/scripts/common.sh \
|
$(top_builddir)/scripts/common.sh \
|
||||||
$(top_srcdir)/scripts/zconfig.sh \
|
$(top_srcdir)/scripts/zconfig.sh \
|
||||||
|
22
scripts/zpool-layout/Makefile.am
Normal file
22
scripts/zpool-layout/Makefile.am
Normal file
@ -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
|
67
scripts/zpool-layout/dragon.ddn.conf
Normal file
67
scripts/zpool-layout/dragon.ddn.conf
Normal file
@ -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
|
67
scripts/zpool-layout/dragon.llnl.conf
Normal file
67
scripts/zpool-layout/dragon.llnl.conf
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user