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) 2014, 2017 by Delphix. All rights reserved.
19 # Copyright (c) 2018 by Lawrence Livermore National Security, LLC.
22 . $STF_SUITE/include/libtest.shlib
23 . $STF_SUITE/tests/functional/removal/removal.kshlib
28 # This test ensures the device removal is cancelled when hard IO
29 # errors are encountered during the removal process. This is done
30 # to ensure that when removing a device all of the data is copied.
34 # 1. We create a pool with enough redundancy such that IO errors
35 # will not result in the pool being suspended.
36 # 2. We write some test data to the pool.
37 # 3. We inject READ errors in to one half of the top-level mirror-0
38 # vdev which is being removed. Then we start the removal process.
39 # 4. Verify that the injected read errors cause the removal of
40 # mirror-0 to be cancelled and that mirror-0 has not been removed.
41 # 5. Clear the read fault injection.
42 # 6. Repeat steps 3-6 above except inject WRITE errors on one of
43 # child vdevs in the destination mirror-1.
44 # 7. Lastly verify the pool data is still intact.
47 TMPDIR=${TMPDIR:-$TEST_BASE_DIR}
53 log_must truncate -s $MINVDEVSIZE $DISK0 $DISK1
54 log_must truncate -s $((MINVDEVSIZE * 4)) $DISK2 $DISK3
58 log_must zinject -c all
59 default_cleanup_noexit
60 log_must rm -f $DISK0 $DISK1 $DISK2 $DISK3
63 function wait_for_removing_cancel
67 log_must zpool wait -t remove $pool
70 # The pool state changes before the TXG finishes syncing; wait for
71 # the removal to be completed on disk.
75 log_mustnot is_pool_removed $pool
79 default_setup_noexit "mirror $DISK0 $DISK1 mirror $DISK2 $DISK3"
82 FILE_CONTENTS="Leeloo Dallas mul-ti-pass."
84 echo $FILE_CONTENTS >$TESTDIR/$TESTFILE0
85 log_must [ "x$(<$TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ]
86 log_must file_write -o create -f $TESTDIR/$TESTFILE1 -b $((2**20)) -c $((2**7))
89 # Verify that unexpected read errors automatically cancel the removal.
90 log_must zinject -d $DISK0 -e io -T all -f 100 $TESTPOOL
91 log_must zpool remove $TESTPOOL mirror-0
92 log_must wait_for_removing_cancel $TESTPOOL
93 log_must vdevs_in_pool $TESTPOOL mirror-0
94 log_must zinject -c all
96 # Verify that unexpected write errors automatically cancel the removal.
97 log_must zinject -d $DISK3 -e io -T all -f 100 $TESTPOOL
98 log_must zpool remove $TESTPOOL mirror-0
99 log_must wait_for_removing_cancel $TESTPOOL
100 log_must vdevs_in_pool $TESTPOOL mirror-0
101 log_must zinject -c all
103 log_must dd if=$TESTDIR/$TESTFILE0 of=/dev/null
104 log_must [ "x$(<$TESTDIR/$TESTFILE0)" = "x$FILE_CONTENTS" ]
105 log_must dd if=$TESTDIR/$TESTFILE1 of=/dev/null
107 log_pass "Device not removed due to unexpected errors."