diff options
author | Ross Williams <ross@ross-williams.net> | 2019-09-03 18:21:33 +0000 |
---|---|---|
committer | Ross Williams <ross@ross-williams.net> | 2019-09-03 18:21:33 +0000 |
commit | e450b586368750e771746ef3e2f5a070962dfd28 (patch) | |
tree | 5501777912872ee233b6c9b60a26dd4906a6b4a7 /zfs | |
parent | ff6914e4ad4b78749bcee5471a33ef206b0a7d03 (diff) |
Refactor openzfs_sysctl_init() and ZfsArcMeter...
openzfs_sysctl_init() now returns void instead of int.
The ZfsArcStats->enabled flag is set inside the init function
now, instead of having to be set from its return value.
Preparation for more flag setting in Compressed ARC commit.
ZfsArcMeter_readStats() added and all Meter->values[] setting
moved to it, eliminating duplicated code in
{darwin,freebsd,linux,solaris}/Platform.c.
Diffstat (limited to 'zfs')
-rw-r--r-- | zfs/ZfsArcMeter.c | 18 | ||||
-rw-r--r-- | zfs/ZfsArcMeter.h | 4 | ||||
-rw-r--r-- | zfs/openzfs_sysctl.c | 6 | ||||
-rw-r--r-- | zfs/openzfs_sysctl.h | 6 |
4 files changed, 28 insertions, 6 deletions
diff --git a/zfs/ZfsArcMeter.c b/zfs/ZfsArcMeter.c index ebd80992..9f7028bc 100644 --- a/zfs/ZfsArcMeter.c +++ b/zfs/ZfsArcMeter.c @@ -6,6 +6,7 @@ in the source distribution for its full text. */ #include "ZfsArcMeter.h" +#include "ZfsArcStats.h" #include "CRT.h" #include "Platform.h" @@ -17,6 +18,8 @@ in the source distribution for its full text. #include <assert.h> /*{ +#include "ZfsArcStats.h" + #include "Meter.h" }*/ @@ -24,6 +27,21 @@ int ZfsArcMeter_attributes[] = { ZFS_MFU, ZFS_MRU, ZFS_ANON, ZFS_HEADER, ZFS_OTHER }; +void ZfsArcMeter_readStats(Meter* this, ZfsArcStats* stats) { + this->total = stats->max; + this->values[0] = stats->MFU; + this->values[1] = stats->MRU; + this->values[2] = stats->anon; + this->values[3] = stats->header; + this->values[4] = stats->other; + + // "Hide" the last value so it can + // only be accessed by index and is not + // displayed by the Bar or Graph style + Meter_setItems(this, 5); + this->values[5] = stats->size; +} + static void ZfsArcMeter_updateValues(Meter* this, char* buffer, int size) { int written; Platform_setZfsArcValues(this); diff --git a/zfs/ZfsArcMeter.h b/zfs/ZfsArcMeter.h index b89be223..c52083df 100644 --- a/zfs/ZfsArcMeter.h +++ b/zfs/ZfsArcMeter.h @@ -9,10 +9,14 @@ Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ +#include "ZfsArcStats.h" + #include "Meter.h" extern int ZfsArcMeter_attributes[]; +void ZfsArcMeter_readStats(Meter* this, ZfsArcStats* stats); + extern MeterClass ZfsArcMeter_class; #endif diff --git a/zfs/openzfs_sysctl.c b/zfs/openzfs_sysctl.c index ce48f233..ceee4d10 100644 --- a/zfs/openzfs_sysctl.c +++ b/zfs/openzfs_sysctl.c @@ -25,13 +25,14 @@ static int MIB_kstat_zfs_misc_arcstats_other_size[5]; #include "zfs/ZfsArcStats.h" }*/ -int openzfs_sysctl_init() { +void openzfs_sysctl_init(ZfsArcStats *stats) { size_t len; unsigned long long int arcSize; len = sizeof(arcSize); if (sysctlbyname("kstat.zfs.misc.arcstats.size", &arcSize, &len, NULL, 0) == 0 && arcSize != 0) { + stats->enabled = 1; len = 5; sysctlnametomib("kstat.zfs.misc.arcstats.size", MIB_kstat_zfs_misc_arcstats_size, &len); sysctlnametomib("kstat.zfs.misc.arcstats.c_max", MIB_kstat_zfs_misc_arcstats_c_max, &len); @@ -40,9 +41,8 @@ int openzfs_sysctl_init() { sysctlnametomib("kstat.zfs.misc.arcstats.anon_size", MIB_kstat_zfs_misc_arcstats_anon_size, &len); sysctlnametomib("kstat.zfs.misc.arcstats.hdr_size", MIB_kstat_zfs_misc_arcstats_hdr_size, &len); sysctlnametomib("kstat.zfs.misc.arcstats.other_size", MIB_kstat_zfs_misc_arcstats_other_size, &len); - return 1; } else { - return 0; + stats->enabled = 0; } } diff --git a/zfs/openzfs_sysctl.h b/zfs/openzfs_sysctl.h index 7c04bd79..6e44ac3b 100644 --- a/zfs/openzfs_sysctl.h +++ b/zfs/openzfs_sysctl.h @@ -1,7 +1,7 @@ /* Do not edit this file. It was automatically generated. */ -#ifndef HEADER_openzfs -#define HEADER_openzfs +#ifndef HEADER_openzfs_sysctl +#define HEADER_openzfs_sysctl /* htop - zfs/openzfs_sysctl.h (C) 2014 Hisham H. Muhammad @@ -11,7 +11,7 @@ in the source distribution for its full text. #include "zfs/ZfsArcStats.h" -int openzfs_sysctl_init(); +void openzfs_sysctl_init(ZfsArcStats *stats); void openzfs_sysctl_updateArcStats(ZfsArcStats *stats); |