]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
14 # Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
17 .
$STF_SUITE/include
/libtest.shlib
18 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_split
/zpool_split.cfg
19 .
$STF_SUITE/include
/math.shlib
23 # 'zpool split' should only work on mirrors. Every other VDEV layout is not
27 # Create pools with various VDEV layouts and verify only mirrors can be split
30 verify_runnable
"both"
34 destroy_pool
$TESTPOOL
35 destroy_pool
$TESTPOOL2
36 rm -f $FILEDEV_PREFIX*
40 # Given a vdev type generate a pool configuration which can be immediately
41 # used as "zpool create $poolname $config" or "zpool add $poolname $config".
42 # Supported vdev types are:
54 # "sc" - special class
56 function pool_config
# <vdev-type>
66 disks
[z3
]="z1 z2 z3 z4"
73 d|t
) # single disk or stripe
75 m|m3
) # 2-way or 3-way mirror
91 sc
) # mirrored special class
92 vdev
='special mirror';;
94 log_fail
"setup_pool: unsupported vdev type '$1'"
97 for tok
in ${disks[$1]}; do
98 filedev
="$FILEDEV_PREFIX-$tok"
99 # if $filedev exists we are requesting the same vdev type twice
100 # in a row (eg. pool of striped mirrors): add a random suffix.
101 while [[ -f $filedev ]]; do
102 filedev
="$filedev.$RANDOM"
104 truncate
-s $SPA_MINDEVSIZE "$filedev"
105 config
="$config $filedev"
110 log_assert
"'zpool split' should work only on mirror VDEVs"
113 # "good" and "bad" pool layouts
114 # first token is always used with "zpool create"
115 # second to last tokens, if any, are used with "zpool add"
116 typeset
-a goodconfs
=("m" "m l" "m s" "m c" "m m" "m3" "m3 m3" "m m3 l s c" "m m sc")
117 typeset
-a badconfs
=("d" "z1" "z2" "z3" "m d" "m3 d" "m z1" "m z2" "m z3")
118 typeset FILEDEV_PREFIX
="$TEST_BASE_DIR/filedev"
119 typeset altroot
="$TESTDIR/altroot-$TESTPOOL2"
121 # Create pools with various VDEV layouts and verify only mirrors can be split
122 for config
in "${goodconfs[@]}"
124 create_config
="${config%% *}"
125 add_config
="$(awk '{$1= "";print $0}' <<< $config)"
126 log_must zpool create
$TESTPOOL $
(pool_config
$create_config)
127 for vdev
in $add_config; do
128 log_must zpool add
-f $TESTPOOL $
(pool_config
$vdev)
130 log_must zpool
split -R $altroot $TESTPOOL $TESTPOOL2
131 log_must poolexists
$TESTPOOL2
132 log_must
test "$(get_pool_prop 'altroot' $TESTPOOL2)" == "$altroot"
136 # Every other pool layout should *not* be splittable
137 for config
in "${badconfs[@]}"
139 create_config
="${config%% *}"
140 add_config
="$(awk '{$1= "";print $0}' <<< $config)"
141 log_must zpool create
$TESTPOOL $
(pool_config
$create_config)
142 for vdev
in $add_config; do
143 log_must zpool add
-f $TESTPOOL $
(pool_config
$vdev)
145 log_mustnot zpool
split -R $altroot $TESTPOOL $TESTPOOL2
146 log_mustnot poolexists
$TESTPOOL2
150 log_pass
"'zpool split' works only on mirror VDEVs"