Skip to content

Commit

Permalink
BRT: Check pool stats in more tests
Browse files Browse the repository at this point in the history
This should allow to catch some leaks, if those happen.

While there fix some cosmetic issues.

Signed-off-by:  Alexander Motin <[email protected]>
Sponsored by:   iXsystems, Inc.
  • Loading branch information
amotin committed Mar 20, 2024
1 parent 78ab221 commit a424355
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tests/zfs-tests/tests/functional/bclone/bclone_corner_cases.kshlib
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function bclone_corner_cases_init
export SECOND_HALF_ORIG0_CHECKSUM=$(second_half_checksum $ORIG0)
export SECOND_HALF_ORIG1_CHECKSUM=$(second_half_checksum $ORIG1)
export SECOND_HALF_ORIG2_CHECKSUM=$(second_half_checksum $ORIG2)
export ZEROS_CHECKSUM=$(dd if=/dev/zero bs=$HALFRECORDSIZE count=1 | sha256digest)
export ZEROS_CHECKSUM=$(dd if=/dev/zero bs=$HALFRECORDSIZE count=1 2>/dev/null | sha256digest)
export FIRST_HALF_CHECKSUM=""
export SECOND_HALF_CHECKSUM=""
}
Expand All @@ -77,7 +77,7 @@ function cache_clone

case "$cached" in
"cached")
dd if=$CLONE of=/dev/null bs=$RECORDSIZE 2>/dev/null
log_must dd if=$CLONE of=/dev/null bs=$RECORDSIZE
;;
"uncached")
;;
Expand Down Expand Up @@ -210,13 +210,20 @@ function bclone_corner_cases_test
typeset -r dstdir=$2
typeset limit=$3
typeset -i count=0
typeset oused
typeset osaved

if [[ $srcdir != "count" ]]; then
if [[ -n "$limit" ]]; then
typeset -r total_count=$(bclone_corner_cases_test count)
limit=$(random_int_between 1 $total_count $((limit*2)) | sort -nu | head -n $limit | xargs)
fi
bclone_corner_cases_init $srcdir $dstdir

# Save current block cloning stats for later use.
sync_pool $TESTPOOL
oused=$(get_pool_prop bcloneused $TESTPOOL)
osaved=$(get_pool_prop bclonesaved $TESTPOOL)
fi

#
Expand Down Expand Up @@ -285,21 +292,24 @@ function bclone_corner_cases_test
overwrite_clone "$second_overwrite"

if checksum_compare $read_after; then
log_note "existing: $existing / cached: $cached / first_clone: $first_clone / first_overwrite: $first_overwrite / read_before: $read_before / second_clone: $second_clone / read_after: $read_after"
log_note "existing: $existing / cached: $cached / first_clone: $first_clone / first_overwrite: $first_overwrite / read_before: $read_before / second_clone: $second_clone / second_overwrite: $second_overwrite / read_after: $read_after"
else
log_fail "FAIL: existing: $existing / cached: $cached / first_clone: $first_clone / first_overwrite: $first_overwrite / read_before: $read_before / second_clone: $second_clone / read_after: $read_after"
log_fail "FAIL: existing: $existing / cached: $cached / first_clone: $first_clone / first_overwrite: $first_overwrite / read_before: $read_before / second_clone: $second_clone / second_overwrite: $second_overwrite / read_after: $read_after"
fi

log_must zpool export $TESTPOOL
log_must zpool import $TESTPOOL

if checksum_compare "yes"; then
log_note "existing: $existing / cached: $cached / first_clone: $first_clone / first_overwrite: $first_overwrite / read_before: $read_before / second_clone: $second_clone / read_after: $read_after / read_next_txg"
log_note "existing: $existing / cached: $cached / first_clone: $first_clone / first_overwrite: $first_overwrite / read_before: $read_before / second_clone: $second_clone / second_overwrite: $second_overwrite / read_after: $read_after / read_next_txg"
else
log_fail "FAIL: existing: $existing / cached: $cached / first_clone: $first_clone / first_overwrite: $first_overwrite / read_before: $read_before / second_clone: $second_clone / read_after: $read_after / read_next_txg"
log_fail "FAIL: existing: $existing / cached: $cached / first_clone: $first_clone / first_overwrite: $first_overwrite / read_before: $read_before / second_clone: $second_clone / second_overwrite: $second_overwrite / read_after: $read_after / read_next_txg"
fi

rm -f "$CLONE"
sync_pool $TESTPOOL
verify_pool_prop_eq bcloneused $oused
verify_pool_prop_eq bclonesaved $osaved
done
done
done
Expand Down

0 comments on commit a424355

Please sign in to comment.