5 # This file and its contents are supplied under the terms of the
6 # Common Development and Distribution License ("CDDL"), version 1.0.
7 # You may only use this file in accordance with the terms of version
10 # A full copy of the text of the CDDL should have accompanied this
11 # source. A copy of the CDDL is also available via the Internet at
12 # http://www.illumos.org/license/CDDL.
18 # Copyright (c) 2018 by Delphix. All rights reserved.
21 . $STF_SUITE/include/libtest.shlib
22 . $STF_SUITE/tests/functional/removal/removal.kshlib
27 # ztest hit an issue where it ran zdb and zdb failed because
28 # it couldn't access some indirect mappings at the end of a
29 # vdev. The issue was that the vdev's ms_shift had changed after
30 # it was removed by the addition of another vdev. This test is
31 # a regression test for ensuring this case doesn't come up again.
35 TMPDIR=${TMPDIR:-$TEST_BASE_DIR}
40 log_must truncate -s $MINVDEVSIZE $DISK0
41 log_must truncate -s $(($MINVDEVSIZE * 3)) $DISK1
42 log_must truncate -s $MINVDEVSIZE $DISK2
46 default_cleanup_noexit
47 log_must rm -f $DISK0 $DISK1 $DISK2
51 # Setup the pool with one disk .
53 log_must default_setup_noexit "$DISK0"
59 log_must truncate -s $(($MINVDEVSIZE * 2)) $DISK0
60 log_must zpool reopen $TESTPOOL
61 log_must zpool online -e $TESTPOOL $DISK0
64 # Fill up the whole vdev.
66 dd if=/dev/urandom of=$TESTDIR/$TESTFILE0 bs=8M
69 # Add another vdev and remove the first vdev creating indirect
70 # mappings for nearly all the allocatable space from the first
71 # vdev. Wait for removal to finish.
73 log_must zpool add $TESTPOOL $DISK1
74 log_must zpool remove $TESTPOOL $DISK0
75 log_must wait_for_removal $TESTPOOL
78 # Add a new vdev that will trigger a change in the config.
79 # Run sync once to ensure that the config actually changed.
81 log_must zpool add $TESTPOOL $DISK2
85 # Ensure that zdb does not find any problems with this.
87 log_must zdb $TESTPOOL
89 log_pass "Removal of expanded vdev doesn't cause any problems."