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 # Verify scrub behaves as intended when contending with a healing or
29 # sequential resilver.
33 # 2. Add a modest amount of data to the pool.
34 # 3. For healing and sequential resilver:
36 # b. Verify a resilver can be started and it cancels the scrub.
37 # c. Verify a scrub cannot be started when resilvering
42 log_must set_tunable32 RESILVER_MIN_TIME_MS $ORIG_RESILVER_MIN_TIME
43 log_must set_tunable32 SCAN_SUSPEND_PROGRESS \
44 $ORIG_SCAN_SUSPEND_PROGRESS
45 destroy_pool $TESTPOOL1
46 rm -f ${VDEV_FILES[@]} $SPARE_VDEV_FILE
49 log_assert "Scrub was cancelled by resilver"
51 ORIG_RESILVER_MIN_TIME=$(get_tunable RESILVER_MIN_TIME_MS)
52 ORIG_SCAN_SUSPEND_PROGRESS=$(get_tunable SCAN_SUSPEND_PROGRESS)
56 log_must truncate -s $VDEV_FILE_SIZE ${VDEV_FILES[@]} $SPARE_VDEV_FILE
58 log_must zpool create -f $TESTPOOL1 ${VDEV_FILES[@]}
59 log_must zfs create $TESTPOOL1/$TESTFS
61 mntpnt=$(get_prop mountpoint $TESTPOOL1/$TESTFS)
62 log_must dd if=/dev/urandom of=$mntpnt/file bs=1M count=64
63 log_must zpool sync $TESTPOOL1
65 # Request a healing or sequential resilver
66 for replace_mode in "healing" "sequential"; do
69 # Healing resilvers abort the dsl_scan and reconfigure it for
70 # resilvering. Sequential resilvers cancel the dsl_scan and start
71 # the vdev_rebuild thread.
73 if [[ "$replace_mode" = "healing" ]]; then
74 history_msg="scan aborted, restarting"
77 history_msg="scan cancelled"
81 # Limit scanning time and suspend the scan as soon as possible.
82 log_must set_tunable32 RESILVER_MIN_TIME_MS 50
83 log_must set_tunable32 SCAN_SUSPEND_PROGRESS 1
86 log_must zpool scrub $TESTPOOL1
88 # Initiate a resilver to cancel the scrub.
89 log_must zpool replace $flags $TESTPOOL1 ${VDEV_FILES[1]} \
92 # Verify the scrub was canceled, it may take a few seconds to exit.
93 while is_pool_scrubbing $TESTPOOL1; do
96 log_mustnot is_pool_scrubbing $TESTPOOL1
98 # Verify a scrub cannot be started while resilvering.
99 log_must is_pool_resilvering $TESTPOOL1
100 log_mustnot zpool scrub $TESTPOOL1
102 # Unsuspend resilver.
103 log_must set_tunable32 SCAN_SUSPEND_PROGRESS 0
104 log_must set_tunable32 RESILVER_MIN_TIME_MS 3000
106 # Wait for resilver to finish then put the original back.
107 log_must zpool wait $TESTPOOL1
108 log_must zpool replace $flags -w $TESTPOOL1 $SPARE_VDEV_FILE \
111 log_pass "Scrub was cancelled by resilver"