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, 2018 by Delphix. All rights reserved.
30 # Copyright (c) 2017 Lawrence Livermore National Security, LLC.
33 .
$STF_SUITE/include
/libtest.shlib
34 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_expand
/zpool_expand.cfg
38 # After zpool online -e poolname zvol vdevs, zpool can autoexpand by
39 # Dynamic VDEV Expansion
44 # 2) Create a pool backed by the files
45 # 3) Expand the files' size with truncate
46 # 4) Use zpool reopen to check the expandsize
47 # 5) Use zpool online -e to online the vdevs
48 # 6) Check that the pool size was expanded
51 verify_runnable
"global"
55 poolexists
$TESTPOOL1 && destroy_pool
$TESTPOOL1
58 [ -e ${TEMPFILE}.
$i ] && log_must
rm ${TEMPFILE}.
$i
64 log_assert
"zpool can expand after zpool online -e zvol vdevs on vdev expansion"
66 for type in " " mirror raidz raidz2
; do
67 # Initialize the file devices and the pool
69 log_must truncate
-s $org_size ${TEMPFILE}.
$i
72 log_must zpool create
$TESTPOOL1 $type $TEMPFILE.1 \
73 $TEMPFILE.2 $TEMPFILE.3
75 typeset autoexp
=$
(get_pool_prop autoexpand
$TESTPOOL1)
77 if [[ $autoexp != "off" ]]; then
78 log_fail
"zpool $TESTPOOL1 autoexpand should be off but is " \
81 typeset prev_size
=$
(get_pool_prop size
$TESTPOOL1)
82 typeset zfs_prev_size
=$
(get_prop avail
$TESTPOOL1)
84 # Increase the size of the file devices
86 log_must truncate
-s $exp_size ${TEMPFILE}.
$i
89 # Reopen the pool and check that the `expandsize` property is set
90 log_must zpool reopen
$TESTPOOL1
91 typeset zpool_expandsize
=$
(get_pool_prop expandsize
$TESTPOOL1)
93 if [[ $type == "mirror" ]]; then
94 typeset expected_zpool_expandsize
=$
(($exp_size-$org_size))
96 typeset expected_zpool_expandsize
=$
((3*($exp_size-$org_size)))
99 if [[ "$zpool_expandsize" = "-" ]]; then
100 log_fail
"pool $TESTPOOL1 did not detect any " \
101 "expandsize after reopen"
104 if [[ $zpool_expandsize -ne $expected_zpool_expandsize ]]; then
105 log_fail
"pool $TESTPOOL1 did not detect correct " \
106 "expandsize after reopen: found $zpool_expandsize," \
107 "expected $expected_zpool_expandsize"
110 # Online the devices to add the new space to the pool. Add an
111 # artificial delay between online commands order to prevent them
112 # from being merged in to a single history entry. This makes
113 # is easier to verify each expansion for the striped pool case.
115 log_must zpool online
-e $TESTPOOL1 ${TEMPFILE}.
$i
119 typeset expand_size
=$
(get_pool_prop size
$TESTPOOL1)
120 typeset zfs_expand_size
=$
(get_prop avail
$TESTPOOL1)
121 log_note
"$TESTPOOL1 $type has previous size: $prev_size and " \
122 "expanded size: $expand_size"
124 # compare available pool size from zfs
125 if [[ $zfs_expand_size -gt $zfs_prev_size ]]; then
126 # check for zpool history for the pool size expansion
127 if [[ $type == " " ]]; then
128 typeset expansion_size
=$
(($exp_size-$org_size))
129 typeset size_addition
=$
(zpool
history -il $TESTPOOL1 \
130 |
grep "pool '$TESTPOOL1' size:" | \
131 grep "vdev online" | \
132 grep "(+${expansion_size}" |
wc -l)
134 if [[ $size_addition -ne $i ]]; then
135 log_fail
"pool $TESTPOOL1 has not expanded " \
136 "after zpool online -e, " \
137 "$size_addition/3 vdevs expanded"
139 elif [[ $type == "mirror" ]]; then
140 typeset expansion_size
=$
(($exp_size-$org_size))
141 zpool
history -il $TESTPOOL1 | \
142 grep "pool '$TESTPOOL1' size:" | \
143 grep "vdev online" | \
144 grep "(+${expansion_size})" >/dev
/null
2>&1
146 if [[ $?
-ne 0 ]]; then
147 log_fail
"pool $TESTPOOL1 has not expanded " \
148 "after zpool online -e"
151 typeset expansion_size
=$
((3*($exp_size-$org_size)))
152 zpool
history -il $TESTPOOL1 | \
153 grep "pool '$TESTPOOL1' size:" | \
154 grep "vdev online" | \
155 grep "(+${expansion_size})" >/dev
/null
2>&1
157 if [[ $?
-ne 0 ]] ; then
158 log_fail
"pool $TESTPOOL1 has not expanded " \
159 "after zpool online -e"
163 log_fail
"pool $TESTPOOL1 did not expand after vdev expansion " \
164 "and zpool online -e"
166 log_must zpool destroy
$TESTPOOL1
168 log_pass
"zpool can expand after zpool online -e"