]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_001_pos.ksh
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
30 # Copyright (c) 2018 by Lawrence Livermore National Security, LLC.
33 .
$STF_SUITE/include
/libtest.shlib
34 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_expand
/zpool_expand.cfg
38 # Once zpool set autoexpand=on poolname, zpool can autoexpand by
39 # Dynamic VDEV Expansion
43 # 1) Create three vdevs (loopback, scsi_debug, and file)
44 # 2) Create pool by using the different devices and set autoexpand=on
45 # 3) Expand each device as appropriate
46 # 4) Check that the pool size was expanded
48 # NOTE: Three different device types are used in this test to verify
49 # expansion of non-partitioned block devices (loopback), partitioned
50 # block devices (scsi_debug), and non-disk file vdevs. ZFS volumes
51 # are not used in order to avoid a possible lock inversion when
52 # layering pools on zvols.
55 verify_runnable
"global"
59 poolexists
$TESTPOOL1 && destroy_pool
$TESTPOOL1
61 if losetup
-a |
grep -q $DEV1; then
65 rm -f $FILE_LO $FILE_RAW
73 log_assert
"zpool can be autoexpanded after set autoexpand=on on vdev expansion"
75 for type in " " mirror raidz raidz2
; do
76 log_note
"Setting up loopback, scsi_debug, and file vdevs"
77 log_must truncate
-s $org_size $FILE_LO
79 log_must losetup
$DEV1 $FILE_LO
81 load_scsi_debug
$org_size_mb 1 1 1 '512b'
83 DEV2
=$
(get_debug_device
)
85 log_must truncate
-s $org_size $FILE_RAW
88 # The -f is required since we're mixing disk and file vdevs.
89 log_must zpool create
-f -o autoexpand
=on
$TESTPOOL1 $type \
92 typeset autoexp
=$
(get_pool_prop autoexpand
$TESTPOOL1)
93 if [[ $autoexp != "on" ]]; then
94 log_fail
"zpool $TESTPOOL1 autoexpand should be on but is " \
98 typeset prev_size
=$
(get_pool_prop size
$TESTPOOL1)
99 typeset zfs_prev_size
=$
(get_prop avail
$TESTPOOL1)
101 # Expand each device as appropriate being careful to add an artificial
102 # delay to ensure we get a single history entry for each. This makes
103 # is easier to verify each expansion for the striped pool case, since
104 # they will not be merged in to a single larger expansion.
105 log_note
"Expanding loopback, scsi_debug, and file vdevs"
106 log_must truncate
-s $exp_size $FILE_LO
107 log_must losetup
-c $DEV1
110 echo "2" > /sys
/bus
/pseudo
/drivers
/scsi_debug
/virtual_gb
111 echo "1" > /sys
/class
/block
/$DEV2/device
/rescan
115 log_must truncate
-s $exp_size $FILE_RAW
116 log_must zpool online
-e $TESTPOOL1 $FILE_RAW
118 typeset expand_size
=$
(get_pool_prop size
$TESTPOOL1)
119 typeset zfs_expand_size
=$
(get_prop avail
$TESTPOOL1)
121 log_note
"$TESTPOOL1 $type has previous size: $prev_size and " \
122 "expanded size: $expand_size"
123 # compare available pool size from zfs
124 if [[ $zfs_expand_size -gt $zfs_prev_size ]]; then
125 # check for zpool history for the pool size expansion
126 if [[ $type == " " ]]; then
127 typeset expansion_size
=$
(($exp_size-$org_size))
128 typeset size_addition
=$
(zpool
history -il $TESTPOOL1 |\
129 grep "pool '$TESTPOOL1' size:" | \
130 grep "vdev online" | \
131 grep "(+${expansion_size}" |
wc -l)
133 if [[ $size_addition -ne 3 ]]; then
134 log_fail
"pool $TESTPOOL1 has not expanded, " \
135 "$size_addition/3 vdevs expanded"
137 elif [[ $type == "mirror" ]]; then
138 typeset expansion_size
=$
(($exp_size-$org_size))
139 zpool
history -il $TESTPOOL1 | \
140 grep "pool '$TESTPOOL1' size:" | \
141 grep "vdev online" | \
142 grep "(+${expansion_size})" >/dev
/null
2>&1
144 if [[ $?
-ne 0 ]] ; then
145 log_fail
"pool $TESTPOOL1 has not expanded"
148 typeset expansion_size
=$
((3*($exp_size-$org_size)))
149 zpool
history -il $TESTPOOL1 | \
150 grep "pool '$TESTPOOL1' size:" | \
151 grep "vdev online" | \
152 grep "(+${expansion_size})" >/dev
/null
2>&1
154 if [[ $?
-ne 0 ]]; then
155 log_fail
"pool $TESTPOOL has not expanded"
159 log_fail
"pool $TESTPOOL1 is not autoexpanded after vdev " \
160 "expansion. Previous size: $zfs_prev_size and expanded " \
161 "size: $zfs_expand_size"
167 log_pass
"zpool can autoexpand if autoexpand=on after vdev expansion"