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.
This commit is contained in:
Ross Williams
2019-09-03 18:21:33 +00:00
parent ff6914e4ad
commit e450b58636
10 changed files with 34 additions and 56 deletions

View File

@ -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);