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 # Ensure that cancelling a removal midway does not cause any
28 # issues like cause a panic.
32 # 1. Create a pool with one vdev and do some writes on it.
33 # 2. Add a new vdev to the pool and start the removal of
35 # 3. Cancel the removal after some segments have been copied
36 # over to the new vdev.
37 # 4. Run zdb to ensure the on-disk state of the pool is ok.
45 log_must set_tunable32 REMOVAL_SUSPEND_PROGRESS 0
49 SAMPLEFILE=/$TESTDIR/00
52 # Create pool with one disk.
54 log_must default_setup_noexit "$REMOVEDISK"
57 # Create a file of size 1GB and then do some random writes.
58 # Since randwritecomp does 8K writes we do 25000 writes
59 # which means we write ~200MB to the vdev.
61 log_must mkfile -n 1g $SAMPLEFILE
62 log_must randwritecomp $SAMPLEFILE 25000
65 # Add second device where all the data will be evacuated.
67 log_must zpool add -f $TESTPOOL $NOTREMOVEDISK
72 log_must set_tunable32 REMOVAL_SUSPEND_PROGRESS 1
77 log_must zpool remove $TESTPOOL $REMOVEDISK
80 # Only for debugging purposes in test logs.
82 log_must zpool status $TESTPOOL
87 log_must zpool remove -s $TESTPOOL
90 # Verify on-disk state.
92 log_must zdb $TESTPOOL
94 log_pass "Device removal thread cancelled successfully."