Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions module/zfs/vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -5866,13 +5866,14 @@ vdev_defer_resilver(vdev_t *vd)

/*
* Clears the resilver deferred flag on all leaf devs under vd. Returns
* B_TRUE if we have devices that need to be resilvered and are available to
* accept resilver I/Os.
* B_TRUE if we cleared a deferred device that still needs to be resilvered
* and is available to accept resilver I/Os.
*/
boolean_t
vdev_clear_resilver_deferred(vdev_t *vd, dmu_tx_t *tx)
{
boolean_t resilver_needed = B_FALSE;
boolean_t was_deferred;
spa_t *spa = vd->vdev_spa;

for (int c = 0; c < vd->vdev_children; c++) {
Expand All @@ -5892,9 +5893,10 @@ vdev_clear_resilver_deferred(vdev_t *vd, dmu_tx_t *tx)
!vd->vdev_ops->vdev_op_leaf)
return (resilver_needed);

was_deferred = vd->vdev_resilver_deferred;
vd->vdev_resilver_deferred = B_FALSE;

return (!vdev_is_dead(vd) && !vd->vdev_offline &&
return (was_deferred && !vdev_is_dead(vd) && !vd->vdev_offline &&
vdev_resilver_needed(vd, NULL, NULL));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/runfiles/common.run
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ tests = ['attach_import', 'attach_multiple', 'attach_rebuild',
'rebuild_disabled_feature', 'rebuild_multiple', 'rebuild_raidz',
'replace_import', 'replace_rebuild', 'replace_resilver',
'replace_resilver_sit_out', 'resilver_restart_001',
'resilver_restart_002', 'scrub_cancel']
'resilver_restart_002', 'resilver_restart_003', 'scrub_cancel']
tags = ['functional', 'replacement']

[tests/functional/reservation]
Expand Down
1 change: 1 addition & 0 deletions tests/zfs-tests/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
functional/replacement/replace_resilver_sit_out.ksh \
functional/replacement/resilver_restart_001.ksh \
functional/replacement/resilver_restart_002.ksh \
functional/replacement/resilver_restart_003.ksh \
functional/replacement/scrub_cancel.ksh \
functional/replacement/setup.ksh \
functional/reservation/cleanup.ksh \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/ksh -p
# SPDX-License-Identifier: CDDL-1.0

#
# CDDL HEADER START
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# CDDL HEADER END
#

. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/replacement/replacement.cfg

#
# DESCRIPTION:
# Verify that a resilver does not restart after completing while a pool
# checkpoint is present.
#
# STRATEGY:
# 1. Create a single-disk pool and write data.
# 2. Start an attach resilver and suspend scan progress.
# 3. Create a checkpoint while the resilver is active.
# 4. Let the resilver finish.
# 5. Verify the checkpoint-retained DTL does not start another resilver.
#

verify_runnable "global"

function cleanup
{
log_must set_tunable32 SCAN_SUSPEND_PROGRESS \
$ORIG_SCAN_SUSPEND_PROGRESS
log_must set_tunable32 RESILVER_MIN_TIME_MS $ORIG_RESILVER_MIN_TIME
log_must zpool events
destroy_pool $TESTPOOL1
rm -f ${VDEV_FILES[0]} $SPARE_VDEV_FILE
}

function wait_for_event # pattern timeout
{
typeset pattern=$1
typeset timeout=${2:-60}
typeset -i events=0

for (( iter = 0; iter < timeout; iter++ )); do
events=$(zpool events | grep -cF "$pattern")
(( events > 0 )) && return 0
sleep 1
done

return 1
}

log_assert "Checkpointed DTLs do not restart a completed resilver"

ORIG_SCAN_SUSPEND_PROGRESS=$(get_tunable SCAN_SUSPEND_PROGRESS)
ORIG_RESILVER_MIN_TIME=$(get_tunable RESILVER_MIN_TIME_MS)

log_onexit cleanup

log_must truncate -s $VDEV_FILE_SIZE ${VDEV_FILES[0]} $SPARE_VDEV_FILE
log_must zpool create -f -O recordsize=128K $TESTPOOL1 ${VDEV_FILES[0]}
log_must eval "dd if=/dev/urandom of=/$TESTPOOL1/file bs=1M count=32" \
">/dev/null 2>&1"

log_must zpool events -c
log_must set_tunable32 RESILVER_MIN_TIME_MS 20
log_must set_tunable32 SCAN_SUSPEND_PROGRESS 1
log_must zpool attach $TESTPOOL1 ${VDEV_FILES[0]} $SPARE_VDEV_FILE

log_must wait_for_event "sysevent.fs.zfs.resilver_start" 60
log_must zpool checkpoint $TESTPOOL1

log_must set_tunable32 SCAN_SUSPEND_PROGRESS 0
log_must wait_for_event "sysevent.fs.zfs.resilver_finish" 120

# Wait a few txgs to ensure completion does not queue a deferred resilver.
sync_pool $TESTPOOL1 true
sync_pool $TESTPOOL1 true

resilver_starts=$(zpool events | grep -cF "sysevent.fs.zfs.resilver_start")
(( resilver_starts != 1 )) &&
log_fail "expected 1 resilver start, found $resilver_starts"

log_pass "Completed resilver was not restarted with checkpoint present"
Loading