mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
RAID-Z expansion feature
This feature allows disks to be added one at a time to a RAID-Z group, expanding its capacity incrementally. This feature is especially useful for small pools (typically with only one RAID-Z group), where there isn't sufficient hardware to add capacity by adding a whole new RAID-Z group (typically doubling the number of disks). == Initiating expansion == A new device (disk) can be attached to an existing RAIDZ vdev, by running `zpool attach POOL raidzP-N NEW_DEVICE`, e.g. `zpool attach tank raidz2-0 sda`. The new device will become part of the RAIDZ group. A "raidz expansion" will be initiated, and the new device will contribute additional space to the RAIDZ group once the expansion completes. The `feature@raidz_expansion` on-disk feature flag must be `enabled` to initiate an expansion, and it remains `active` for the life of the pool. In other words, pools with expanded RAIDZ vdevs can not be imported by older releases of the ZFS software. == During expansion == The expansion entails reading all allocated space from existing disks in the RAIDZ group, and rewriting it to the new disks in the RAIDZ group (including the newly added device). The expansion progress can be monitored with `zpool status`. Data redundancy is maintained during (and after) the expansion. If a disk fails while the expansion is in progress, the expansion pauses until the health of the RAIDZ vdev is restored (e.g. by replacing the failed disk and waiting for reconstruction to complete). The pool remains accessible during expansion. Following a reboot or export/import, the expansion resumes where it left off. == After expansion == When the expansion completes, the additional space is available for use, and is reflected in the `available` zfs property (as seen in `zfs list`, `df`, etc). Expansion does not change the number of failures that can be tolerated without data loss (e.g. a RAIDZ2 is still a RAIDZ2 even after expansion). A RAIDZ vdev can be expanded multiple times. After the expansion completes, old blocks remain with their old data-to-parity ratio (e.g. 5-wide RAIDZ2, has 3 data to 2 parity), but distributed among the larger set of disks. New blocks will be written with the new data-to-parity ratio (e.g. a 5-wide RAIDZ2 which has been expanded once to 6-wide, has 4 data to 2 parity). However, the RAIDZ vdev's "assumed parity ratio" does not change, so slightly less space than is expected may be reported for newly-written blocks, according to `zfs list`, `df`, `ls -s`, and similar tools. Sponsored-by: The FreeBSD Foundation Sponsored-by: iXsystems, Inc. Sponsored-by: vStack Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Mark Maybee <mark.maybee@delphix.com> Authored-by: Matthew Ahrens <mahrens@delphix.com> Contributions-by: Fedor Uporov <fuporov.vstack@gmail.com> Contributions-by: Stuart Maybee <stuart.maybee@comcast.net> Contributions-by: Thorsten Behrens <tbehrens@outlook.com> Contributions-by: Fmstrat <nospam@nowsci.com> Contributions-by: Don Brady <dev.fs.zfs@gmail.com> Signed-off-by: Don Brady <dev.fs.zfs@gmail.com> Closes #15022
This commit is contained in:
@@ -769,8 +769,12 @@ tests = ['redacted_compressed', 'redacted_contents', 'redacted_deleted',
|
||||
tags = ['functional', 'redacted_send']
|
||||
|
||||
[tests/functional/raidz]
|
||||
tests = ['raidz_001_neg', 'raidz_002_pos', 'raidz_003_pos', 'raidz_004_pos']
|
||||
tests = ['raidz_001_neg', 'raidz_002_pos', 'raidz_expand_001_pos',
|
||||
'raidz_expand_002_pos', 'raidz_expand_003_neg', 'raidz_expand_003_pos',
|
||||
'raidz_expand_004_pos', 'raidz_expand_005_pos', 'raidz_expand_006_neg',
|
||||
'raidz_expand_007_neg']
|
||||
tags = ['functional', 'raidz']
|
||||
timeout = 1200
|
||||
|
||||
[tests/functional/redundancy]
|
||||
tests = ['redundancy_draid', 'redundancy_draid1', 'redundancy_draid2',
|
||||
|
||||
@@ -34,6 +34,7 @@ DEADMAN_SYNCTIME_MS deadman.synctime_ms zfs_deadman_synctime_ms
|
||||
DEADMAN_ZIOTIME_MS deadman.ziotime_ms zfs_deadman_ziotime_ms
|
||||
DISABLE_IVSET_GUID_CHECK disable_ivset_guid_check zfs_disable_ivset_guid_check
|
||||
DMU_OFFSET_NEXT_SYNC dmu_offset_next_sync zfs_dmu_offset_next_sync
|
||||
EMBEDDED_SLOG_MIN_MS embedded_slog_min_ms zfs_embedded_slog_min_ms
|
||||
INITIALIZE_CHUNK_SIZE initialize_chunk_size zfs_initialize_chunk_size
|
||||
INITIALIZE_VALUE initialize_value zfs_initialize_value
|
||||
KEEP_LOG_SPACEMAPS_AT_EXPORT keep_log_spacemaps_at_export zfs_keep_log_spacemaps_at_export
|
||||
@@ -62,6 +63,7 @@ MULTIHOST_IMPORT_INTERVALS multihost.import_intervals zfs_multihost_import_inter
|
||||
MULTIHOST_INTERVAL multihost.interval zfs_multihost_interval
|
||||
OVERRIDE_ESTIMATE_RECORDSIZE send.override_estimate_recordsize zfs_override_estimate_recordsize
|
||||
PREFETCH_DISABLE prefetch.disable zfs_prefetch_disable
|
||||
RAIDZ_EXPAND_MAX_REFLOW_BYTES vdev.expand_max_reflow_bytes raidz_expand_max_reflow_bytes
|
||||
REBUILD_SCRUB_ENABLED rebuild_scrub_enabled zfs_rebuild_scrub_enabled
|
||||
REMOVAL_SUSPEND_PROGRESS removal_suspend_progress zfs_removal_suspend_progress
|
||||
REMOVE_MAX_SEGMENT remove_max_segment zfs_remove_max_segment
|
||||
@@ -69,6 +71,7 @@ RESILVER_MIN_TIME_MS resilver_min_time_ms zfs_resilver_min_time_ms
|
||||
SCAN_LEGACY scan_legacy zfs_scan_legacy
|
||||
SCAN_SUSPEND_PROGRESS scan_suspend_progress zfs_scan_suspend_progress
|
||||
SCAN_VDEV_LIMIT scan_vdev_limit zfs_scan_vdev_limit
|
||||
SCRUB_AFTER_EXPAND scrub_after_expand zfs_scrub_after_expand
|
||||
SEND_HOLES_WITHOUT_BIRTH_TIME send_holes_without_birth_time send_holes_without_birth_time
|
||||
SLOW_IO_EVENTS_PER_SECOND slow_io_events_per_second zfs_slow_io_events_per_second
|
||||
SPA_ASIZE_INFLATION spa.asize_inflation spa_asize_inflation
|
||||
|
||||
@@ -1668,8 +1668,14 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
|
||||
functional/raidz/cleanup.ksh \
|
||||
functional/raidz/raidz_001_neg.ksh \
|
||||
functional/raidz/raidz_002_pos.ksh \
|
||||
functional/raidz/raidz_003_pos.ksh \
|
||||
functional/raidz/raidz_004_pos.ksh \
|
||||
functional/raidz/raidz_expand_001_pos.ksh \
|
||||
functional/raidz/raidz_expand_002_pos.ksh \
|
||||
functional/raidz/raidz_expand_003_neg.ksh \
|
||||
functional/raidz/raidz_expand_003_pos.ksh \
|
||||
functional/raidz/raidz_expand_004_pos.ksh \
|
||||
functional/raidz/raidz_expand_005_pos.ksh \
|
||||
functional/raidz/raidz_expand_006_neg.ksh \
|
||||
functional/raidz/raidz_expand_007_neg.ksh \
|
||||
functional/raidz/setup.ksh \
|
||||
functional/redacted_send/cleanup.ksh \
|
||||
functional/redacted_send/redacted_compressed.ksh \
|
||||
|
||||
@@ -106,5 +106,6 @@ if is_linux || is_freebsd; then
|
||||
"feature@blake3"
|
||||
"feature@block_cloning"
|
||||
"feature@vdev_zaps_v2"
|
||||
"feature@raidz_expansion"
|
||||
)
|
||||
fi
|
||||
|
||||
@@ -23,19 +23,39 @@
|
||||
#
|
||||
# Copyright (c) 2016 by Gvozden Neskovic. All rights reserved.
|
||||
# Use is subject to license terms.
|
||||
# Copyright (c) 2020 by vStack. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Call the raidz_test tool with -S to test all supported raidz
|
||||
# implementations. This options will test several raidz block geometries
|
||||
# Call the raidz_test tool with sweep to test all supported raidz
|
||||
# implementations. This will test several raidz block geometries
|
||||
# and several zio parameters that affect raidz block layout. Data
|
||||
# reconstruction performs all combinations of failed disks. Wall time
|
||||
# is set to 5min, but actual runtime might be longer.
|
||||
# reconstruction performs all combinations of failed disks. Wall
|
||||
# time is set to 5 min, but actual runtime might be longer.
|
||||
#
|
||||
|
||||
log_must raidz_test -S -t 300
|
||||
|
||||
log_pass "raidz_test parameter sweep test succeeded."
|
||||
case $((RANDOM % 3)) in
|
||||
0)
|
||||
# Basic sweep test
|
||||
log_must raidz_test -S -t 300
|
||||
log_pass "raidz_test parameter sweep test succeeded."
|
||||
;;
|
||||
1)
|
||||
# Using expanded raidz map to test all supported raidz
|
||||
# implementations with expanded map and default reflow offset.
|
||||
log_must raidz_test -S -e -t 300
|
||||
log_pass "raidz_test sweep test with expanded map succeeded."
|
||||
;;
|
||||
2)
|
||||
# Using expanded raidz map ('-e') to test all supported raidz
|
||||
# implementations with expanded map and zero reflow offset.
|
||||
log_must raidz_test -S -e -r 0 -t 300
|
||||
log_pass "raidz_test sweep test with expanded map succeeded."
|
||||
;;
|
||||
*)
|
||||
# avoid shellcheck SC2249
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or https://opensource.org/licenses/CDDL-1.0.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2020 by vStack. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Call the raidz_test tool with -S and -e to test all supported raidz
|
||||
# implementations with expanded map and default reflow offset.
|
||||
# This options will test several raidz block geometries and several zio
|
||||
# parameters that affect raidz block layout. Data reconstruction performs
|
||||
# all combinations of failed disks. Wall time is set to 5min, but actual
|
||||
# runtime might be longer.
|
||||
#
|
||||
|
||||
log_must raidz_test -S -e -t 60
|
||||
|
||||
log_pass "raidz_test parameter sweep test with expanded map succeeded."
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or https://opensource.org/licenses/CDDL-1.0.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2020 by vStack. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Call the raidz_test tool with -S and -e to test all supported raidz
|
||||
# implementations with expanded map and zero reflow offset.
|
||||
# This options will test several raidz block geometries and several zio
|
||||
# parameters that affect raidz block layout. Data reconstruction performs
|
||||
# all combinations of failed disks. Wall time is set to 5min, but actual
|
||||
# runtime might be longer.
|
||||
#
|
||||
|
||||
log_must raidz_test -S -e -r 0 -t 60
|
||||
|
||||
log_pass "raidz_test parameter sweep test with expanded map succeeded."
|
||||
@@ -0,0 +1,215 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or http://www.opensolaris.org/os/licensing.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2020 by vStack. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# 'zpool attach poolname raidz ...' should attach new device to the pool.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create block device files for the test raidz pool
|
||||
# 2. For each parity value [1..3]
|
||||
# - create raidz pool
|
||||
# - fill it with some directories/files
|
||||
# - attach device to the raidz pool
|
||||
# - verify that device attached and the raidz pool size increase
|
||||
# - verify resilver by replacing parity devices
|
||||
# - verify resilver by replacing data devices
|
||||
# - verify scrub by zeroing parity devices
|
||||
# - verify scrub by zeroing data devices
|
||||
# - verify the raidz pool
|
||||
# - destroy the raidz pool
|
||||
|
||||
typeset -r devs=6
|
||||
typeset -r dev_size_mb=128
|
||||
|
||||
typeset -a disks
|
||||
|
||||
prefetch_disable=$(get_tunable PREFETCH_DISABLE)
|
||||
|
||||
function cleanup
|
||||
{
|
||||
log_pos zpool status $TESTPOOL
|
||||
|
||||
poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL"
|
||||
|
||||
for i in {0..$devs}; do
|
||||
log_must rm -f "$TEST_BASE_DIR/dev-$i"
|
||||
done
|
||||
|
||||
log_must set_tunable32 PREFETCH_DISABLE $prefetch_disable
|
||||
log_must set_tunable64 RAIDZ_EXPAND_MAX_REFLOW_BYTES 0
|
||||
}
|
||||
|
||||
function wait_expand_paused
|
||||
{
|
||||
oldcopied='0'
|
||||
newcopied='1'
|
||||
while [[ $oldcopied != $newcopied ]]; do
|
||||
oldcopied=$newcopied
|
||||
sleep 2
|
||||
newcopied=$(zpool status $TESTPOOL | \
|
||||
grep 'copied out of' | \
|
||||
awk '{print $1}')
|
||||
log_note "newcopied=$newcopied"
|
||||
done
|
||||
log_note "paused at $newcopied"
|
||||
}
|
||||
|
||||
function test_resilver # <pool> <parity> <dir>
|
||||
{
|
||||
typeset pool=$1
|
||||
typeset nparity=$2
|
||||
typeset dir=$3
|
||||
|
||||
for (( i=0; i<$nparity; i=i+1 )); do
|
||||
log_must zpool offline $pool $dir/dev-$i
|
||||
done
|
||||
|
||||
log_must zpool export $pool
|
||||
|
||||
for (( i=0; i<$nparity; i=i+1 )); do
|
||||
log_must zpool labelclear -f $dir/dev-$i
|
||||
done
|
||||
|
||||
log_must zpool import -o cachefile=none -d $dir $pool
|
||||
|
||||
for (( i=0; i<$nparity; i=i+1 )); do
|
||||
log_must zpool replace -f $pool $dir/dev-$i
|
||||
done
|
||||
|
||||
log_must zpool wait -t resilver $pool
|
||||
|
||||
log_must check_pool_status $pool "errors" "No known data errors"
|
||||
|
||||
log_must zpool clear $pool
|
||||
|
||||
for (( i=$nparity; i<$nparity*2; i=i+1 )); do
|
||||
log_must zpool offline $pool $dir/dev-$i
|
||||
done
|
||||
|
||||
log_must zpool export $pool
|
||||
|
||||
for (( i=$nparity; i<$nparity*2; i=i+1 )); do
|
||||
log_must zpool labelclear -f $dir/dev-$i
|
||||
done
|
||||
|
||||
log_must zpool import -o cachefile=none -d $dir $pool
|
||||
|
||||
for (( i=$nparity; i<$nparity*2; i=i+1 )); do
|
||||
log_must zpool replace -f $pool $dir/dev-$i
|
||||
done
|
||||
|
||||
log_must zpool wait -t resilver $pool
|
||||
|
||||
log_must check_pool_status $pool "errors" "No known data errors"
|
||||
|
||||
log_must zpool clear $pool
|
||||
}
|
||||
|
||||
function test_scrub # <pool> <parity> <dir>
|
||||
{
|
||||
typeset pool=$1
|
||||
typeset nparity=$2
|
||||
typeset dir=$3
|
||||
typeset combrec=$4
|
||||
|
||||
reflow_size=$(get_pool_prop allocated $pool)
|
||||
randbyte=$(( ((RANDOM<<15) + RANDOM) % $reflow_size ))
|
||||
log_must set_tunable64 RAIDZ_EXPAND_MAX_REFLOW_BYTES $randbyte
|
||||
log_must zpool attach $TESTPOOL ${raid}-0 $dir/dev-$devs
|
||||
wait_expand_paused
|
||||
|
||||
log_must zpool export $pool
|
||||
|
||||
# zero out parity disks
|
||||
for (( i=0; i<$nparity; i=i+1 )); do
|
||||
dd conv=notrunc if=/dev/zero of=$dir/dev-$i \
|
||||
bs=1M seek=4 count=$(($dev_size_mb-4))
|
||||
done
|
||||
|
||||
log_must zpool import -o cachefile=none -d $dir $pool
|
||||
|
||||
log_must zpool scrub -w $pool
|
||||
log_must zpool clear $pool
|
||||
log_must zpool export $pool
|
||||
|
||||
# zero out parity count worth of data disks
|
||||
for (( i=$nparity; i<$nparity*2; i=i+1 )); do
|
||||
dd conv=notrunc if=/dev/zero of=$dir/dev-$i \
|
||||
bs=1M seek=4 count=$(($dev_size_mb-4))
|
||||
done
|
||||
|
||||
log_must zpool import -o cachefile=none -d $dir $pool
|
||||
|
||||
log_must zpool scrub -w $pool
|
||||
|
||||
log_must check_pool_status $pool "errors" "No known data errors"
|
||||
|
||||
log_must zpool clear $pool
|
||||
log_must set_tunable64 RAIDZ_EXPAND_MAX_REFLOW_BYTES 0
|
||||
log_must zpool wait -t raidz_expand $TESTPOOL
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
log_must set_tunable32 PREFETCH_DISABLE 1
|
||||
|
||||
# Disk files which will be used by pool
|
||||
for i in {0..$(($devs - 1))}; do
|
||||
device=$TEST_BASE_DIR/dev-$i
|
||||
log_must truncate -s ${dev_size_mb}M $device
|
||||
disks[${#disks[*]}+1]=$device
|
||||
done
|
||||
|
||||
# Disk file which will be attached
|
||||
log_must truncate -s 512M $TEST_BASE_DIR/dev-$devs
|
||||
|
||||
nparity=$((RANDOM%(3) + 1))
|
||||
raid=raidz$nparity
|
||||
dir=$TEST_BASE_DIR
|
||||
|
||||
log_must zpool create -f -o cachefile=none $TESTPOOL $raid ${disks[@]}
|
||||
log_must zfs set primarycache=metadata $TESTPOOL
|
||||
|
||||
log_must zfs create $TESTPOOL/fs
|
||||
log_must fill_fs /$TESTPOOL/fs 1 512 100 1024 R
|
||||
|
||||
log_must zfs create -o compress=on $TESTPOOL/fs2
|
||||
log_must fill_fs /$TESTPOOL/fs2 1 512 100 1024 R
|
||||
|
||||
log_must zfs create -o compress=on -o recordsize=8k $TESTPOOL/fs3
|
||||
log_must fill_fs /$TESTPOOL/fs3 1 512 100 1024 R
|
||||
|
||||
log_must check_pool_status $TESTPOOL "errors" "No known data errors"
|
||||
|
||||
test_scrub $TESTPOOL $nparity $dir
|
||||
test_resilver $TESTPOOL $nparity $dir
|
||||
|
||||
zpool destroy "$TESTPOOL"
|
||||
|
||||
log_pass "raidz expansion test succeeded."
|
||||
@@ -0,0 +1,115 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or http://www.opensolaris.org/os/licensing.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2020 by vStack. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# 'zpool attach poolname raidz ...' should attach new devive to the pool.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create block device files for the test raidz pool
|
||||
# 2. For each parity value [1..3]
|
||||
# - create raidz pool with minimum block device files required
|
||||
# - for each free test block device
|
||||
# - attach to the pool
|
||||
# - verify the raidz pool
|
||||
# - destroy the raidz pool
|
||||
|
||||
typeset -r devs=6
|
||||
typeset -r dev_size_mb=512
|
||||
|
||||
typeset -a disks
|
||||
|
||||
prefetch_disable=$(get_tunable PREFETCH_DISABLE)
|
||||
|
||||
function cleanup
|
||||
{
|
||||
poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL"
|
||||
|
||||
for i in {0..$devs}; do
|
||||
log_must rm -f "$TEST_BASE_DIR/dev-$i"
|
||||
done
|
||||
|
||||
log_must set_tunable32 PREFETCH_DISABLE $prefetch_disable
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
log_must set_tunable32 PREFETCH_DISABLE 1
|
||||
|
||||
# Disk files which will be used by pool
|
||||
for i in {0..$(($devs))}; do
|
||||
device=$TEST_BASE_DIR/dev-$i
|
||||
log_must truncate -s ${dev_size_mb}M $device
|
||||
disks[${#disks[*]}+1]=$device
|
||||
done
|
||||
|
||||
nparity=$((RANDOM%(3) + 1))
|
||||
raid=raidz$nparity
|
||||
dir=$TEST_BASE_DIR
|
||||
pool=$TESTPOOL
|
||||
opts="-o cachefile=none"
|
||||
|
||||
log_must zpool create -f $opts $pool $raid ${disks[1..$(($nparity+1))]}
|
||||
log_must zfs set primarycache=metadata $pool
|
||||
|
||||
log_must zfs create $pool/fs
|
||||
log_must fill_fs /$pool/fs 1 512 100 1024 R
|
||||
|
||||
log_must zfs create -o compress=on $pool/fs2
|
||||
log_must fill_fs /$pool/fs2 1 512 100 1024 R
|
||||
|
||||
log_must zfs create -o compress=on -o recordsize=8k $pool/fs3
|
||||
log_must fill_fs /$pool/fs3 1 512 100 1024 R
|
||||
|
||||
typeset pool_size=$(get_pool_prop size $pool)
|
||||
|
||||
for disk in ${disks[$(($nparity+2))..$devs]}; do
|
||||
log_must dd if=/dev/urandom of=/${pool}/FILE-$RANDOM bs=1M \
|
||||
count=64
|
||||
|
||||
log_must zpool attach -w $pool ${raid}-0 $disk
|
||||
|
||||
# Wait some time for pool size increase
|
||||
sleep 5
|
||||
|
||||
# Confirm that disk was attached to the pool
|
||||
log_must zpool get -H path $TESTPOOL $disk
|
||||
|
||||
typeset expand_size=$(get_pool_prop size $pool)
|
||||
if [[ "$expand_size" -le "$pool_size" ]]; then
|
||||
log_fail "pool $pool not expanded"
|
||||
fi
|
||||
|
||||
verify_pool $pool
|
||||
|
||||
pool_size=$expand_size
|
||||
done
|
||||
|
||||
zpool destroy "$pool"
|
||||
|
||||
log_pass "raidz expansion test succeeded."
|
||||
@@ -0,0 +1,102 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or http://www.opensolaris.org/os/licensing.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2021 by vStack. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# 'zpool attach poolname raidz ...' should reject device attach if pool
|
||||
# is in checkpointed state. If checkpoint creation requested on
|
||||
# expanding pool, the request should be rejected.
|
||||
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create block device files for the test raidz pool.
|
||||
# 2. Create pool and checkpoint it.
|
||||
# 3. Try to expand raidz, ensure that request rejected.
|
||||
# 4. Recreate the pool.
|
||||
# 5. Apply raidz expansion.
|
||||
# 6. Ensure, that checkpoint cannot be created.
|
||||
|
||||
typeset -r devs=6
|
||||
typeset -r dev_size_mb=512
|
||||
|
||||
typeset -a disks
|
||||
|
||||
prefetch_disable=$(get_tunable PREFETCH_DISABLE)
|
||||
|
||||
function cleanup
|
||||
{
|
||||
poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL"
|
||||
|
||||
for i in {0..$devs}; do
|
||||
log_must rm -f "$TEST_BASE_DIR/dev-$i"
|
||||
done
|
||||
|
||||
log_must set_tunable32 PREFETCH_DISABLE $prefetch_disable
|
||||
log_must set_tunable64 RAIDZ_EXPAND_MAX_REFLOW_BYTES 0
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
log_must set_tunable32 PREFETCH_DISABLE 1
|
||||
|
||||
# Disk files which will be used by pool
|
||||
for i in {0..$(($devs))}; do
|
||||
device=$TEST_BASE_DIR/dev-$i
|
||||
log_must truncate -s ${dev_size_mb}M $device
|
||||
disks[${#disks[*]}+1]=$device
|
||||
done
|
||||
|
||||
nparity=1
|
||||
raid=raidz$nparity
|
||||
pool=$TESTPOOL
|
||||
opts="-o cachefile=none"
|
||||
|
||||
# case 1: checkpoint exist, try to expand
|
||||
log_must zpool create -f $opts $pool $raid ${disks[1..$(($devs-1))]}
|
||||
log_must zfs set primarycache=metadata $pool
|
||||
log_must zpool checkpoint $pool
|
||||
log_mustnot zpool attach $pool ${raid}-0 ${disks[$devs]}
|
||||
log_must zpool destroy $pool
|
||||
|
||||
#
|
||||
# case 2: expansion in progress, try to checkpoint
|
||||
#
|
||||
# Sets pause point at 25% of allocated space so that we know an
|
||||
# expansion is still in progress when we attempt the checkpoint
|
||||
#
|
||||
log_must zpool create -f $opts $pool $raid ${disks[1..$(($devs-1))]}
|
||||
log_must zfs set primarycache=metadata $pool
|
||||
log_must zfs create $pool/fs
|
||||
log_must fill_fs /$pool/fs 1 512 100 1024 R
|
||||
allocated=$(zpool list -Hp -o allocated $pool)
|
||||
log_must set_tunable64 RAIDZ_EXPAND_MAX_REFLOW_BYTES $((allocated / 4))
|
||||
log_must zpool attach $pool ${raid}-0 ${disks[$devs]}
|
||||
log_mustnot zpool checkpoint $pool
|
||||
log_must zpool destroy $pool
|
||||
|
||||
log_pass "raidz expansion test succeeded."
|
||||
@@ -0,0 +1,141 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or http://www.opensolaris.org/os/licensing.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2021 by vStack. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
. $STF_SUITE/tests/functional/cli_root/zfs_wait/zfs_wait.kshlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Check raidz expansion is able to work correctly under i/o load.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create block device files for the test raidz pool
|
||||
# 2. For each parity value [1..3]
|
||||
# - create raidz pool with minimum block device files required
|
||||
# - create couple of datasets with different recordsize and fill it
|
||||
# - set a max reflow value near pool capacity
|
||||
# - wait for reflow to reach this max
|
||||
# - verify pool
|
||||
# - set reflow bytes to max value to complete the expansion
|
||||
|
||||
typeset -r devs=10
|
||||
typeset -r dev_size_mb=256
|
||||
|
||||
typeset -a disks
|
||||
|
||||
embedded_slog_min_ms=$(get_tunable EMBEDDED_SLOG_MIN_MS)
|
||||
|
||||
function cleanup
|
||||
{
|
||||
poolexists "$TESTPOOL" && zpool status -v "$TESTPOOL"
|
||||
poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL"
|
||||
|
||||
for i in {0..$devs}; do
|
||||
log_must rm -f "$TEST_BASE_DIR/dev-$i"
|
||||
done
|
||||
|
||||
log_must set_tunable32 EMBEDDED_SLOG_MIN_MS $embedded_slog_min_ms
|
||||
log_must set_tunable64 RAIDZ_EXPAND_MAX_REFLOW_BYTES 0
|
||||
}
|
||||
|
||||
function wait_expand_paused
|
||||
{
|
||||
oldcopied='0'
|
||||
newcopied='1'
|
||||
# wait until reflow copied value stops changing
|
||||
while [[ $oldcopied != $newcopied ]]; do
|
||||
oldcopied=$newcopied
|
||||
sleep 1
|
||||
newcopied=$(zpool status $TESTPOOL | \
|
||||
grep 'copied out of' | \
|
||||
awk '{print $1}')
|
||||
done
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
log_must set_tunable32 EMBEDDED_SLOG_MIN_MS 99999
|
||||
|
||||
# Disk files which will be used by pool
|
||||
for i in {0..$(($devs))}; do
|
||||
device=$TEST_BASE_DIR/dev-$i
|
||||
log_must truncate -s ${dev_size_mb}M $device
|
||||
disks[${#disks[*]}+1]=$device
|
||||
done
|
||||
|
||||
nparity=$((RANDOM%(3) + 1))
|
||||
raid=raidz$nparity
|
||||
pool=$TESTPOOL
|
||||
opts="-o cachefile=none"
|
||||
|
||||
log_must zpool create -f $opts $pool $raid ${disks[1..$(($nparity+1))]}
|
||||
|
||||
log_must zfs create -o recordsize=8k $pool/fs
|
||||
log_must fill_fs /$pool/fs 1 256 100 1024 R
|
||||
|
||||
log_must zfs create -o recordsize=128k $pool/fs2
|
||||
log_must fill_fs /$pool/fs2 1 256 100 1024 R
|
||||
|
||||
for disk in ${disks[$(($nparity+2))..$devs]}; do
|
||||
log_must mkfile -n 400m /$pool/fs/file
|
||||
log_bkgrnd randwritecomp /$pool/fs/file 250
|
||||
pid0=$!
|
||||
|
||||
# start some random writes in the background during expansion
|
||||
log_must mkfile -n 400m /$pool/fs2/file2
|
||||
log_bkgrnd randwritecomp /$pool/fs2/file2 250
|
||||
pid1=$!
|
||||
sleep 10
|
||||
|
||||
# Pause at half total bytes to be copied for expansion
|
||||
reflow_size=$(get_pool_prop allocated $pool)
|
||||
log_note need to reflow $reflow_size bytes
|
||||
pause=$((reflow_size/2))
|
||||
log_must set_tunable64 RAIDZ_EXPAND_MAX_REFLOW_BYTES $pause
|
||||
|
||||
log_must zpool attach $pool ${raid}-0 $disk
|
||||
wait_expand_paused
|
||||
|
||||
kill_if_running $pid0
|
||||
kill_if_running $pid1
|
||||
|
||||
log_must zpool scrub -w $pool
|
||||
|
||||
log_must check_pool_status $pool "errors" "No known data errors"
|
||||
log_must check_pool_status $pool "scan" "with 0 errors"
|
||||
log_must check_pool_status $pool "scan" "repaired 0B"
|
||||
|
||||
# Set pause past largest possible value for this pool
|
||||
pause=$((devs*dev_size_mb*1024*1024))
|
||||
log_must set_tunable64 RAIDZ_EXPAND_MAX_REFLOW_BYTES $pause
|
||||
|
||||
log_must zpool wait -t raidz_expand $pool
|
||||
done
|
||||
|
||||
log_must zpool destroy "$pool"
|
||||
|
||||
log_pass "raidz expansion test succeeded."
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or http://www.opensolaris.org/os/licensing.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2021 by vStack. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Check device replacement during raidz expansion.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create block device files for the test raidz pool
|
||||
# 2. For each parity value [1..3]
|
||||
# - create raidz pool with minimum block device files required
|
||||
# - create couple of datasets with different recordsize and fill it
|
||||
# - attach new device to the pool
|
||||
# - offline and zero vdevs allowed by parity
|
||||
# - wait some time and start offlined vdevs replacement
|
||||
# - wait replacement completion and verify pool status
|
||||
|
||||
typeset -r devs=10
|
||||
typeset -r dev_size_mb=128
|
||||
|
||||
typeset -a disks
|
||||
|
||||
embedded_slog_min_ms=$(get_tunable EMBEDDED_SLOG_MIN_MS)
|
||||
original_scrub_after_expand=$(get_tunable SCRUB_AFTER_EXPAND)
|
||||
|
||||
function cleanup
|
||||
{
|
||||
poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL"
|
||||
|
||||
for i in {0..$devs}; do
|
||||
log_must rm -f "$TEST_BASE_DIR/dev-$i"
|
||||
done
|
||||
|
||||
log_must set_tunable32 EMBEDDED_SLOG_MIN_MS $embedded_slog_min_ms
|
||||
log_must set_tunable32 SCRUB_AFTER_EXPAND $original_scrub_after_expand
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
log_must set_tunable32 EMBEDDED_SLOG_MIN_MS 99999
|
||||
|
||||
# Disk files which will be used by pool
|
||||
for i in {0..$(($devs))}; do
|
||||
device=$TEST_BASE_DIR/dev-$i
|
||||
log_must truncate -s ${dev_size_mb}M $device
|
||||
disks[${#disks[*]}+1]=$device
|
||||
done
|
||||
|
||||
nparity=$((RANDOM%(3) + 1))
|
||||
raid=raidz$nparity
|
||||
pool=$TESTPOOL
|
||||
opts="-o cachefile=none"
|
||||
|
||||
log_must set_tunable32 SCRUB_AFTER_EXPAND 0
|
||||
|
||||
log_must zpool create -f $opts $pool $raid ${disks[1..$(($nparity+1))]}
|
||||
|
||||
log_must zfs create -o recordsize=8k $pool/fs
|
||||
log_must fill_fs /$pool/fs 1 128 100 1024 R
|
||||
|
||||
log_must zfs create -o recordsize=128k $pool/fs2
|
||||
log_must fill_fs /$pool/fs2 1 128 100 1024 R
|
||||
|
||||
for disk in ${disks[$(($nparity+2))..$devs]}; do
|
||||
log_must zpool attach $pool ${raid}-0 $disk
|
||||
|
||||
sleep 10
|
||||
|
||||
for (( i=1; i<=$nparity; i=i+1 )); do
|
||||
log_must zpool offline $pool ${disks[$i]}
|
||||
log_must dd if=/dev/zero of=${disks[$i]} \
|
||||
bs=1024k count=$dev_size_mb conv=notrunc
|
||||
done
|
||||
|
||||
sleep 3
|
||||
|
||||
for (( i=1; i<=$nparity; i=i+1 )); do
|
||||
log_must zpool replace $pool ${disks[$i]}
|
||||
done
|
||||
|
||||
log_must zpool wait -t replace $pool
|
||||
log_must check_pool_status $pool "scan" "with 0 errors"
|
||||
|
||||
log_must zpool wait -t raidz_expand $pool
|
||||
|
||||
log_must zpool clear $pool
|
||||
log_must zpool scrub -w $pool
|
||||
|
||||
log_must zpool status -v
|
||||
log_must check_pool_status $pool "scan" "with 0 errors"
|
||||
done
|
||||
|
||||
log_must zpool destroy "$pool"
|
||||
|
||||
log_pass "raidz expansion test succeeded."
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or http://www.opensolaris.org/os/licensing.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2021 by vStack. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Check device replacement during raidz expansion using expansion pausing.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create block device files for the test raidz pool
|
||||
# 2. For each parity value [1..3]
|
||||
# - create raidz pool with minimum block device files required
|
||||
# - create couple of datasets with different recordsize and fill it
|
||||
# - set raidz expand maximum reflow bytes
|
||||
# - attach new device to the pool
|
||||
# - wait for reflow bytes to reach the maximum
|
||||
# - offline and zero vdevs allowed by parity
|
||||
# - wait some time and start offlined vdevs replacement
|
||||
# - wait replacement completion and verify pool status
|
||||
# - loop thru vdevs replacing with the max reflow bytes increasing
|
||||
# - verify pool
|
||||
# - set reflow bytes to max value to complete the expansion
|
||||
|
||||
typeset -r devs=10
|
||||
typeset -r dev_size_mb=128
|
||||
|
||||
typeset -a disks
|
||||
|
||||
embedded_slog_min_ms=$(get_tunable EMBEDDED_SLOG_MIN_MS)
|
||||
original_scrub_after_expand=$(get_tunable SCRUB_AFTER_EXPAND)
|
||||
|
||||
function cleanup
|
||||
{
|
||||
poolexists "$TESTPOOL" && zpool status -v "$TESTPOOL"
|
||||
poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL"
|
||||
|
||||
for i in {0..$devs}; do
|
||||
log_must rm -f "$TEST_BASE_DIR/dev-$i"
|
||||
done
|
||||
|
||||
log_must set_tunable32 EMBEDDED_SLOG_MIN_MS $embedded_slog_min_ms
|
||||
log_must set_tunable64 RAIDZ_EXPAND_MAX_REFLOW_BYTES 0
|
||||
log_must set_tunable32 SCRUB_AFTER_EXPAND $original_scrub_after_expand
|
||||
}
|
||||
|
||||
function wait_expand_paused
|
||||
{
|
||||
oldcopied='0'
|
||||
newcopied='1'
|
||||
while [[ $oldcopied != $newcopied ]]; do
|
||||
oldcopied=$newcopied
|
||||
sleep 1
|
||||
newcopied=$(zpool status $TESTPOOL | \
|
||||
grep 'copied out of' | \
|
||||
awk '{print $1}')
|
||||
done
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
function test_replace # <pool> <devices> <parity>
|
||||
{
|
||||
pool=${1}
|
||||
devices=${2}
|
||||
nparity=${3}
|
||||
device_count=0
|
||||
|
||||
log_must echo "devices=$devices"
|
||||
|
||||
for dev in ${devices}; do
|
||||
device_count=$((device_count+1))
|
||||
done
|
||||
|
||||
index=$((RANDOM%(device_count-nparity)))
|
||||
for (( j=1; j<=$nparity; j=j+1 )); do
|
||||
log_must zpool offline $pool ${disks[$((index+j))]}
|
||||
log_must dd if=/dev/zero of=${disks[$((index+j))]} \
|
||||
bs=1024k count=$dev_size_mb conv=notrunc
|
||||
done
|
||||
|
||||
for (( j=1; j<=$nparity; j=j+1 )); do
|
||||
log_must zpool replace $pool ${disks[$((index+j))]}
|
||||
done
|
||||
|
||||
log_must zpool wait -t replace $pool
|
||||
log_must check_pool_status $pool "scan" "with 0 errors"
|
||||
|
||||
log_must zpool clear $pool
|
||||
log_must zpool scrub -w $pool
|
||||
|
||||
log_must zpool status -v
|
||||
log_must check_pool_status $pool "scan" "repaired 0B"
|
||||
}
|
||||
|
||||
log_must set_tunable32 EMBEDDED_SLOG_MIN_MS 99999
|
||||
|
||||
# Disk files which will be used by pool
|
||||
for i in {0..$(($devs))}; do
|
||||
device=$TEST_BASE_DIR/dev-$i
|
||||
log_must truncate -s ${dev_size_mb}M $device
|
||||
disks[${#disks[*]}+1]=$device
|
||||
done
|
||||
|
||||
nparity=$((RANDOM%(3) + 1))
|
||||
raid=raidz$nparity
|
||||
pool=$TESTPOOL
|
||||
opts="-o cachefile=none"
|
||||
devices=""
|
||||
|
||||
log_must set_tunable32 SCRUB_AFTER_EXPAND 0
|
||||
|
||||
log_must zpool create -f $opts $pool $raid ${disks[1..$(($nparity+1))]}
|
||||
devices="${disks[1..$(($nparity+1))]}"
|
||||
|
||||
log_must zfs create -o recordsize=8k $pool/fs
|
||||
log_must fill_fs /$pool/fs 1 128 100 1024 R
|
||||
|
||||
log_must zfs create -o recordsize=128k $pool/fs2
|
||||
log_must fill_fs /$pool/fs2 1 128 100 1024 R
|
||||
|
||||
for disk in ${disks[$(($nparity+2))..$devs]}; do
|
||||
# Set pause to some random value near halfway point
|
||||
reflow_size=$(get_pool_prop allocated $pool)
|
||||
pause=$((((RANDOM << 15) + RANDOM) % reflow_size / 2))
|
||||
log_must set_tunable64 RAIDZ_EXPAND_MAX_REFLOW_BYTES $pause
|
||||
|
||||
log_must zpool attach $pool ${raid}-0 $disk
|
||||
devices="$devices $disk"
|
||||
|
||||
wait_expand_paused
|
||||
|
||||
for (( i=0; i<2; i++ )); do
|
||||
test_replace $pool "$devices" $nparity
|
||||
|
||||
# Increase pause by about 25%
|
||||
pause=$((pause + (((RANDOM << 15) + RANDOM) % \
|
||||
reflow_size) / 4))
|
||||
log_must set_tunable64 RAIDZ_EXPAND_MAX_REFLOW_BYTES $pause
|
||||
|
||||
wait_expand_paused
|
||||
done
|
||||
|
||||
# Set pause past largest possible value for this pool
|
||||
pause=$((devs*dev_size_mb*1024*1024))
|
||||
log_must set_tunable64 RAIDZ_EXPAND_MAX_REFLOW_BYTES $pause
|
||||
|
||||
log_must zpool wait -t raidz_expand $pool
|
||||
done
|
||||
|
||||
log_must zpool destroy "$pool"
|
||||
|
||||
log_pass "raidz expansion test succeeded."
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or http://www.opensolaris.org/os/licensing.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2023 by iXsystems, Inc.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# 'zpool attach poolname raidz ...' should fail if raidz_expansion
|
||||
# feature is not enabled.
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create raidz pool with raidz_expansion feature disabled
|
||||
# 2. Attempt to attach a device to the raidz vdev
|
||||
# 3. Verify that device attached failed
|
||||
# 4. Destroy the raidz pool
|
||||
|
||||
typeset -r devs=4
|
||||
typeset -r dev_size_mb=128
|
||||
typeset -a disks
|
||||
|
||||
function cleanup
|
||||
{
|
||||
log_pos zpool status "$TESTPOOL"
|
||||
|
||||
poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL"
|
||||
|
||||
for i in {0..$devs}; do
|
||||
log_must rm -f "$TEST_BASE_DIR/dev-$i"
|
||||
done
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
for i in {0..$devs}; do
|
||||
device=$TEST_BASE_DIR/dev-$i
|
||||
log_must truncate -s ${dev_size_mb}M "$device"
|
||||
if [[ $i -ne $devs ]]; then
|
||||
disks[${#disks[*]}+1]=$device
|
||||
fi
|
||||
done
|
||||
|
||||
# create a pool with raidz_expansion feature disabled
|
||||
log_must zpool create -f -o cachefile=none -o feature@raidz_expansion=disabled \
|
||||
"$TESTPOOL" raidz1 "${disks[@]}"
|
||||
status=$(zpool list -H -o feature@raidz_expansion "$TESTPOOL")
|
||||
if [[ "$status" != "disabled" ]]; then
|
||||
log_fail "raidz_expansion feature was not disabled"
|
||||
fi
|
||||
|
||||
# expecting attach to fail
|
||||
log_mustnot_expect "raidz_expansion feature must be enabled" zpool attach -f \
|
||||
"$TESTPOOL" raidz1-0 "$TEST_BASE_DIR/dev-$devs"
|
||||
log_must zpool destroy "$TESTPOOL"
|
||||
|
||||
log_pass "raidz attach failed with feature disabled as expected"
|
||||
@@ -0,0 +1,86 @@
|
||||
#!/bin/ksh -p
|
||||
#
|
||||
# CDDL HEADER START
|
||||
#
|
||||
# The contents of this file are subject to the terms of the
|
||||
# Common Development and Distribution License (the "License").
|
||||
# You may not use this file except in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
||||
# or http://www.opensolaris.org/os/licensing.
|
||||
# See the License for the specific language governing permissions
|
||||
# and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL HEADER in each
|
||||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
||||
# If applicable, add the following below this CDDL HEADER, with the
|
||||
# fields enclosed by brackets "[]" replaced with your own identifying
|
||||
# information: Portions Copyright [yyyy] [name of copyright owner]
|
||||
#
|
||||
# CDDL HEADER END
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2023 by iXsystems, Inc.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Negative for FreeBSD Only
|
||||
#
|
||||
# Attempting to expand a RAIDZ should fail if the scratch area on the
|
||||
# existing disks contains BTX Server binary (used to boot FreeBSD when
|
||||
# using MBR partitions with ZFS).
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create raidz pool
|
||||
# 2. Add a BTX header to the reserved boot area
|
||||
# 3. Attempt to attach a device to the raidz vdev
|
||||
# 4. Verify that device attached failed
|
||||
# 5. Destroy the raidz pool
|
||||
|
||||
typeset -r devs=4
|
||||
typeset -r dev_size_mb=128
|
||||
typeset -a disks
|
||||
|
||||
function cleanup
|
||||
{
|
||||
log_pos zpool status "$TESTPOOL"
|
||||
|
||||
poolexists "$TESTPOOL" && log_must_busy zpool destroy "$TESTPOOL"
|
||||
|
||||
for i in {0..$devs}; do
|
||||
log_must rm -f "$TEST_BASE_DIR/dev-$i"
|
||||
done
|
||||
}
|
||||
|
||||
log_onexit cleanup
|
||||
|
||||
for i in {0..$devs}; do
|
||||
device=$TEST_BASE_DIR/dev-$i
|
||||
# simulate active BTX Server data by inserting a BTX header
|
||||
printf "\xeb\x0e%s\x01\x02\x80" "BTX" | dd of="$device" \
|
||||
bs=512 seek=1024 status=none
|
||||
log_must truncate -s ${dev_size_mb}M "$device"
|
||||
if [[ $i -ne $devs ]]; then
|
||||
disks[${#disks[*]}+1]=$device
|
||||
fi
|
||||
done
|
||||
|
||||
log_must zpool create -f -o cachefile=none "$TESTPOOL" raidz1 "${disks[@]}"
|
||||
|
||||
if is_freebsd; then
|
||||
# expecting attach to fail
|
||||
log_mustnot_expect "the reserved boot area" zpool attach -f \
|
||||
"$TESTPOOL" raidz1-0 "$TEST_BASE_DIR/dev-$devs"
|
||||
log_must zpool destroy "$TESTPOOL"
|
||||
log_pass "raidz attach failed with in-use reserved boot area"
|
||||
else
|
||||
# expecting attach to pass everywhere else
|
||||
log_must zpool attach -f "$TESTPOOL" raidz1-0 "$TEST_BASE_DIR/dev-$devs"
|
||||
log_must zpool destroy "$TESTPOOL"
|
||||
log_pass "raidz attach passed with in-use reserved boot area"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user