Improve and fix gang blocks dyn header test

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Signed-off-by: Paul Dagnelie <paul.dagnelie@klarasystems.com>
Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Closes #17587
This commit is contained in:
Paul Dagnelie 2025-07-31 15:23:25 -07:00 committed by Brian Behlendorf
parent 2c8beeece0
commit 8ecf044d62
2 changed files with 56 additions and 31 deletions

View File

@ -72,6 +72,23 @@ function get_num_dvas
sed 's/.*L[0-9] \(.*\) [a-f0-9]*L.*/\1/' | awk '{print NF}'
}
function check_gang_bp
{
typeset gang="$(echo -n $1 | grep -c 'gang')"
[[ "$gang" == "1" ]] || return 1
return 0
}
function check_is_gang_bp
{
check_gang_bp $1 || log_fail "Not a gang DVA: \"$1\""
}
function check_not_gang_bp
{
check_gang_bp $1 && log_fail "Gang DVA: \"$1\""
}
function check_gang_dva
{
typeset last_byte="$(echo -n $1 | tail -c 1)"

View File

@ -33,41 +33,49 @@ log_assert "Verify that we don't use large gang headers on small-ashift pools".
log_onexit cleanup
preamble
log_must zpool create -f -o ashift=12 -o feature@dynamic_gang_header=enabled $TESTPOOL $DISKS
log_must zfs create -o recordsize=1M $TESTPOOL/$TESTFS
mountpoint=$(get_prop mountpoint $TESTPOOL/$TESTFS)
set_tunable64 METASLAB_FORCE_GANGING 200000
set_tunable32 METASLAB_FORCE_GANGING_PCT 100
for vdevtype in "" "mirror" "raidz" "raidz2" "draid"; do
log_must zpool create -f -o ashift=12 $TESTPOOL $vdevtype $DISKS
log_must zfs create -o recordsize=1M $TESTPOOL/$TESTFS
mountpoint=$(get_prop mountpoint $TESTPOOL/$TESTFS)
set_tunable64 METASLAB_FORCE_GANGING 200000
set_tunable32 METASLAB_FORCE_GANGING_PCT 100
status=$(get_pool_prop feature@dynamic_gang_header $TESTPOOL)
[[ "$status" == "enabled" ]] || log_fail "Dynamic gang headers not enabled"
path="${mountpoint}/file"
log_must dd if=/dev/urandom of=$path bs=1M count=1
log_must zpool sync $TESTPOOL
first_block=$(get_first_block_dva $TESTPOOL/$TESTFS file)
leaves=$(read_gang_header $TESTPOOL $first_block 1000 | grep -v HOLE)
first_dva=$(echo "$leaves" | head -n 1 | awk '{print $1}' | sed 's/.*<//' | sed 's/>.*//')
check_not_gang_dva $first_dva
status=$(get_pool_prop feature@dynamic_gang_header $TESTPOOL)
[[ "$status" == "enabled" ]] || \
log_fail "Dynamic gang headers not enabled"
path="${mountpoint}/file"
log_must dd if=/dev/urandom of=$path bs=1M count=1
log_must zpool sync $TESTPOOL
first_block=$(get_first_block_dva $TESTPOOL/$TESTFS file)
leaves=$(read_gang_header $TESTPOOL $first_block 1000 | \
grep -v HOLE | grep -v "^Found")
first_child=$(echo "$leaves" | head -n 1)
check_gang_bp $first_child
num_leaves=$(echo "$leaves" | wc -l)
[[ "$num_leaves" -gt 3 ]] && log_fail "used a larger gang header too soon: \"$leaves\""
log_must verify_pool $TESTPOOL
status=$(get_pool_prop feature@dynamic_gang_header $TESTPOOL)
[[ "$status" == "active" ]] || log_fail "Dynamic gang headers not active"
num_leaves=$(echo "$leaves" | wc -l)
[[ "$num_leaves" -gt 3 ]] && \
log_fail "used a larger gang header too soon: \"$leaves\""
log_must verify_pool $TESTPOOL
status=$(get_pool_prop feature@dynamic_gang_header $TESTPOOL)
[[ "$status" == "active" ]] || log_fail "Dynamic gang headers not active"
path="${mountpoint}/file2"
log_must dd if=/dev/urandom of=$path bs=1M count=1
log_must zpool sync $TESTPOOL
first_block=$(get_first_block_dva $TESTPOOL/$TESTFS file2)
leaves=$(read_gang_header $TESTPOOL $first_block 1000 | grep -v HOLE)
first_dva=$(echo "$leaves" | head -n 1 | awk '{print $1}' | sed 's/.*<//' | sed 's/>.*//')
check_not_gang_dva $first_dva
path="${mountpoint}/file2"
log_must dd if=/dev/urandom of=$path bs=1M count=1
log_must zpool sync $TESTPOOL
first_block=$(get_first_block_dva $TESTPOOL/$TESTFS file2)
leaves=$(read_gang_header $TESTPOOL $first_block 1000 | \
grep -v HOLE | grep -v "^Found")
first_child=$(echo "$leaves" | head -n 1)
check_not_gang_bp $first_child
num_leaves=$(echo "$leaves" | wc -l)
[[ "$num_leaves" -gt 3 ]] || log_fail "didn't use a larger gang header: \"$leaves\""
num_leaves=$(echo "$leaves" | wc -l)
[[ "$num_leaves" -gt 3 ]] || \
log_fail "didn't use a larger gang header: \"$leaves\""
log_must verify_pool $TESTPOOL
status=$(get_pool_prop feature@dynamic_gang_header $TESTPOOL)
[[ "$status" == "active" ]] || log_fail "Dynamic gang headers not active"
log_must verify_pool $TESTPOOL
status=$(get_pool_prop feature@dynamic_gang_header $TESTPOOL)
[[ "$status" == "active" ]] || log_fail "Dynamic gang headers not active"
log_must zpool destroy $TESTPOOL
done
log_pass "We don't use large gang headers on small-ashift pools".