6 # This file and its contents are supplied under the terms of the
7 # Common Development and Distribution License ("CDDL"), version 1.0.
8 # You may only use this file in accordance with the terms of version
11 # A full copy of the text of the CDDL should have accompanied this
12 # source. A copy of the CDDL is also available via the Internet at
13 # http://www.illumos.org/license/CDDL.
19 # Copyright (c) 2019, Datto Inc. All rights reserved.
20 # Copyright (c) 2020 by Lawrence Livermore National Security, LLC.
23 . $STF_SUITE/include/libtest.shlib
24 . $STF_SUITE/tests/functional/replacement/replacement.cfg
28 # Sequential reconstruction (unlike healing reconstruction) operate on the
29 # top-level vdev. This means that a sequential resilver operation can be
30 # started/stopped on a different top-level vdev without impacting other
31 # sequential resilvers.
34 # 1. Create a mirrored pool.
39 log_must set_tunable32 SCAN_SUSPEND_PROGRESS \
40 $ORIG_SCAN_SUSPEND_PROGRESS
41 destroy_pool $TESTPOOL1
42 rm -f ${VDEV_FILES[@]} $SPARE_VDEV_FILE $SPARE_VDEV_FILE2
45 function check_history
51 count=$(zpool history -i $pool | grep "rebuild" | grep -c "$msg")
52 if [[ "$count" -ne "$exp" ]]; then
53 log_fail "Expected $exp rebuild '$msg' messages, found $count"
55 log_note "Found $count/$exp rebuild '$msg' messages"
59 log_assert "Rebuilds operate on the top-level vdevs"
61 ORIG_SCAN_SUSPEND_PROGRESS=$(get_tunable SCAN_SUSPEND_PROGRESS)
65 log_must truncate -s $VDEV_FILE_SIZE ${VDEV_FILES[@]} \
66 $SPARE_VDEV_FILE $SPARE_VDEV_FILE2
68 # Verify two sequential resilvers can run concurrently.
69 log_must zpool create -f $TESTPOOL1 \
70 mirror ${VDEV_FILES[0]} ${VDEV_FILES[1]} \
71 mirror ${VDEV_FILES[2]} ${VDEV_FILES[3]}
72 log_must zfs create $TESTPOOL1/$TESTFS
74 mntpnt=$(get_prop mountpoint $TESTPOOL1/$TESTFS)
75 log_must dd if=/dev/urandom of=$mntpnt/file bs=1M count=32
76 log_must zpool sync $TESTPOOL1
78 log_must set_tunable32 SCAN_SUSPEND_PROGRESS 1
80 log_must zpool replace -s $TESTPOOL1 ${VDEV_FILES[1]} $SPARE_VDEV_FILE
81 log_must zpool replace -s $TESTPOOL1 ${VDEV_FILES[3]} $SPARE_VDEV_FILE2
83 check_history $TESTPOOL1 "started" 2
84 check_history $TESTPOOL1 "reset" 0
85 check_history $TESTPOOL1 "complete" 0
86 check_history $TESTPOOL1 "canceled" 0
88 log_must set_tunable32 SCAN_SUSPEND_PROGRESS $ORIG_SCAN_SUSPEND_PROGRESS
89 log_must zpool wait -t resilver $TESTPOOL1
91 check_history $TESTPOOL1 "complete" 2
92 destroy_pool $TESTPOOL1
94 # Verify canceling one resilver (zpool detach) does not impact others.
95 log_must zpool create -f $TESTPOOL1 \
96 mirror ${VDEV_FILES[0]} ${VDEV_FILES[1]} \
97 mirror ${VDEV_FILES[2]} ${VDEV_FILES[3]}
98 log_must zfs create $TESTPOOL1/$TESTFS
100 mntpnt=$(get_prop mountpoint $TESTPOOL1/$TESTFS)
101 log_must dd if=/dev/urandom of=$mntpnt/file bs=1M count=32
102 log_must zpool sync $TESTPOOL1
104 log_must set_tunable32 SCAN_SUSPEND_PROGRESS 1
106 log_must zpool replace -s $TESTPOOL1 ${VDEV_FILES[1]} $SPARE_VDEV_FILE
107 log_must zpool replace -s $TESTPOOL1 ${VDEV_FILES[3]} $SPARE_VDEV_FILE2
109 check_history $TESTPOOL1 "started" 2
110 check_history $TESTPOOL1 "reset" 0
111 check_history $TESTPOOL1 "complete" 0
112 check_history $TESTPOOL1 "canceled" 0
114 log_must zpool detach $TESTPOOL1 $SPARE_VDEV_FILE2
116 check_history $TESTPOOL1 "complete" 0
117 check_history $TESTPOOL1 "canceled" 1
119 log_must set_tunable32 SCAN_SUSPEND_PROGRESS $ORIG_SCAN_SUSPEND_PROGRESS
120 log_must zpool wait -t resilver $TESTPOOL1
122 check_history $TESTPOOL1 "complete" 1
123 check_history $TESTPOOL1 "canceled" 1
124 destroy_pool $TESTPOOL1
126 log_pass "Rebuilds operate on the top-level vdevs"