mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
Add ashift validation when adding devices to a pool
Currently, zpool add allows users to add top-level vdevs that have different ashifts but doing so prevents users from being able to perform a top-level vdev removal. Often times consumers may not realize that they have mismatched ashifts until the top-level removal fails. This feature adds ashift validation to the zpool add command and will fail the operation if the sector size of the specified vdev does not match the existing pool. This behavior can be disabled by using the -f flag. In addition, new flags have been added to provide fine-grained control to disable specific checks. These flags are: --allow-in-use --allow-ashift-mismatch --allow-replicaton-mismatch The force flag will disable all of these checks. Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Mark Maybee <mmaybee@delphix.com> Signed-off-by: George Wilson <gwilson@delphix.com> Closes #15509
This commit is contained in:
committed by
Tony Hutter
parent
b3b37b84e8
commit
6f323353d2
@@ -372,7 +372,8 @@ tags = ['functional', 'cli_root', 'zpool']
|
||||
tests = ['zpool_add_001_pos', 'zpool_add_002_pos', 'zpool_add_003_pos',
|
||||
'zpool_add_004_pos', 'zpool_add_006_pos', 'zpool_add_007_neg',
|
||||
'zpool_add_008_neg', 'zpool_add_009_neg', 'zpool_add_010_pos',
|
||||
'add-o_ashift', 'add_prop_ashift', 'zpool_add_dryrun_output']
|
||||
'add-o_ashift', 'add_prop_ashift', 'zpool_add_dryrun_output',
|
||||
'zpool_add--allow-ashift-mismatch']
|
||||
tags = ['functional', 'cli_root', 'zpool_add']
|
||||
|
||||
[tests/functional/cli_root/zpool_attach]
|
||||
|
||||
@@ -989,6 +989,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
|
||||
functional/cli_root/zpool_add/add_prop_ashift.ksh \
|
||||
functional/cli_root/zpool_add/cleanup.ksh \
|
||||
functional/cli_root/zpool_add/setup.ksh \
|
||||
functional/cli_root/zpool_add/zpool_add--allow-ashift-mismatch.ksh \
|
||||
functional/cli_root/zpool_add/zpool_add_001_pos.ksh \
|
||||
functional/cli_root/zpool_add/zpool_add_002_pos.ksh \
|
||||
functional/cli_root/zpool_add/zpool_add_003_pos.ksh \
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#
|
||||
# Copyright 2017, loli10K. All rights reserved.
|
||||
# Copyright (c) 2020 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2020, 2024 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -60,12 +60,23 @@ log_must mkfile $SIZE $disk2
|
||||
logical_ashift=$(get_tunable VDEV_FILE_LOGICAL_ASHIFT)
|
||||
orig_ashift=$(get_tunable VDEV_FILE_PHYSICAL_ASHIFT)
|
||||
max_auto_ashift=$(get_tunable VDEV_MAX_AUTO_ASHIFT)
|
||||
opt=""
|
||||
|
||||
typeset ashifts=("9" "10" "11" "12" "13" "14" "15" "16")
|
||||
for ashift in ${ashifts[@]}
|
||||
do
|
||||
#
|
||||
# Need to add the --allow-ashift-mismatch option to disable the
|
||||
# ashift mismatch checks in zpool add.
|
||||
#
|
||||
if [[ $ashift -eq $orig_ashift ]]; then
|
||||
opt=""
|
||||
else
|
||||
opt="--allow-ashift-mismatch"
|
||||
fi
|
||||
|
||||
log_must zpool create $TESTPOOL $disk1
|
||||
log_must zpool add -o ashift=$ashift $TESTPOOL $disk2
|
||||
log_must zpool add $opt -o ashift=$ashift $TESTPOOL $disk2
|
||||
log_must verify_ashift $disk2 $ashift
|
||||
|
||||
# clean things for the next run
|
||||
@@ -78,7 +89,7 @@ do
|
||||
#
|
||||
log_must zpool create $TESTPOOL $disk1
|
||||
log_must set_tunable32 VDEV_FILE_PHYSICAL_ASHIFT $ashift
|
||||
log_must zpool add $TESTPOOL $disk2
|
||||
log_must zpool add $opt $TESTPOOL $disk2
|
||||
exp=$(( (ashift <= max_auto_ashift) ? ashift : logical_ashift ))
|
||||
log_must verify_ashift $disk2 $exp
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#
|
||||
# Copyright 2017, loli10K. All rights reserved.
|
||||
# Copyright (c) 2020 by Delphix. All rights reserved.
|
||||
# Copyright (c) 2020, 2024 by Delphix. All rights reserved.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
@@ -68,8 +68,13 @@ log_must set_tunable32 VDEV_FILE_PHYSICAL_ASHIFT 16
|
||||
typeset ashifts=("9" "10" "11" "12" "13" "14" "15" "16")
|
||||
for ashift in ${ashifts[@]}
|
||||
do
|
||||
if [ $ashift -eq $orig_ashift ];then
|
||||
opt=""
|
||||
else
|
||||
opt="--allow-ashift-mismatch"
|
||||
fi
|
||||
log_must zpool create -o ashift=$ashift $TESTPOOL $disk1
|
||||
log_must zpool add $TESTPOOL $disk2
|
||||
log_must zpool add $opt $TESTPOOL $disk2
|
||||
log_must verify_ashift $disk2 $ashift
|
||||
|
||||
# clean things for the next run
|
||||
@@ -82,8 +87,13 @@ for ashift in ${ashifts[@]}
|
||||
do
|
||||
for cmdval in ${ashifts[@]}
|
||||
do
|
||||
if [ $ashift -eq $cmdval ];then
|
||||
opt=""
|
||||
else
|
||||
opt="--allow-ashift-mismatch"
|
||||
fi
|
||||
log_must zpool create -o ashift=$ashift $TESTPOOL $disk1
|
||||
log_must zpool add -o ashift=$cmdval $TESTPOOL $disk2
|
||||
log_must zpool add $opt -o ashift=$cmdval $TESTPOOL $disk2
|
||||
log_must verify_ashift $disk2 $cmdval
|
||||
|
||||
# clean things for the next run
|
||||
|
||||
@@ -65,4 +65,15 @@ log_mustnot vdevs_in_pool $TESTPOOL $DISK2
|
||||
log_must zpool add -f $TESTPOOL $DISK2
|
||||
log_must vdevs_in_pool $TESTPOOL $DISK2
|
||||
|
||||
log_must zpool destroy $TESTPOOL
|
||||
|
||||
create_pool $TESTPOOL mirror $DISK0 $DISK1
|
||||
log_must poolexists $TESTPOOL
|
||||
|
||||
log_mustnot zpool add $TESTPOOL $DISK2
|
||||
log_mustnot vdevs_in_pool $TESTPOOL $DISK2
|
||||
|
||||
log_must zpool add --allow-replication-mismatch $TESTPOOL $DISK2
|
||||
log_must vdevs_in_pool $TESTPOOL $DISK2
|
||||
|
||||
log_pass "'zpool add -f <pool> <vdev> ...' executes successfully."
|
||||
|
||||
@@ -70,7 +70,7 @@ if is_freebsd; then
|
||||
recursive=$(get_tunable VOL_RECURSIVE)
|
||||
log_must set_tunable64 VOL_RECURSIVE 1
|
||||
fi
|
||||
log_must zpool add $TESTPOOL $ZVOL_DEVDIR/$TESTPOOL1/$TESTVOL
|
||||
log_must zpool add --allow-ashift-mismatch $TESTPOOL $ZVOL_DEVDIR/$TESTPOOL1/$TESTVOL
|
||||
|
||||
log_must vdevs_in_pool "$TESTPOOL" "$ZVOL_DEVDIR/$TESTPOOL1/$TESTVOL"
|
||||
|
||||
|
||||
@@ -75,7 +75,9 @@ log_must poolexists $TESTPOOL1
|
||||
|
||||
unset NOINUSE_CHECK
|
||||
log_mustnot zpool add -f $TESTPOOL $DISK1
|
||||
log_mustnot zpool add --allow-in-use $TESTPOOL $DISK1
|
||||
log_mustnot zpool add -f $TESTPOOL $mnttab_dev
|
||||
log_mustnot zpool add --allow-in-use $TESTPOOL $mnttab_dev
|
||||
if is_linux; then
|
||||
log_mustnot zpool add $TESTPOOL $vfstab_dev
|
||||
else
|
||||
|
||||
@@ -64,7 +64,9 @@ log_mustnot zpool add -f $TESTPOOL $DISK0
|
||||
for type in "" "mirror" "raidz" "draid" "spare" "log" "dedup" "special" "cache"
|
||||
do
|
||||
log_mustnot zpool add -f $TESTPOOL $type $DISK0 $DISK1
|
||||
log_mustnot zpool add --allow-in-use $TESTPOOL $type $DISK0 $DISK1
|
||||
log_mustnot zpool add -f $TESTPOOL $type $DISK1 $DISK1
|
||||
log_mustnot zpool add --allow-in-use $TESTPOOL $type $DISK1 $DISK1
|
||||
done
|
||||
|
||||
log_pass "'zpool add' get fail as expected if vdevs are the same or vdev is " \
|
||||
|
||||
@@ -138,7 +138,7 @@ function zpool_create_forced_add
|
||||
while ((j < ${#add_args[@]})); do
|
||||
log_must zpool create $TESTPOOL1 ${create_args[$i]}
|
||||
log_mustnot zpool add $TESTPOOL1 ${add_args[$j]}
|
||||
log_must zpool add -f $TESTPOOL1 ${add_args[$j]}
|
||||
log_must zpool add --allow-replication-mismatch $TESTPOOL1 ${add_args[$j]}
|
||||
log_must zpool destroy -f $TESTPOOL1
|
||||
|
||||
((j += 1))
|
||||
|
||||
Reference in New Issue
Block a user