Make dbufstat work on FreeBSD

With procfs_list kstats implemented for FreeBSD, dbufs are now exposed
as kstat.zfs.misc.dbufs.

On FreeBSD, dbufstats can use the sysctl instead of procfs when no
input file has been given.

Enable the dbufstats tests on FreeBSD.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #11008
This commit is contained in:
Ryan Moeller
2020-10-08 12:40:23 -04:00
committed by Brian Behlendorf
parent 718d20ed93
commit 25e44a17ff
7 changed files with 56 additions and 16 deletions
+22 -4
View File
@@ -4154,18 +4154,36 @@ 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)
typeset zfs_kstat="/proc/spl/kstat/zfs/$stat"
[[ -f "$zfs_kstat" ]] || return 1
cat $zfs_kstat
;;
*)
false
;;
esac
}
function get_arcstat # stat
{
typeset stat=$1
case $(uname) in
FreeBSD)
sysctl -n kstat.zfs.misc.arcstats.$stat
kstat arcstats.$stat
;;
Linux)
typeset zfs_arcstats="/proc/spl/kstat/zfs/arcstats"
[[ -f "$zfs_arcstats" ]] || return 1
grep $stat $zfs_arcstats | awk '{print $3}'
kstat arcstats | awk "/$stat/ { print \$3 }"
;;
*)
false