From 69f439eff387a6ecb52734e400b297a3c85f2285 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Tue, 21 Sep 2021 08:35:19 +0200 Subject: New upstream version 3.1.0 --- zfs/ZfsArcMeter.c | 13 ++++-- zfs/ZfsArcMeter.h | 3 +- zfs/ZfsArcStats.c | 10 ----- zfs/ZfsCompressedArcMeter.c | 25 +++++++----- zfs/ZfsCompressedArcMeter.h | 3 +- zfs/openzfs_sysctl.c | 98 --------------------------------------------- zfs/openzfs_sysctl.h | 16 -------- 7 files changed, 29 insertions(+), 139 deletions(-) delete mode 100644 zfs/ZfsArcStats.c delete mode 100644 zfs/openzfs_sysctl.c delete mode 100644 zfs/openzfs_sysctl.h (limited to 'zfs') diff --git a/zfs/ZfsArcMeter.c b/zfs/ZfsArcMeter.c index 91dfc71..7653a35 100644 --- a/zfs/ZfsArcMeter.c +++ b/zfs/ZfsArcMeter.c @@ -5,14 +5,17 @@ Released under the GNU GPLv2, see the COPYING file in the source distribution for its full text. */ -#include "ZfsArcMeter.h" -#include "ZfsArcStats.h" +#include "zfs/ZfsArcMeter.h" + +#include #include "CRT.h" #include "Object.h" #include "Platform.h" #include "RichString.h" +#include "zfs/ZfsArcStats.h" + static const int ZfsArcMeter_attributes[] = { ZFS_MFU, ZFS_MRU, ZFS_ANON, ZFS_HEADER, ZFS_OTHER @@ -33,7 +36,9 @@ void ZfsArcMeter_readStats(Meter* this, const ZfsArcStats* stats) { this->values[5] = stats->size; } -static void ZfsArcMeter_updateValues(Meter* this, char* buffer, size_t size) { +static void ZfsArcMeter_updateValues(Meter* this) { + char* buffer = this->txtBuffer; + size_t size = sizeof(this->txtBuffer); int written; Platform_setZfsArcValues(this); @@ -72,7 +77,7 @@ static void ZfsArcMeter_display(const Object* cast, RichString* out) { RichString_appendAscii(out, CRT_colors[ZFS_OTHER], buffer); } else { RichString_writeAscii(out, CRT_colors[METER_TEXT], " "); - RichString_appendAscii(out, CRT_colors[FAILED_SEARCH], "Unavailable"); + RichString_appendAscii(out, CRT_colors[FAILED_READ], "Unavailable"); } } diff --git a/zfs/ZfsArcMeter.h b/zfs/ZfsArcMeter.h index 52bf784..19a0454 100644 --- a/zfs/ZfsArcMeter.h +++ b/zfs/ZfsArcMeter.h @@ -7,10 +7,11 @@ Released under the GNU GPLv2, see the COPYING file in the source distribution for its full text. */ -#include "ZfsArcStats.h" +#include "zfs/ZfsArcStats.h" #include "Meter.h" + void ZfsArcMeter_readStats(Meter* this, const ZfsArcStats* stats); extern const MeterClass ZfsArcMeter_class; diff --git a/zfs/ZfsArcStats.c b/zfs/ZfsArcStats.c deleted file mode 100644 index bead846..0000000 --- a/zfs/ZfsArcStats.c +++ /dev/null @@ -1,10 +0,0 @@ -/* -htop - ZfsArcStats.c -(C) 2014 Hisham H. Muhammad -Released under the GNU GPLv2, see the COPYING file -in the source distribution for its full text. -*/ - -#include "Macros.h" - -static int make_iso_compilers_happy ATTR_UNUSED; diff --git a/zfs/ZfsCompressedArcMeter.c b/zfs/ZfsCompressedArcMeter.c index 92d82e9..29ac3c4 100644 --- a/zfs/ZfsCompressedArcMeter.c +++ b/zfs/ZfsCompressedArcMeter.c @@ -5,7 +5,9 @@ Released under the GNU GPLv2, see the COPYING file in the source distribution for its full text. */ -#include "ZfsCompressedArcMeter.h" +#include "zfs/ZfsCompressedArcMeter.h" + +#include #include "CRT.h" #include "Meter.h" @@ -13,7 +15,6 @@ in the source distribution for its full text. #include "Platform.h" #include "RichString.h" #include "XUtils.h" - #include "zfs/ZfsArcStats.h" @@ -32,14 +33,18 @@ void ZfsCompressedArcMeter_readStats(Meter* this, const ZfsArcStats* stats) { } } -static void ZfsCompressedArcMeter_printRatioString(const Meter* this, char* buffer, size_t size) { - xSnprintf(buffer, size, "%.2f:1", this->total / this->values[0]); +static int ZfsCompressedArcMeter_printRatioString(const Meter* this, char* buffer, size_t size) { + if (this->values[0] > 0) { + return xSnprintf(buffer, size, "%.2f:1", this->total / this->values[0]); + } + + return xSnprintf(buffer, size, "N/A"); } -static void ZfsCompressedArcMeter_updateValues(Meter* this, char* buffer, size_t size) { +static void ZfsCompressedArcMeter_updateValues(Meter* this) { Platform_setZfsCompressedArcValues(this); - ZfsCompressedArcMeter_printRatioString(this, buffer, size); + ZfsCompressedArcMeter_printRatioString(this, this->txtBuffer, sizeof(this->txtBuffer)); } static void ZfsCompressedArcMeter_display(const Object* cast, RichString* out) { @@ -47,18 +52,20 @@ static void ZfsCompressedArcMeter_display(const Object* cast, RichString* out) { if (this->values[0] > 0) { char buffer[50]; + int len; + Meter_humanUnit(buffer, this->total, sizeof(buffer)); RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); RichString_appendAscii(out, CRT_colors[METER_TEXT], " Uncompressed, "); Meter_humanUnit(buffer, this->values[0], sizeof(buffer)); RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); RichString_appendAscii(out, CRT_colors[METER_TEXT], " Compressed, "); - ZfsCompressedArcMeter_printRatioString(this, buffer, sizeof(buffer)); - RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); + len = ZfsCompressedArcMeter_printRatioString(this, buffer, sizeof(buffer)); + RichString_appendnAscii(out, CRT_colors[ZFS_RATIO], buffer, len); RichString_appendAscii(out, CRT_colors[METER_TEXT], " Ratio"); } else { RichString_writeAscii(out, CRT_colors[METER_TEXT], " "); - RichString_appendAscii(out, CRT_colors[FAILED_SEARCH], "Compression Unavailable"); + RichString_appendAscii(out, CRT_colors[FAILED_READ], "Compression Unavailable"); } } diff --git a/zfs/ZfsCompressedArcMeter.h b/zfs/ZfsCompressedArcMeter.h index 025a9dd..9a53430 100644 --- a/zfs/ZfsCompressedArcMeter.h +++ b/zfs/ZfsCompressedArcMeter.h @@ -7,10 +7,11 @@ Released under the GNU GPLv2, see the COPYING file in the source distribution for its full text. */ -#include "ZfsArcStats.h" +#include "zfs/ZfsArcStats.h" #include "Meter.h" + void ZfsCompressedArcMeter_readStats(Meter* this, const ZfsArcStats* stats); extern const MeterClass ZfsCompressedArcMeter_class; diff --git a/zfs/openzfs_sysctl.c b/zfs/openzfs_sysctl.c deleted file mode 100644 index fd00d61..0000000 --- a/zfs/openzfs_sysctl.c +++ /dev/null @@ -1,98 +0,0 @@ -/* -htop - zfs/openzfs_sysctl.c -(C) 2014 Hisham H. Muhammad -Released under the GNU GPLv2, see the COPYING file -in the source distribution for its full text. -*/ - -#include "zfs/openzfs_sysctl.h" - -#include -#include // IWYU pragma: keep -#include // needs for u_int with gcc - -#include "zfs/ZfsArcStats.h" - - -static int MIB_kstat_zfs_misc_arcstats_size[5]; -static int MIB_kstat_zfs_misc_arcstats_c_max[5]; -static int MIB_kstat_zfs_misc_arcstats_mfu_size[5]; -static int MIB_kstat_zfs_misc_arcstats_mru_size[5]; -static int MIB_kstat_zfs_misc_arcstats_anon_size[5]; -static int MIB_kstat_zfs_misc_arcstats_hdr_size[5]; -static int MIB_kstat_zfs_misc_arcstats_other_size[5]; -static int MIB_kstat_zfs_misc_arcstats_compressed_size[5]; -static int MIB_kstat_zfs_misc_arcstats_uncompressed_size[5]; - -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); - sysctlnametomib("kstat.zfs.misc.arcstats.mfu_size", MIB_kstat_zfs_misc_arcstats_mfu_size, &len); - sysctlnametomib("kstat.zfs.misc.arcstats.mru_size", MIB_kstat_zfs_misc_arcstats_mru_size, &len); - 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); - - if (sysctlnametomib("kstat.zfs.misc.arcstats.compressed_size", MIB_kstat_zfs_misc_arcstats_compressed_size, &len) == 0) { - stats->isCompressed = 1; - sysctlnametomib("kstat.zfs.misc.arcstats.uncompressed_size", MIB_kstat_zfs_misc_arcstats_uncompressed_size, &len); - } else { - stats->isCompressed = 0; - } - } else { - stats->enabled = 0; - } -} - -void openzfs_sysctl_updateArcStats(ZfsArcStats* stats) { - size_t len; - - if (stats->enabled) { - len = sizeof(stats->size); - sysctl(MIB_kstat_zfs_misc_arcstats_size, 5, &(stats->size), &len, NULL, 0); - stats->size /= 1024; - - len = sizeof(stats->max); - sysctl(MIB_kstat_zfs_misc_arcstats_c_max, 5, &(stats->max), &len, NULL, 0); - stats->max /= 1024; - - len = sizeof(stats->MFU); - sysctl(MIB_kstat_zfs_misc_arcstats_mfu_size, 5, &(stats->MFU), &len, NULL, 0); - stats->MFU /= 1024; - - len = sizeof(stats->MRU); - sysctl(MIB_kstat_zfs_misc_arcstats_mru_size, 5, &(stats->MRU), &len, NULL, 0); - stats->MRU /= 1024; - - len = sizeof(stats->anon); - sysctl(MIB_kstat_zfs_misc_arcstats_anon_size, 5, &(stats->anon), &len, NULL, 0); - stats->anon /= 1024; - - len = sizeof(stats->header); - sysctl(MIB_kstat_zfs_misc_arcstats_hdr_size, 5, &(stats->header), &len, NULL, 0); - stats->header /= 1024; - - len = sizeof(stats->other); - sysctl(MIB_kstat_zfs_misc_arcstats_other_size, 5, &(stats->other), &len, NULL, 0); - stats->other /= 1024; - - if (stats->isCompressed) { - len = sizeof(stats->compressed); - sysctl(MIB_kstat_zfs_misc_arcstats_compressed_size, 5, &(stats->compressed), &len, NULL, 0); - stats->compressed /= 1024; - - len = sizeof(stats->uncompressed); - sysctl(MIB_kstat_zfs_misc_arcstats_uncompressed_size, 5, &(stats->uncompressed), &len, NULL, 0); - stats->uncompressed /= 1024; - } - } -} diff --git a/zfs/openzfs_sysctl.h b/zfs/openzfs_sysctl.h deleted file mode 100644 index b49128e..0000000 --- a/zfs/openzfs_sysctl.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef HEADER_openzfs_sysctl -#define HEADER_openzfs_sysctl -/* -htop - zfs/openzfs_sysctl.h -(C) 2014 Hisham H. Muhammad -Released under the GNU GPLv2, see the COPYING file -in the source distribution for its full text. -*/ - -#include "zfs/ZfsArcStats.h" - -void openzfs_sysctl_init(ZfsArcStats* stats); - -void openzfs_sysctl_updateArcStats(ZfsArcStats* stats); - -#endif -- cgit v1.2.3