Skip to content

Commit

Permalink
ZTS: remove get_arcstat
Browse files Browse the repository at this point in the history
It's now a simple wrapper, so lets just call kstat direct.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <[email protected]>
  • Loading branch information
robn committed Jan 16, 2025
1 parent a391944 commit e079b6f
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 52 deletions.
21 changes: 2 additions & 19 deletions tests/zfs-tests/include/libtest.shlib
Original file line number Diff line number Diff line change
Expand Up @@ -3664,23 +3664,6 @@ function ls_xattr # path
esac
}

function get_arcstat # stat
{
typeset stat=$1

case "$UNAME" in
FreeBSD)
kstat arcstats.$stat
;;
Linux)
kstat arcstats | awk "/$stat/"' { print $3 }'
;;
*)
false
;;
esac
}

function punch_hole # offset length file
{
typeset offset=$1
Expand Down Expand Up @@ -3732,9 +3715,9 @@ function arcstat_quiescence # stat echo
fi

while $do_once || [ $stat1 -ne $stat2 ] || [ $stat2 -eq 0 ]; do
typeset stat1=$(get_arcstat $stat)
typeset stat1=$(kstat arcstats.$stat)
sleep 0.5
typeset stat2=$(get_arcstat $stat)
typeset stat2=$(kstat arcstats.$stat)
do_once=false
done

Expand Down
4 changes: 2 additions & 2 deletions tests/zfs-tests/tests/functional/cache/cache_012_pos.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export RUNTIME=1

typeset do_once=true
while $do_once || [[ $l2_size1 -le $l2_size2 ]]; do
typeset l2_size1=$(get_arcstat l2_size)
typeset l2_size1=$(kstat arcstats.l2_size)
log_must fio $FIO_SCRIPTS/random_reads.fio
typeset l2_size2=$(get_arcstat l2_size)
typeset l2_size2=$(kstat arcstats.l2_size)
do_once=false
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ log_must truncate -s ${cache_sz}M $VDEV_CACHE

log_must zpool create -O compression=lz4 -f $TESTPOOL-l2arc $VDEV cache $VDEV_CACHE

l2_cksum_bad_start=$(get_arcstat l2_cksum_bad)
l2_cksum_bad_start=$(kstat arcstats.l2_cksum_bad)

log_must fio $FIO_SCRIPTS/mkfiles.fio
log_must fio $FIO_SCRIPTS/random_reads.fio

l2_cksum_bad_end=$(get_arcstat l2_cksum_bad)
l2_cksum_bad_end=$(kstat arcstats.l2_cksum_bad)

log_note "L2ARC Failed Checksums before: $l2_cksum_bad_start After:"\
"$l2_cksum_bad_end"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ log_must truncate -s ${cache_sz}M $VDEV_CACHE

log_must zpool create -O compression=lz4 -f $TESTPOOL-l2arc $VDEV cache $VDEV_CACHE

l2_cksum_bad_start=$(get_arcstat l2_cksum_bad)
l2_cksum_bad_start=$(kstat arcstats.l2_cksum_bad)

log_must fio $FIO_SCRIPTS/mkfiles.fio
log_must fio $FIO_SCRIPTS/random_reads.fio

l2_cksum_bad_end=$(get_arcstat l2_cksum_bad)
l2_cksum_bad_end=$(kstat arcstats.l2_cksum_bad)

log_note "L2ARC Failed Checksums before: $l2_cksum_bad_start After:"\
"$l2_cksum_bad_end"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ log_must eval "echo $PASSPHRASE | zfs create -o compression=zstd " \
"-o encryption=on -o keyformat=passphrase -o keylocation=prompt " \
"$TESTPOOL-l2arc/encrypted"

l2_cksum_bad_start=$(get_arcstat l2_cksum_bad)
l2_cksum_bad_start=$(kstat arcstats.l2_cksum_bad)

log_must fio $FIO_SCRIPTS/mkfiles.fio
log_must fio $FIO_SCRIPTS/random_reads.fio

l2_cksum_bad_end=$(get_arcstat l2_cksum_bad)
l2_cksum_bad_end=$(kstat arcstats.l2_cksum_bad)

log_note "L2ARC Failed Checksums before: $l2_cksum_bad_start After:"\
"$l2_cksum_bad_end"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ log_must eval "echo $PASSPHRASE | zfs create -o compression=zstd " \
"-o encryption=on -o keyformat=passphrase -o keylocation=prompt " \
"$TESTPOOL-l2arc/encrypted"

l2_cksum_bad_start=$(get_arcstat l2_cksum_bad)
l2_cksum_bad_start=$(kstat arcstats.l2_cksum_bad)

log_must fio $FIO_SCRIPTS/mkfiles.fio
log_must fio $FIO_SCRIPTS/random_reads.fio

l2_cksum_bad_end=$(get_arcstat l2_cksum_bad)
l2_cksum_bad_end=$(kstat arcstats.l2_cksum_bad)

log_note "L2ARC Failed Checksums before: $l2_cksum_bad_start After:"\
"$l2_cksum_bad_end"
Expand Down
20 changes: 10 additions & 10 deletions tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ arcstat_quiescence_noecho l2_size
log_must zpool offline $TESTPOOL $VDEV_CACHE
arcstat_quiescence_noecho l2_size

typeset l2_mfu_init=$(get_arcstat l2_mfu_asize)
typeset l2_mru_init=$(get_arcstat l2_mru_asize)
typeset l2_prefetch_init=$(get_arcstat l2_prefetch_asize)
typeset l2_asize_init=$(get_arcstat l2_asize)
typeset l2_mfu_init=$(kstat arcstats.l2_mfu_asize)
typeset l2_mru_init=$(kstat arcstats.l2_mru_asize)
typeset l2_prefetch_init=$(kstat arcstats.l2_prefetch_asize)
typeset l2_asize_init=$(kstat arcstats.l2_asize)

log_must zpool online $TESTPOOL $VDEV_CACHE
arcstat_quiescence_noecho l2_size
log_must zpool export $TESTPOOL
arcstat_quiescence_noecho l2_feeds

log_must test $(get_arcstat l2_mfu_asize) -eq 0
log_must test $(get_arcstat l2_mru_asize) -eq 0
log_must test $(kstat arcstats.l2_mfu_asize) -eq 0
log_must test $(kstat arcstats.l2_mru_asize) -eq 0
log_must zpool import -d $VDIR $TESTPOOL
arcstat_quiescence_noecho l2_size

Expand All @@ -93,10 +93,10 @@ arcstat_quiescence_noecho l2_size
log_must zpool offline $TESTPOOL $VDEV_CACHE
arcstat_quiescence_noecho l2_size

typeset l2_mfu_end=$(get_arcstat l2_mfu_asize)
typeset l2_mru_end=$(get_arcstat l2_mru_asize)
typeset l2_prefetch_end=$(get_arcstat l2_prefetch_asize)
typeset l2_asize_end=$(get_arcstat l2_asize)
typeset l2_mfu_end=$(kstat arcstats.l2_mfu_asize)
typeset l2_mru_end=$(kstat arcstats.l2_mru_asize)
typeset l2_prefetch_end=$(kstat arcstats.l2_prefetch_asize)
typeset l2_asize_end=$(kstat arcstats.l2_asize)

log_must test $(( $l2_mru_end + $l2_mfu_end + $l2_prefetch_end - \
$l2_asize_end )) -eq 0
Expand Down
6 changes: 3 additions & 3 deletions tests/zfs-tests/tests/functional/l2arc/l2arc_l2miss_pos.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ log_must fio $FIO_SCRIPTS/random_reads.fio
log_must zpool export $TESTPOOL1
log_must zpool import $TESTPOOL1 -d $VDEV1

typeset starting_miss_count=$(get_arcstat l2_misses)
typeset starting_miss_count=$(kstat arcstats.l2_misses)

log_must fio $FIO_SCRIPTS/random_reads.fio
log_must test $(get_arcstat l2_misses) -eq $starting_miss_count
log_must test $(kstat arcstats.l2_misses) -eq $starting_miss_count

# I/O to pool with l2arc - expect that l2_misses rises
export DIRECTORY=/$TESTPOOL
Expand All @@ -88,7 +88,7 @@ log_must zpool export $TESTPOOL
log_must zpool import $TESTPOOL -d $VDEV

log_must fio $FIO_SCRIPTS/random_reads.fio
log_must test $(get_arcstat l2_misses) -gt $starting_miss_count
log_must test $(kstat arcstats.l2_misses) -gt $starting_miss_count

log_must zpool destroy -f $TESTPOOL
log_must zpool destroy -f $TESTPOOL1
Expand Down
4 changes: 2 additions & 2 deletions tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export FILE_SIZE=$(( floor($fill_mb / $NUMJOBS) ))M

log_must truncate -s ${cache_sz}M $VDEV_CACHE

typeset log_blk_start=$(get_arcstat l2_log_blk_writes)
typeset log_blk_start=$(kstat arcstats.l2_log_blk_writes)

log_must zpool create -f $TESTPOOL $VDEV cache $VDEV_CACHE

Expand All @@ -89,7 +89,7 @@ log_must zpool import -N -d $VDIR $TESTPOOL
# will not be 0 (mentioned also in zfs.4)
# For the purposes of this test we mitigate this by disabling (predictive)
# ZFS prefetches with zfs_prefetch_disable=1.
log_must test $(get_arcstat l2_mru_asize) -eq 0
log_must test $(kstat arcstats.l2_mru_asize) -eq 0

log_must zpool destroy -f $TESTPOOL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ arcstat_quiescence_noecho l2_feeds

typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}')

typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks)
typeset l2_rebuild_log_blk_start=$(kstat arcstats.l2_rebuild_log_blks)

log_must zpool import -d $VDIR $TESTPOOL
arcstat_quiescence_noecho l2_size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ arcstat_quiescence_noecho l2_feeds

typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}')

typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks)
typeset l2_rebuild_log_blk_start=$(kstat arcstats.l2_rebuild_log_blks)

log_must zpool import -d $VDIR $TESTPOOL
log_must eval "echo $PASSPHRASE | zfs mount -l $TESTPOOL/$TESTFS1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ log_must fio $FIO_SCRIPTS/random_reads.fio

log_must zpool export $TESTPOOL

typeset l2_success_start=$(get_arcstat l2_rebuild_success)
typeset l2_success_start=$(kstat arcstats.l2_rebuild_success)

log_must zpool import -d $VDIR $TESTPOOL
log_mustnot test "$(zpool iostat -Hpv $TESTPOOL $VDEV_CACHE | awk '{print $2}')" -gt 80000000

typeset l2_success_end=$(get_arcstat l2_rebuild_success)
typeset l2_success_end=$(kstat arcstats.l2_rebuild_success)

log_mustnot test $l2_success_end -gt $l2_success_start

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ arcstat_quiescence_noecho l2_size
log_must zpool export $TESTPOOL
arcstat_quiescence_noecho l2_feeds

typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks)
typeset l2_rebuild_log_blk_start=$(kstat arcstats.l2_rebuild_log_blks)
typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}')

log_must zpool import -d $VDIR $TESTPOOL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ arcstat_quiescence_noecho l2_size
log_must zpool offline $TESTPOOL $VDEV_CACHE
arcstat_quiescence_noecho l2_size

typeset l2_rebuild_log_blk_start=$(get_arcstat l2_rebuild_log_blks)
typeset l2_rebuild_log_blk_start=$(kstat arcstats.l2_rebuild_log_blks)
typeset l2_dh_log_blk=$(zdb -l $VDEV_CACHE | awk '/log_blk_count/ {print $2}')

log_must zpool online $TESTPOOL $VDEV_CACHE
Expand Down
4 changes: 2 additions & 2 deletions tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ log_must fio $FIO_SCRIPTS/random_reads.fio
export RUNTIME=1
typeset do_once=true
while $do_once || [[ $l2_size1 -le $l2_size2 ]]; do
typeset l2_size1=$(get_arcstat l2_size)
typeset l2_size1=$(kstat arcstats.l2_size)
log_must fio $FIO_SCRIPTS/random_reads.fio
typeset l2_size2=$(get_arcstat l2_size)
typeset l2_size2=$(kstat arcstats.l2_size)
do_once=false
done

Expand Down

0 comments on commit e079b6f

Please sign in to comment.