mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-18 10:21:01 +03:00
ZTS: Simplify zpool_initialize_verify_initialized
Consider the test to be a success as long as the initializing pattern is found at least once per metaslab. This indicates that at least part of the free space was initialized. Ideally we'd check that the pattern was written to all free space but that's much trickier so this check is a reasonable compromise. Using a here-string to feed the loop in this test causes an empty string to still trigger the loop so we miss the `spacemaps=0` case. Pipe into the loop instead. While here, we can use `zpool wait -t initialize $TESTPOOL` to wait for the pool to initialize. Co-authored-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ryan Moeller <ryan@iXsystems.com> Closes #11365
This commit is contained in:
parent
a103ae446e
commit
fa7b558bef
@ -24,7 +24,6 @@
|
|||||||
# Copyright (c) 2016 by Delphix. All rights reserved.
|
# Copyright (c) 2016 by Delphix. All rights reserved.
|
||||||
#
|
#
|
||||||
. $STF_SUITE/include/libtest.shlib
|
. $STF_SUITE/include/libtest.shlib
|
||||||
. $STF_SUITE/tests/functional/cli_root/zpool_initialize/zpool_initialize.kshlib
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# DESCRIPTION:
|
# DESCRIPTION:
|
||||||
@ -33,8 +32,8 @@
|
|||||||
# STRATEGY:
|
# STRATEGY:
|
||||||
# 1. Create a one-disk pool.
|
# 1. Create a one-disk pool.
|
||||||
# 2. Initialize the disk to completion.
|
# 2. Initialize the disk to completion.
|
||||||
# 3. Load all metaslabs that don't have a spacemap, and make sure the entire
|
# 3. Load all metaslabs and make sure that each contains at least
|
||||||
# metaslab has been filled with the initializing pattern (deadbeef).
|
# once instance of the initializing pattern (deadbeef).
|
||||||
#
|
#
|
||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
@ -58,32 +57,34 @@ ORIG_PATTERN=$(get_tunable INITIALIZE_VALUE)
|
|||||||
log_must set_tunable64 INITIALIZE_VALUE $(printf %llu 0x$PATTERN)
|
log_must set_tunable64 INITIALIZE_VALUE $(printf %llu 0x$PATTERN)
|
||||||
|
|
||||||
log_must mkdir "$TESTDIR"
|
log_must mkdir "$TESTDIR"
|
||||||
log_must mkfile $MINVDEVSIZE "$SMALLFILE"
|
log_must truncate -s $MINVDEVSIZE "$SMALLFILE"
|
||||||
log_must zpool create $TESTPOOL "$SMALLFILE"
|
log_must zpool create $TESTPOOL "$SMALLFILE"
|
||||||
log_must zpool initialize $TESTPOOL
|
log_must zpool initialize -w $TESTPOOL
|
||||||
|
|
||||||
while [[ "$(initialize_progress $TESTPOOL $SMALLFILE)" -lt "100" ]]; do
|
|
||||||
sleep 0.5
|
|
||||||
done
|
|
||||||
|
|
||||||
log_must zpool export $TESTPOOL
|
log_must zpool export $TESTPOOL
|
||||||
|
|
||||||
spacemaps=0
|
metaslabs=0
|
||||||
bs=512
|
bs=512
|
||||||
while read -r sm; do
|
zdb -p $TESTDIR -Pme $TESTPOOL | awk '/metaslab[ ]+[0-9]+/ { print $4, $8 }' |
|
||||||
typeset offset="$(echo $sm | cut -d ' ' -f1)"
|
while read -r offset_size; do
|
||||||
typeset size="$(echo $sm | cut -d ' ' -f2)"
|
typeset offset=$(echo $offset_size | cut -d ' ' -f1)
|
||||||
|
typeset size=$(echo $offset_size | cut -d ' ' -f2)
|
||||||
|
|
||||||
spacemaps=$((spacemaps + 1))
|
log_note "offset: '$offset'"
|
||||||
|
log_note "size: '$size'"
|
||||||
|
|
||||||
|
metaslabs=$((metaslabs + 1))
|
||||||
offset=$(((4 * 1024 * 1024) + 16#$offset))
|
offset=$(((4 * 1024 * 1024) + 16#$offset))
|
||||||
out=$(dd if=$SMALLFILE skip=$(($offset / $bs)) \
|
log_note "vdev file offset: '$offset'"
|
||||||
count=$(($size / $bs)) bs=$bs 2>/dev/null | od -t x8 -Ad)
|
|
||||||
echo "$out" | log_must egrep "$PATTERN|\*|$size"
|
|
||||||
done <<< "$(zdb -p $TESTDIR -Pme $TESTPOOL | egrep 'spacemap[ ]+0 ' | \
|
|
||||||
awk '{print $4, $8}')"
|
|
||||||
|
|
||||||
if [[ $spacemaps -eq 0 ]];then
|
# Note we use '-t x4' instead of '-t x8' here because x8 is not
|
||||||
log_fail "Did not find any empty space maps to check"
|
# a supported format on FreeBSD.
|
||||||
|
dd if=$SMALLFILE skip=$((offset / bs)) count=$((size / bs)) bs=$bs |
|
||||||
|
od -t x4 -Ad | egrep -q "deadbeef +deadbeef +deadbeef +deadbeef" ||
|
||||||
|
log_fail "Pattern not found in metaslab free space"
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $metaslabs -eq 0 ]]; then
|
||||||
|
log_fail "Did not find any metaslabs to check"
|
||||||
else
|
else
|
||||||
log_pass "Initializing wrote appropriate amount to disk"
|
log_pass "Initializing wrote to each metaslab"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user