]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zpool_resilver/zpool_resilver_restart.ksh
de9e5ecdf49b528072f0fad6ce96e6f2e1856c41
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zpool_resilver / zpool_resilver_restart.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 (c) 2018 Datto Inc.
25 #
26
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
30
31 #
32 # DESCRIPTION:
33 # "Verify 'zpool resilver' restarts in-progress resilvers"
34 #
35 # STRATEGY:
36 # 1. Write some data and detatch the first drive so it has resilver
37 # work to do
38 # 2. Repeat the process with a second disk
39 # 3. Reattach the drives, causing the second drive's resilver to be
40 # deferred
41 # 4. Manually restart the resilver with all drives
42 #
43 # NOTES:
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.
47 #
48
49 verify_runnable "global"
50
51 function cleanup
52 {
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
57 }
58
59 log_onexit cleanup
60
61 log_assert "Verify 'zpool resilver' restarts in-progress resilvers"
62
63 mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
64
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
67 log_must sync
68 log_must zpool detach $TESTPOOL $DISK2
69
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
72 log_must sync
73 log_must zpool detach $TESTPOOL $DISK3
74
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
77
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
81
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
85
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"
94
95 log_pass "Verified 'zpool resilver' restarts in-progress resilvers"