mirror_zfs/tests/zfs-tests/tests/functional/replacement/attach_multiple.ksh
Brian Behlendorf 9a49d3f3d3
Add device rebuild feature
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
2020-07-03 11:05:50 -07:00

112 lines
3.5 KiB
Bash
Executable File

#!/bin/ksh
#
# 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.
#
#
# 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:
# Verify that attach/detach work while resilvering and attaching
# multiple vdevs.
#
# Strategy:
# 1. Create a single vdev pool
# 2. While healing or sequential resilvering:
# a. Attach a vdev to convert the pool to a mirror.
# b. Attach a vdev to convert the pool to a 3-way mirror.
# c. Verify the original vdev cannot be removed (no redundant copies)
# d. Detach a vdev. Healing and sequential resilver remain running.
# e. Detach a vdev. Healing resilver remains running, sequential
# resilver is canceled.
# f. Wait for resilver to complete.
#
function cleanup
{
log_must set_tunable32 SCAN_SUSPEND_PROGRESS \
$ORIG_SCAN_SUSPEND_PROGRESS
destroy_pool $TESTPOOL1
rm -f ${VDEV_FILES[@]}
}
log_assert "Verify attach/detech with multiple vdevs"
ORIG_SCAN_SUSPEND_PROGRESS=$(get_tunable SCAN_SUSPEND_PROGRESS)
log_onexit cleanup
log_must truncate -s $VDEV_FILE_SIZE ${VDEV_FILES[@]}
# Verify resilver resumes on import.
log_must zpool create -f $TESTPOOL1 ${VDEV_FILES[0]}
for replace_mode in "healing" "sequential"; do
#
# Resilvers abort the dsl_scan and reconfigure it for resilvering.
# Rebuilds cancel the dsl_scan and start the vdev_rebuild thread.
#
if [[ "$replace_mode" = "healing" ]]; then
flags=""
else
flags="-s"
fi
log_mustnot is_pool_resilvering $TESTPOOL1
log_must set_tunable32 SCAN_SUSPEND_PROGRESS 1
# Attach first vdev (stripe -> mirror)
log_must zpool attach $flags $TESTPOOL1 \
${VDEV_FILES[0]} ${VDEV_FILES[1]}
log_must is_pool_resilvering $TESTPOOL1
# Attach second vdev (2-way -> 3-way mirror)
log_must zpool attach $flags $TESTPOOL1 \
${VDEV_FILES[1]} ${VDEV_FILES[2]}
log_must is_pool_resilvering $TESTPOOL1
# Original vdev cannot be detached until there is sufficent redundancy.
log_mustnot zpool detach $TESTPOOL1 ${VDEV_FILES[0]}
# Detach first vdev (resilver keeps running)
log_must zpool detach $TESTPOOL1 ${VDEV_FILES[1]}
log_must is_pool_resilvering $TESTPOOL1
#
# Detach second vdev. There's a difference in behavior between
# healing and sequential resilvers. A healing resilver will not be
# cancelled even though there's nothing on the original vdev which
# needs to be rebuilt. A sequential resilver on the otherhand is
# canceled when returning to a non-redundant striped layout. At
# some point the healing resilver behavior should be updated to match
# the sequential resilver behavior.
#
log_must zpool detach $TESTPOOL1 ${VDEV_FILES[2]}
if [[ "$replace_mode" = "healing" ]]; then
log_must is_pool_resilvering $TESTPOOL1
else
log_mustnot is_pool_resilvering $TESTPOOL1
fi
log_must set_tunable32 SCAN_SUSPEND_PROGRESS \
$ORIG_SCAN_SUSPEND_PROGRESS
log_must zpool wait $TESTPOOL1
done
log_pass "Verify attach/detech with multiple vdevs"