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 (c) 2018 Datto Inc.
27 .
$STF_SUITE/include
/libtest.shlib
28 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_reopen
/zpool_reopen.shlib
29 .
$STF_SUITE/tests
/functional
/cli_root
/zpool_resilver
/zpool_resilver.cfg
33 # "Verify 'zpool resilver' restarts in-progress resilvers"
36 # 1. Write some data and detatch the first drive so it has resilver
38 # 2. Repeat the process with a second disk
39 # 3. Reattach the drives, causing the second drive's resilver to be
41 # 4. Manually restart the resilver with all drives
44 # Artificially limit the scrub speed by setting the zfs_scan_vdev_limit
45 # low and adding a 50ms zio delay in order to ensure that the resilver
46 # does not complete early.
49 verify_runnable
"global"
53 log_must zinject
-c all
54 log_must set_tunable64 zfs_scan_vdev_limit
$ZFS_SCAN_VDEV_LIMIT_DEFAULT
55 log_must
rm -f $mntpnt/biggerfile1
56 log_must
rm -f $mntpnt/biggerfile2
61 log_assert
"Verify 'zpool resilver' restarts in-progress resilvers"
63 mntpnt
=$
(get_prop mountpoint
$TESTPOOL/$TESTFS)
65 # 1. Write some data and detatch the first drive so it has resilver work to do
66 log_must file_write
-b 524288 -c 1024 -o create
-d 0 -f $mntpnt/biggerfile1
68 log_must zpool detach
$TESTPOOL $DISK2
70 # 2. Repeat the process with a second disk
71 log_must file_write
-b 524288 -c 1024 -o create
-d 0 -f $mntpnt/biggerfile2
73 log_must zpool detach
$TESTPOOL $DISK3
75 # 3. Reattach the drives, causing the second drive's resilver to be deferred
76 log_must set_tunable64 zfs_scan_vdev_limit
$ZFS_SCAN_VDEV_LIMIT_SLOW
78 log_must zpool attach
$TESTPOOL $DISK1 $DISK2
79 log_must zinject
-d $DISK2 -D50:1 $TESTPOOL
80 log_must is_pool_resilvering
$TESTPOOL true
82 log_must zpool attach
$TESTPOOL $DISK1 $DISK3
83 log_must zinject
-d $DISK3 -D50:1 $TESTPOOL
84 log_must is_pool_resilvering
$TESTPOOL true
86 # 4. Manually restart the resilver with all drives
87 log_must zpool resilver
$TESTPOOL
88 log_must zinject
-c all
89 log_must set_tunable64 zfs_scan_vdev_limit
$ZFS_SCAN_VDEV_LIMIT_DEFAULT
90 log_must wait_for_resilver_end
$TESTPOOL $MAXTIMEOUT
91 log_must is_deferred_scan_started
$TESTPOOL
92 log_must check_state
$TESTPOOL "$DISK2" "online"
93 log_must check_state
$TESTPOOL "$DISK3" "online"
95 log_pass
"Verified 'zpool resilver' restarts in-progress resilvers"