]>
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/include
/math.shlib
22 # 'zpool split' should only work on mirrors. Every other VDEV layout is not
26 # Create pools with various VDEV layouts and verify only mirrors can be split
29 verify_runnable
"both"
33 destroy_pool
$TESTPOOL
34 destroy_pool
$TESTPOOL2
35 rm -f $FILEDEV_PREFIX*
39 # Given a vdev type generate a pool configuration which can be immediately
40 # used as "zpool create $poolname $config" or "zpool add $poolname $config".
41 # Supported vdev types are:
53 # "sc" - special class
55 function pool_config
# <vdev-type>
65 disks
[z3
]="z1 z2 z3 z4"
72 d|t
) # single disk or stripe
74 m|m3
) # 2-way or 3-way mirror
90 sc
) # mirrored special class
91 vdev
='special mirror';;
93 log_fail
"setup_pool: unsupported vdev type '$1'"
96 for tok
in ${disks[$1]}; do
97 filedev
="$FILEDEV_PREFIX-$tok"
98 # if $filedev exists we are requesting the same vdev type twice
99 # in a row (eg. pool of striped mirrors): add a random suffix.
100 while [[ -f $filedev ]]; do
101 filedev
="$filedev.$RANDOM"
103 truncate
-s $SPA_MINDEVSIZE "$filedev"
104 config
="$config $filedev"
109 log_assert
"'zpool split' should work only on mirror VDEVs"
112 # "good" and "bad" pool layouts
113 # first token is always used with "zpool create"
114 # second to last tokens, if any, are used with "zpool add"
115 typeset
-a goodconfs
=("m" "m l" "m s" "m c" "m m" "m3" "m3 m3" "m m3 l s c" "m m sc")
116 typeset
-a badconfs
=("d" "z1" "z2" "z3" "m d" "m3 d" "m z1" "m z2" "m z3")
117 typeset FILEDEV_PREFIX
="$TEST_BASE_DIR/filedev"
118 typeset altroot
="$TESTDIR/altroot-$TESTPOOL2"
120 # Create pools with various VDEV layouts and verify only mirrors can be split
121 for config
in "${goodconfs[@]}"
123 create_config
="${config%% *}"
124 add_config
="$(awk '{$1= "";print $0}' <<< $config)"
125 log_must zpool create
$TESTPOOL $
(pool_config
$create_config)
126 for vdev
in $add_config; do
127 log_must zpool add
$TESTPOOL -f $
(pool_config
$vdev)
129 log_must zpool
split -R $altroot $TESTPOOL $TESTPOOL2
130 log_must poolexists
$TESTPOOL2
131 log_must
test "$(get_pool_prop 'altroot' $TESTPOOL2)" == "$altroot"
135 # Every other pool layout should *not* be splittable
136 for config
in "${badconfs[@]}"
138 create_config
="${config%% *}"
139 add_config
="$(awk '{$1= "";print $0}' <<< $config)"
140 log_must zpool create
$TESTPOOL $
(pool_config
$create_config)
141 for vdev
in $add_config; do
142 log_must zpool add
$TESTPOOL -f $
(pool_config
$vdev)
144 log_mustnot zpool
split -R $altroot $TESTPOOL $TESTPOOL2
145 log_mustnot poolexists
$TESTPOOL2
149 log_pass
"'zpool split' works only on mirror VDEVs"