diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib index 5ba94bc6f5e4..0b6c675cdd2c 100644 --- a/tests/zfs-tests/include/libtest.shlib +++ b/tests/zfs-tests/include/libtest.shlib @@ -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 @@ -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 diff --git a/tests/zfs-tests/tests/functional/cache/cache_012_pos.ksh b/tests/zfs-tests/tests/functional/cache/cache_012_pos.ksh index 20498440bea7..b8deafc5b30c 100755 --- a/tests/zfs-tests/tests/functional/cache/cache_012_pos.ksh +++ b/tests/zfs-tests/tests/functional/cache/cache_012_pos.ksh @@ -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 diff --git a/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc.ksh b/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc.ksh index 1d3cbfc79ee6..1eded81101c1 100755 --- a/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc.ksh +++ b/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc.ksh @@ -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" diff --git a/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc_disabled.ksh b/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc_disabled.ksh index c8f4111744eb..b08f8dccc845 100755 --- a/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc_disabled.ksh +++ b/tests/zfs-tests/tests/functional/compression/l2arc_compressed_arc_disabled.ksh @@ -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" diff --git a/tests/zfs-tests/tests/functional/compression/l2arc_encrypted.ksh b/tests/zfs-tests/tests/functional/compression/l2arc_encrypted.ksh index 460c95bb6051..8da3441330a6 100755 --- a/tests/zfs-tests/tests/functional/compression/l2arc_encrypted.ksh +++ b/tests/zfs-tests/tests/functional/compression/l2arc_encrypted.ksh @@ -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" diff --git a/tests/zfs-tests/tests/functional/compression/l2arc_encrypted_no_compressed_arc.ksh b/tests/zfs-tests/tests/functional/compression/l2arc_encrypted_no_compressed_arc.ksh index 2f352e2af5d4..e571016f6e2a 100755 --- a/tests/zfs-tests/tests/functional/compression/l2arc_encrypted_no_compressed_arc.ksh +++ b/tests/zfs-tests/tests/functional/compression/l2arc_encrypted_no_compressed_arc.ksh @@ -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" diff --git a/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh index 69d60ab8bb90..dc6bb9f9a163 100755 --- a/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/l2arc_arcstats_pos.ksh @@ -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 @@ -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 diff --git a/tests/zfs-tests/tests/functional/l2arc/l2arc_l2miss_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/l2arc_l2miss_pos.ksh index c9d5d7ffe1f1..8a9e4fa41b7c 100755 --- a/tests/zfs-tests/tests/functional/l2arc/l2arc_l2miss_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/l2arc_l2miss_pos.ksh @@ -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 @@ -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 diff --git a/tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh index 89ab940334ee..2c5fc6753152 100755 --- a/tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/l2arc_mfuonly_pos.ksh @@ -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 @@ -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 diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh index a9968723c3ca..a999f96971fd 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_001_pos.ksh @@ -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 diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh index 3b893d28da6a..4c6bc2e2e720 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_002_pos.ksh @@ -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" diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh index 14063658e3c5..104d1d484ff2 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_003_neg.ksh @@ -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 diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh index 8a572c26469c..6460b9a0e7a1 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_004_pos.ksh @@ -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 diff --git a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh index 9663437c6597..ce379a566f18 100755 --- a/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh +++ b/tests/zfs-tests/tests/functional/l2arc/persist_l2arc_005_pos.ksh @@ -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 diff --git a/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh b/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh index 62563e0dd4cb..fc7824ec6ce5 100755 --- a/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh +++ b/tests/zfs-tests/tests/functional/trim/trim_l2arc.ksh @@ -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