Create zap for root vdev

And add it to the AVZ, this is not backwards compatible with older pools
due to an assertion in spa_sync() that verifies the number of ZAPs of
all vdevs matches the number of ZAPs in the AVZ.

Granted, the assertion only applies to #DEBUG builds - still, a feature
flag is introduced to avoid the assertion, com.klarasystems:vdev_zaps_v2

Notably, this allows to get/set properties on the root vdev:

    % zpool set user:prop=value <pool> root-0

Before this commit, it was already possible to get/set properties on
top-level vdevs with the syntax <type>-<vdev_id> (e.g. mirror-0):

    % zpool set user:prop=value <pool> mirror-0

This syntax also applies to the root vdev as it is is of type 'root'
with a vdev_id of 0, root-0. The keyword 'root' as an alias for
'root-0'.

The following tests have been added:

    - zpool get all properties from root vdev
    - zpool set a property on root vdev
    - verify root vdev ZAP is created

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Wing <rob.wing@klarasystems.com>
Sponsored-by: Seagate Technology
Submitted-by: Klara, Inc.
Closes #14405
This commit is contained in:
rob-wing
2023-04-20 09:07:56 -08:00
committed by GitHub
parent 71d191ef25
commit 3e4ed4213d
27 changed files with 339 additions and 38 deletions
+3
View File
@@ -178,6 +178,7 @@ nobase_dist_datadir_zfs_tests_tests_DATA += \
functional/cli_root/zpool_expand/zpool_expand.cfg \
functional/cli_root/zpool_export/zpool_export.cfg \
functional/cli_root/zpool_export/zpool_export.kshlib \
functional/cli_root/zpool_get/vdev_get.cfg \
functional/cli_root/zpool_get/zpool_get.cfg \
functional/cli_root/zpool_get/zpool_get_parsable.cfg \
functional/cli_root/zpool_import/blockfiles/cryptv0.dat.bz2 \
@@ -1032,6 +1033,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
functional/cli_root/zpool_export/zpool_export_004_pos.ksh \
functional/cli_root/zpool_get/cleanup.ksh \
functional/cli_root/zpool_get/setup.ksh \
functional/cli_root/zpool_get/vdev_get_001_pos.ksh \
functional/cli_root/zpool_get/zpool_get_001_pos.ksh \
functional/cli_root/zpool_get/zpool_get_002_pos.ksh \
functional/cli_root/zpool_get/zpool_get_003_pos.ksh \
@@ -1146,6 +1148,7 @@ nobase_dist_datadir_zfs_tests_tests_SCRIPTS += \
functional/cli_root/zpool_set/cleanup.ksh \
functional/cli_root/zpool_set/setup.ksh \
functional/cli_root/zpool/setup.ksh \
functional/cli_root/zpool_set/vdev_set_001_pos.ksh \
functional/cli_root/zpool_set/zpool_set_001_pos.ksh \
functional/cli_root/zpool_set/zpool_set_002_neg.ksh \
functional/cli_root/zpool_set/zpool_set_003_neg.ksh \
@@ -0,0 +1,73 @@
#
# 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) 2022, Klara Inc.
#
# Set the expected properties of a vdev
typeset -a properties=(
capacity
state
guid
asize
psize
ashift
size
free
allocated
comment
expandsize
fragmentation
bootsize
parity
path
devid
physpath
encpath
fru
parent
children
numchildren
read_errors
write_errors
checksum_errors
initialize_errors
null_ops
read_ops
write_ops
free_ops
claim_ops
trim_ops
null_bytes
read_bytes
write_bytes
free_bytes
claim_bytes
trim_bytes
removing
allocating
failfast
checksum_n
checksum_t
io_n
io_t
)
@@ -0,0 +1,62 @@
#!/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) 2022, Klara Inc.
#
. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/cli_root/zpool_get/vdev_get.cfg
#
# DESCRIPTION:
#
# zpool get <pool> root works as expected
#
# STRATEGY:
#
# 1. use zpool get to retrieve properties from root vdev
# 2. verify expected properties match detected properties
#
log_assert "zpool get all on root vdev"
EXPECT="$(zpool get -H all ${TESTPOOL} root | wc -l)"
if [ $? -ne 0 ]; then
log_fail "cannot retrieve properties from root vdev"
fi
i=0;
while [ $i -lt "${#properties[@]}" ]
do
log_must zpool get -H "${properties[$i]}" "$TESTPOOL" root
i=$(($i+1))
done
EXPECT=$((EXPECT))
if [ $i -gt $EXPECT ]; then
log_fail "found vdev properties not in vdev_get.cfg: $i/$EXPECT."
elif [ $i -lt $EXPECT ]; then
log_fail "expected properties not found in vdev_get.cfg: $i/$EXPECT."
fi
log_pass "zpool get all on root vdev"
@@ -104,5 +104,6 @@ if is_linux || is_freebsd; then
"feature@head_errlog"
"feature@blake3"
"feature@block_cloning"
"feature@vdev_zaps_v2"
)
fi
@@ -0,0 +1,52 @@
#!/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) 2022, Klara Inc.
#
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
#
# zpool set comment property on root vdev
#
# STRATEGY:
# 1. set a property on root vdev
# 2. verify the property is set
#
log_assert "zpool set comment property on root vdev"
log_must zpool set comment="openzfs" ${TESTPOOL} root
COMMENT="$(zpool get -H -o value comment ${TESTPOOL} root)"
if [ $? -ne 0 ]; then
log_fail "cant retrieve comment property from root vdev"
fi
if [ "$COMMENT" != "openzfs" ]; then
log_fail "unexpected value for comment property: $COMMENT != \"openzfs\""
fi
log_pass "zpool set comment property on root vdev"
@@ -34,6 +34,10 @@ function get_top_vd_zap # dsk conf
{
get_conf_section "$1" "$2" | awk '/com.delphix:vdev_zap_top: [0-9]+/ {print $2}'
}
function get_root_vd_zap # conf
{
awk '/com.klarasystems:vdev_zap_root: [0-9]+/ {print $2}' "$1"
}
function assert_has_sentinel # conf
{
@@ -54,6 +58,15 @@ function assert_zap_common # pool vd lvl zapobj
fi
}
function assert_root_zap # pool conf
{
typeset pool=$1
typeset conf=$2
root_zap=$(get_root_vd_zap $conf)
assert_zap_common $pool "root vdev" "root" $root_zap
}
function assert_top_zap # pool vd conf
{
typeset pool=$1
@@ -21,7 +21,7 @@
#
# Strategy:
# 1. Create a pool with one disk.
# 2. Verify that the disk has a top and leaf ZAP in its config and the MOS.
# 2. Verify that the disk has a root, top and leaf ZAP in its config and the MOS.
#
. $STF_SUITE/include/libtest.shlib
@@ -35,6 +35,7 @@ log_must zpool create -f $TESTPOOL $DISK
conf="$TESTDIR/vz001"
log_must eval "zdb -PC $TESTPOOL > $conf"
assert_root_zap $TESTPOOL "$conf"
assert_top_zap $TESTPOOL $DISK "$conf"
assert_leaf_zap $TESTPOOL $DISK "$conf"
assert_has_sentinel "$conf"
@@ -36,6 +36,7 @@ conf="$TESTDIR/vz002"
log_must eval "zdb -PC $TESTPOOL > $conf"
assert_has_sentinel "$conf"
assert_root_zap $TESTPOOL "$conf"
for DISK in $DISKS; do
assert_top_zap $TESTPOOL $DISK "$conf"
assert_leaf_zap $TESTPOOL $DISK "$conf"
@@ -37,6 +37,7 @@ conf="$TESTDIR/vz003"
log_must eval "zdb -PC $TESTPOOL > $conf"
assert_has_sentinel "$conf"
assert_root_zap $TESTPOOL "$conf"
assert_top_zap $TESTPOOL "type: 'mirror'" "$conf"
for DISK in $DISKS; do
assert_leaf_zap $TESTPOOL $DISK "$conf"
@@ -40,6 +40,7 @@ log_must zpool create -f $TESTPOOL $DISK
conf="$TESTDIR/vz004"
log_must eval "zdb -PC $TESTPOOL > $conf"
assert_has_sentinel "$conf"
assert_root_zap $TESTPOOL "$conf"
orig_top=$(get_top_vd_zap $DISK $conf)
orig_leaf=$(get_leaf_vd_zap $DISK $conf)
assert_zap_common $TESTPOOL $DISK "top" $orig_top
@@ -37,6 +37,7 @@ log_must zpool create -f $TESTPOOL $DISK
conf="$TESTDIR/vz005"
log_must eval "zdb -PC $TESTPOOL > $conf"
assert_has_sentinel "$conf"
assert_root_zap $TESTPOOL "$conf"
orig_top=$(get_top_vd_zap $DISK $conf)
orig_leaf=$(get_leaf_vd_zap $DISK $conf)
assert_zap_common $TESTPOOL $DISK "top" $orig_top
@@ -39,6 +39,7 @@ conf="$TESTDIR/vz006"
log_must eval "zdb -PC $TESTPOOL > $conf"
assert_has_sentinel "$conf"
assert_root_zap $TESTPOOL "$conf"
orig_top=$(get_top_vd_zap ${DISK_ARR[1]} $conf)
assert_zap_common $TESTPOOL ${DISK_ARR[1]} "top" $orig_top
assert_leaf_zap $TESTPOOL ${DISK_ARR[1]} "$conf"
@@ -39,6 +39,7 @@ conf="$TESTDIR/vz007"
log_must eval "zdb -PC $TESTPOOL > $conf"
assert_has_sentinel "$conf"
assert_root_zap $TESTPOOL "$conf"
orig_top=$(get_top_vd_zap "type: 'mirror'" $conf)
orig_leaf0=$(get_leaf_vd_zap ${DISK_ARR[0]} $conf)
orig_leaf1=$(get_leaf_vd_zap ${DISK_ARR[1]} $conf)