]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_expand/zpool_expand_004_pos.ksh
Add support for autoexpand property
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zpool_expand / zpool_expand_004_pos.ksh
1 #! /bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
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.
8 #
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.
13 #
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]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 #
29 # Copyright (c) 2012, 2015 by Delphix. All rights reserved.
30 # Copyright (c) 2017 Lawrence Livermore National Security, LLC.
31 #
32
33 . $STF_SUITE/include/libtest.shlib
34 . $STF_SUITE/tests/functional/cli_root/zpool_expand/zpool_expand.cfg
35
36 #
37 # DESCRIPTION:
38 # After vdev expansion, all 4 labels have the same set of uberblocks.
39 #
40 #
41 # STRATEGY:
42 # 1) Create 3 files
43 # 2) Create a pool backed by the files
44 # 3) Expand the files' size with truncate
45 # 4) Use zpool online -e to expand the vdevs
46 # 5) Check that for all the devices, all 4 labels have the same uberblocks
47 #
48
49 verify_runnable "global"
50
51 function cleanup
52 {
53 poolexists $TESTPOOL1 && destroy_pool $TESTPOOL1
54
55 for i in 1 2 3; do
56 [ -e ${TEMPFILE}.$i ] && log_must rm ${TEMPFILE}.$i
57 done
58 }
59
60 log_onexit cleanup
61
62 log_assert "After vdev expansion, all 4 labels have the same set of uberblocks."
63
64 for type in " " mirror raidz raidz2; do
65 for i in 1 2 3; do
66 log_must truncate -s $org_size ${TEMPFILE}.$i
67 done
68
69 log_must zpool create $TESTPOOL1 $type $TEMPFILE.1 \
70 $TEMPFILE.2 $TEMPFILE.3
71
72 sync_pool $TESTPOOL1
73
74 for i in 1 2 3; do
75 log_must truncate -s $exp_size ${TEMPFILE}.$i
76 done
77
78 for i in 1 2 3; do
79 log_must zpool online -e $TESTPOOL1 ${TEMPFILE}.$i
80 done
81
82 sync_pool $TESTPOOL1
83
84
85 for i in 1 2 3; do
86 non_uniform=$(zdb -lu ${TEMPFILE}.$i | \
87 grep 'labels = ' | \
88 grep -c -v 'labels = 0 1 2 3')
89
90 log_note "non-uniform label count: $non_uniform"
91
92 if [[ $non_uniform -ne 0 ]]; then
93 log_fail "After vdev expansion, all labels contents are not identical"
94 fi
95 done
96
97 log_must zpool destroy $TESTPOOL1
98 done
99
100 log_pass "After vdev expansion, all 4 labels have the same set of uberblocks."