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.
34 . $STF_SUITE/include/libtest.shlib
35 . $STF_SUITE/tests/functional/cli_root/zpool_expand/zpool_expand.cfg
39 # Once set zpool autoexpand=off, zpool can *NOT* autoexpand by
40 # Dynamic VDEV Expansion
44 # 1) Create three vdevs (loopback, scsi_debug, and file)
45 # 2) Create pool by using the different devices and set autoexpand=off
46 # 3) Expand each device as appropriate
47 # 4) Check that the pool size is not expanded
49 # NOTE: Three different device types are used in this test to verify
50 # expansion of non-partitioned block devices (loopback), partitioned
51 # block devices (scsi_debug), and non-disk file vdevs. ZFS volumes
52 # are not used in order to avoid a possible lock inversion when
53 # layering pools on zvols.
56 verify_runnable "global"
60 poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
62 if losetup -a | grep -q $DEV1; then
66 rm -f $FILE_LO $FILE_RAW
74 log_assert "zpool can not expand if set autoexpand=off after vdev expansion"
76 for type in " " mirror raidz raidz2; do
77 log_note "Setting up loopback, scsi_debug, and file vdevs"
78 log_must truncate -s $org_size $FILE_LO
80 log_must losetup $DEV1 $FILE_LO
82 load_scsi_debug $org_size_mb 1 1 1 '512b'
84 DEV2=$(get_debug_device)
86 log_must truncate -s $org_size $FILE_RAW
89 # The -f is required since we're mixing disk and file vdevs.
90 log_must zpool create -f $TESTPOOL1 $type $DEV1 $DEV2 $DEV3
92 typeset autoexp=$(get_pool_prop autoexpand $TESTPOOL1)
93 if [[ $autoexp != "off" ]]; then
94 log_fail "zpool $TESTPOOL1 autoexpand should be off but is " \
98 typeset prev_size=$(get_pool_prop size $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
117 # This is far longer than we should need to wait, but let's be sure.
120 # check for zpool history for the pool size expansion
121 zpool history -il $TESTPOOL1 | grep "pool '$TESTPOOL1' size:" | \
122 grep "vdev online" >/dev/null 2>&1
124 if [[ $? -eq 0 ]]; then
125 log_fail "pool $TESTPOOL1 is not autoexpand after vdev " \
129 typeset expand_size=$(get_pool_prop size $TESTPOOL1)
131 if [[ "$prev_size" != "$expand_size" ]]; then
132 log_fail "pool $TESTPOOL1 size changed after vdev expansion"
138 log_pass "zpool can not autoexpand if autoexpand=off after vdev expansion"