mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-07-08 00:37:41 +03:00

The device_rebuild feature enables sequential reconstruction when resilvering. Mirror vdevs can be rebuilt in LBA order which may more quickly restore redundancy depending on the pools average block size, overall fragmentation and the performance characteristics of the devices. However, block checksums cannot be verified as part of the rebuild thus a scrub is automatically started after the sequential resilver completes. The new '-s' option has been added to the `zpool attach` and `zpool replace` command to request sequential reconstruction instead of healing reconstruction when resilvering. zpool attach -s <pool> <existing vdev> <new vdev> zpool replace -s <pool> <old vdev> <new vdev> The `zpool status` output has been updated to report the progress of sequential resilvering in the same way as healing resilvering. The one notable difference is that multiple sequential resilvers may be in progress as long as they're operating on different top-level vdevs. The `zpool wait -t resilver` command was extended to wait on sequential resilvers. From this perspective they are no different than healing resilvers. Sequential resilvers cannot be supported for RAIDZ, but are compatible with the dRAID feature being developed. As part of this change the resilver_restart_* tests were moved in to the functional/replacement directory. Additionally, the replacement tests were renamed and extended to verify both resilvering and rebuilding. Original-patch-by: Isaac Huang <he.huang@intel.com> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: John Poduska <jpoduska@datto.com> Co-authored-by: Mark Maybee <mmaybee@cray.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #10349
127 lines
3.6 KiB
Bash
Executable File
127 lines
3.6 KiB
Bash
Executable File
#!/bin/ksh -p
|
|
|
|
#
|
|
# 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
|
|
#
|
|
|
|
#
|
|
# Copyright (c) 2019, Datto Inc. All rights reserved.
|
|
# Copyright (c) 2020 by Lawrence Livermore National Security, LLC.
|
|
#
|
|
|
|
. $STF_SUITE/include/libtest.shlib
|
|
. $STF_SUITE/tests/functional/replacement/replacement.cfg
|
|
|
|
#
|
|
# DESCRIPTION:
|
|
# Sequential reconstruction (unlike healing reconstruction) operate on the
|
|
# top-level vdev. This means that a sequential resilver operation can be
|
|
# started/stopped on a different top-level vdev without impacting other
|
|
# sequential resilvers.
|
|
#
|
|
# STRATEGY:
|
|
# 1. Create a mirrored pool.
|
|
#
|
|
|
|
function cleanup
|
|
{
|
|
log_must set_tunable32 SCAN_SUSPEND_PROGRESS \
|
|
$ORIG_SCAN_SUSPEND_PROGRESS
|
|
destroy_pool $TESTPOOL1
|
|
rm -f ${VDEV_FILES[@]} $SPARE_VDEV_FILE $SPARE_VDEV_FILE2
|
|
}
|
|
|
|
function check_history
|
|
{
|
|
pool=$1
|
|
msg=$2
|
|
exp=$3
|
|
|
|
count=$(zpool history -i $pool | grep "rebuild" | grep -c "$msg")
|
|
if [[ "$count" -ne "$exp" ]]; then
|
|
log_fail "Expected $exp rebuild '$msg' messages, found $count"
|
|
else
|
|
log_note "Found $count/$exp rebuild '$msg' messages"
|
|
fi
|
|
}
|
|
|
|
log_assert "Rebuilds operate on the top-level vdevs"
|
|
|
|
ORIG_SCAN_SUSPEND_PROGRESS=$(get_tunable SCAN_SUSPEND_PROGRESS)
|
|
|
|
log_onexit cleanup
|
|
|
|
log_must truncate -s $VDEV_FILE_SIZE ${VDEV_FILES[@]} \
|
|
$SPARE_VDEV_FILE $SPARE_VDEV_FILE2
|
|
|
|
# Verify two sequential resilvers can run concurrently.
|
|
log_must zpool create -f $TESTPOOL1 \
|
|
mirror ${VDEV_FILES[0]} ${VDEV_FILES[1]} \
|
|
mirror ${VDEV_FILES[2]} ${VDEV_FILES[3]}
|
|
log_must zfs create $TESTPOOL1/$TESTFS
|
|
|
|
mntpnt=$(get_prop mountpoint $TESTPOOL1/$TESTFS)
|
|
log_must dd if=/dev/urandom of=$mntpnt/file bs=1M count=32
|
|
log_must zpool sync $TESTPOOL1
|
|
|
|
log_must set_tunable32 SCAN_SUSPEND_PROGRESS 1
|
|
|
|
log_must zpool replace -s $TESTPOOL1 ${VDEV_FILES[1]} $SPARE_VDEV_FILE
|
|
log_must zpool replace -s $TESTPOOL1 ${VDEV_FILES[3]} $SPARE_VDEV_FILE2
|
|
|
|
check_history $TESTPOOL1 "started" 2
|
|
check_history $TESTPOOL1 "reset" 0
|
|
check_history $TESTPOOL1 "complete" 0
|
|
check_history $TESTPOOL1 "canceled" 0
|
|
|
|
log_must set_tunable32 SCAN_SUSPEND_PROGRESS $ORIG_SCAN_SUSPEND_PROGRESS
|
|
log_must zpool wait -t resilver $TESTPOOL1
|
|
|
|
check_history $TESTPOOL1 "complete" 2
|
|
destroy_pool $TESTPOOL1
|
|
|
|
# Verify canceling one resilver (zpool detach) does not impact others.
|
|
log_must zpool create -f $TESTPOOL1 \
|
|
mirror ${VDEV_FILES[0]} ${VDEV_FILES[1]} \
|
|
mirror ${VDEV_FILES[2]} ${VDEV_FILES[3]}
|
|
log_must zfs create $TESTPOOL1/$TESTFS
|
|
|
|
mntpnt=$(get_prop mountpoint $TESTPOOL1/$TESTFS)
|
|
log_must dd if=/dev/urandom of=$mntpnt/file bs=1M count=32
|
|
log_must zpool sync $TESTPOOL1
|
|
|
|
log_must set_tunable32 SCAN_SUSPEND_PROGRESS 1
|
|
|
|
log_must zpool replace -s $TESTPOOL1 ${VDEV_FILES[1]} $SPARE_VDEV_FILE
|
|
log_must zpool replace -s $TESTPOOL1 ${VDEV_FILES[3]} $SPARE_VDEV_FILE2
|
|
|
|
check_history $TESTPOOL1 "started" 2
|
|
check_history $TESTPOOL1 "reset" 0
|
|
check_history $TESTPOOL1 "complete" 0
|
|
check_history $TESTPOOL1 "canceled" 0
|
|
|
|
log_must zpool detach $TESTPOOL1 $SPARE_VDEV_FILE2
|
|
|
|
check_history $TESTPOOL1 "complete" 0
|
|
check_history $TESTPOOL1 "canceled" 1
|
|
|
|
log_must set_tunable32 SCAN_SUSPEND_PROGRESS $ORIG_SCAN_SUSPEND_PROGRESS
|
|
log_must zpool wait -t resilver $TESTPOOL1
|
|
|
|
check_history $TESTPOOL1 "complete" 1
|
|
check_history $TESTPOOL1 "canceled" 1
|
|
destroy_pool $TESTPOOL1
|
|
|
|
log_pass "Rebuilds operate on the top-level vdevs"
|