mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
ZTS: reimplement kstat helper function
The old kstat helper function was barely used, I suspect in part because it was very limited in the kinds of kstats it could gather. This adds new functions to replace it, for each kind of thing that can have stats: global, pool and dataset. There's options in there to get a single stat value, or all values within a group. Most importantly, the interface is the same for both platforms. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Signed-off-by: Rob Norris <rob.norris@klarasystems.com> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Tony Hutter <hutter2@llnl.gov>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
# Copyright (c) 2017, Datto Inc. All rights reserved.
|
||||
# Copyright (c) 2017, Open-E Inc. All rights reserved.
|
||||
# Copyright (c) 2021, The FreeBSD Foundation.
|
||||
# Copyright (c) 2025, Klara, Inc.
|
||||
# Use is subject to license terms.
|
||||
#
|
||||
|
||||
@@ -37,6 +38,7 @@
|
||||
. ${STF_SUITE}/include/math.shlib
|
||||
. ${STF_SUITE}/include/blkdev.shlib
|
||||
|
||||
|
||||
# On AlmaLinux 9 we will see $PWD = '.' instead of the full path. This causes
|
||||
# some tests to fail. Fix it up here.
|
||||
if [ "$PWD" = "." ] ; then
|
||||
@@ -3662,24 +3664,6 @@ function ls_xattr # path
|
||||
esac
|
||||
}
|
||||
|
||||
function kstat # stat flags?
|
||||
{
|
||||
typeset stat=$1
|
||||
typeset flags=${2-"-n"}
|
||||
|
||||
case "$UNAME" in
|
||||
FreeBSD)
|
||||
sysctl $flags kstat.zfs.misc.$stat
|
||||
;;
|
||||
Linux)
|
||||
cat "/proc/spl/kstat/zfs/$stat" 2>/dev/null
|
||||
;;
|
||||
*)
|
||||
false
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function get_arcstat # stat
|
||||
{
|
||||
typeset stat=$1
|
||||
@@ -3916,3 +3900,5 @@ function pop_coredump_pattern
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
. ${STF_SUITE}/include/kstat.shlib
|
||||
|
||||
Reference in New Issue
Block a user