aboutsummaryrefslogtreecommitdiffstats
path: root/zfs
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2020-12-07 10:26:01 +0100
committerDaniel Lange <DLange@git.local>2020-12-07 10:26:01 +0100
commit65357c8c46154de4e4eca14075bfe5523bb5fc14 (patch)
tree8f430ee5a0d5de377c4e7c94e47842a27c70d7e8 /zfs
parentf80394a20254938142011855f2954b3f63fe5909 (diff)
downloaddebian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.tar.gz
debian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.tar.bz2
debian_htop-65357c8c46154de4e4eca14075bfe5523bb5fc14.zip
New upstream version 3.0.3upstream/3.0.3
Diffstat (limited to 'zfs')
-rw-r--r--zfs/ZfsArcMeter.c42
-rw-r--r--zfs/ZfsArcMeter.h8
-rw-r--r--zfs/ZfsArcStats.c20
-rw-r--r--zfs/ZfsArcStats.h2
-rw-r--r--zfs/ZfsCompressedArcMeter.c36
-rw-r--r--zfs/ZfsCompressedArcMeter.h8
-rw-r--r--zfs/openzfs_sysctl.c73
-rw-r--r--zfs/openzfs_sysctl.h6
8 files changed, 80 insertions, 115 deletions
diff --git a/zfs/ZfsArcMeter.c b/zfs/ZfsArcMeter.c
index 8bd0f5d..e844d77 100644
--- a/zfs/ZfsArcMeter.c
+++ b/zfs/ZfsArcMeter.c
@@ -1,7 +1,7 @@
/*
htop - ZfsArcMeter.c
(C) 2004-2011 Hisham H. Muhammad
-Released under the GNU GPL, see the COPYING file
+Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
*/
@@ -9,25 +9,16 @@ in the source distribution for its full text.
#include "ZfsArcStats.h"
#include "CRT.h"
+#include "Object.h"
#include "Platform.h"
+#include "RichString.h"
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <sys/param.h>
-#include <assert.h>
-/*{
-#include "ZfsArcStats.h"
-
-#include "Meter.h"
-}*/
-
-int ZfsArcMeter_attributes[] = {
+static const int ZfsArcMeter_attributes[] = {
ZFS_MFU, ZFS_MRU, ZFS_ANON, ZFS_HEADER, ZFS_OTHER
};
-void ZfsArcMeter_readStats(Meter* this, ZfsArcStats* stats) {
+void ZfsArcMeter_readStats(Meter* this, const ZfsArcStats* stats) {
this->total = stats->max;
this->values[0] = stats->MFU;
this->values[1] = stats->MRU;
@@ -38,28 +29,27 @@ void ZfsArcMeter_readStats(Meter* this, ZfsArcStats* stats) {
// "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->curItems = 5;
this->values[5] = stats->size;
}
-static void ZfsArcMeter_updateValues(Meter* this, char* buffer, int size) {
+static void ZfsArcMeter_updateValues(Meter* this, char* buffer, size_t size) {
int written;
Platform_setZfsArcValues(this);
written = Meter_humanUnit(buffer, this->values[5], size);
- buffer += written;
- if ((size -= written) > 0) {
- *buffer++ = '/';
- size--;
- Meter_humanUnit(buffer, this->total, size);
- }
+ METER_BUFFER_CHECK(buffer, size, written);
+
+ METER_BUFFER_APPEND_CHR(buffer, size, '/');
+
+ Meter_humanUnit(buffer, this->total, size);
}
-static void ZfsArcMeter_display(Object* cast, RichString* out) {
- char buffer[50];
- Meter* this = (Meter*)cast;
+static void ZfsArcMeter_display(const Object* cast, RichString* out) {
+ const Meter* this = (const Meter*)cast;
if (this->values[5] > 0) {
+ char buffer[50];
Meter_humanUnit(buffer, this->total, 50);
RichString_append(out, CRT_colors[METER_VALUE], buffer);
Meter_humanUnit(buffer, this->values[5], 50);
@@ -86,7 +76,7 @@ static void ZfsArcMeter_display(Object* cast, RichString* out) {
}
}
-MeterClass ZfsArcMeter_class = {
+const MeterClass ZfsArcMeter_class = {
.super = {
.extends = Class(Meter),
.delete = Meter_delete,
diff --git a/zfs/ZfsArcMeter.h b/zfs/ZfsArcMeter.h
index e6b59d5..52bf784 100644
--- a/zfs/ZfsArcMeter.h
+++ b/zfs/ZfsArcMeter.h
@@ -3,7 +3,7 @@
/*
htop - ZfsArcMeter.h
(C) 2004-2011 Hisham H. Muhammad
-Released under the GNU GPL, see the COPYING file
+Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
*/
@@ -11,10 +11,8 @@ in the source distribution for its full text.
#include "Meter.h"
-extern int ZfsArcMeter_attributes[];
+void ZfsArcMeter_readStats(Meter* this, const ZfsArcStats* stats);
-void ZfsArcMeter_readStats(Meter* this, ZfsArcStats* stats);
-
-extern MeterClass ZfsArcMeter_class;
+extern const MeterClass ZfsArcMeter_class;
#endif
diff --git a/zfs/ZfsArcStats.c b/zfs/ZfsArcStats.c
index bfed07d..bead846 100644
--- a/zfs/ZfsArcStats.c
+++ b/zfs/ZfsArcStats.c
@@ -1,24 +1,10 @@
/*
htop - ZfsArcStats.c
(C) 2014 Hisham H. Muhammad
-Released under the GNU GPL, see the COPYING file
+Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
*/
-/*{
-typedef struct ZfsArcStats_ {
- int enabled;
- int isCompressed;
- unsigned long long int max;
- unsigned long long int size;
- unsigned long long int MFU;
- unsigned long long int MRU;
- unsigned long long int anon;
- unsigned long long int header;
- unsigned long long int other;
- unsigned long long int compressed;
- unsigned long long int uncompressed;
-} ZfsArcStats;
-}*/
+#include "Macros.h"
-static int make_iso_compilers_happy __attribute__((unused));
+static int make_iso_compilers_happy ATTR_UNUSED;
diff --git a/zfs/ZfsArcStats.h b/zfs/ZfsArcStats.h
index 087f3fc..d891dc2 100644
--- a/zfs/ZfsArcStats.h
+++ b/zfs/ZfsArcStats.h
@@ -3,7 +3,7 @@
/*
htop - ZfsArcStats.h
(C) 2014 Hisham H. Muhammad
-Released under the GNU GPL, see the COPYING file
+Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
*/
diff --git a/zfs/ZfsCompressedArcMeter.c b/zfs/ZfsCompressedArcMeter.c
index ac3944d..8766f80 100644
--- a/zfs/ZfsCompressedArcMeter.c
+++ b/zfs/ZfsCompressedArcMeter.c
@@ -1,33 +1,27 @@
/*
htop - ZfsCompressedArcMeter.c
(C) 2004-2011 Hisham H. Muhammad
-Released under the GNU GPL, see the COPYING file
+Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
*/
#include "ZfsCompressedArcMeter.h"
-#include "ZfsArcStats.h"
#include "CRT.h"
+#include "Meter.h"
+#include "Object.h"
#include "Platform.h"
+#include "RichString.h"
+#include "XUtils.h"
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <sys/param.h>
-#include <assert.h>
-
-/*{
-#include "ZfsArcStats.h"
+#include "zfs/ZfsArcStats.h"
-#include "Meter.h"
-}*/
-int ZfsCompressedArcMeter_attributes[] = {
+static const int ZfsCompressedArcMeter_attributes[] = {
ZFS_COMPRESSED
};
-void ZfsCompressedArcMeter_readStats(Meter* this, ZfsArcStats* stats) {
+void ZfsCompressedArcMeter_readStats(Meter* this, const ZfsArcStats* stats) {
if ( stats->isCompressed ) {
this->total = stats->uncompressed;
this->values[0] = stats->compressed;
@@ -38,21 +32,21 @@ void ZfsCompressedArcMeter_readStats(Meter* this, ZfsArcStats* stats) {
}
}
-static void ZfsCompressedArcMeter_printRatioString(Meter* this, char* buffer, int size) {
- xSnprintf(buffer, size, "%.2f:1", this->total/this->values[0]);
+static void ZfsCompressedArcMeter_printRatioString(const Meter* this, char* buffer, size_t size) {
+ xSnprintf(buffer, size, "%.2f:1", this->total / this->values[0]);
}
-static void ZfsCompressedArcMeter_updateValues(Meter* this, char* buffer, int size) {
+static void ZfsCompressedArcMeter_updateValues(Meter* this, char* buffer, size_t size) {
Platform_setZfsCompressedArcValues(this);
ZfsCompressedArcMeter_printRatioString(this, buffer, size);
}
-static void ZfsCompressedArcMeter_display(Object* cast, RichString* out) {
- char buffer[50];
- Meter* this = (Meter*)cast;
+static void ZfsCompressedArcMeter_display(const Object* cast, RichString* out) {
+ const Meter* this = (const Meter*)cast;
if (this->values[0] > 0) {
+ char buffer[50];
Meter_humanUnit(buffer, this->total, 50);
RichString_append(out, CRT_colors[METER_VALUE], buffer);
RichString_append(out, CRT_colors[METER_TEXT], " Uncompressed, ");
@@ -68,7 +62,7 @@ static void ZfsCompressedArcMeter_display(Object* cast, RichString* out) {
}
}
-MeterClass ZfsCompressedArcMeter_class = {
+const MeterClass ZfsCompressedArcMeter_class = {
.super = {
.extends = Class(Meter),
.delete = Meter_delete,
diff --git a/zfs/ZfsCompressedArcMeter.h b/zfs/ZfsCompressedArcMeter.h
index 8e64493..025a9dd 100644
--- a/zfs/ZfsCompressedArcMeter.h
+++ b/zfs/ZfsCompressedArcMeter.h
@@ -3,7 +3,7 @@
/*
htop - ZfsCompressedArcMeter.h
(C) 2004-2011 Hisham H. Muhammad
-Released under the GNU GPL, see the COPYING file
+Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
*/
@@ -11,10 +11,8 @@ in the source distribution for its full text.
#include "Meter.h"
-extern int ZfsCompressedArcMeter_attributes[];
+void ZfsCompressedArcMeter_readStats(Meter* this, const ZfsArcStats* stats);
-void ZfsCompressedArcMeter_readStats(Meter* this, ZfsArcStats* stats);
-
-extern MeterClass ZfsCompressedArcMeter_class;
+extern const MeterClass ZfsCompressedArcMeter_class;
#endif
diff --git a/zfs/openzfs_sysctl.c b/zfs/openzfs_sysctl.c
index c1ab223..fd00d61 100644
--- a/zfs/openzfs_sysctl.c
+++ b/zfs/openzfs_sysctl.c
@@ -1,17 +1,18 @@
/*
htop - zfs/openzfs_sysctl.c
(C) 2014 Hisham H. Muhammad
-Released under the GNU GPL, see the COPYING file
+Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
*/
#include "zfs/openzfs_sysctl.h"
-#include "zfs/ZfsArcStats.h"
-#include <unistd.h>
#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/sysctl.h>
+#include <sys/types.h> // IWYU pragma: keep
+#include <sys/sysctl.h> // needs <sys/types.h> 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];
@@ -23,76 +24,74 @@ 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];
-/*{
-#include "zfs/ZfsArcStats.h"
-}*/
-
-void openzfs_sysctl_init(ZfsArcStats *stats) {
+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;
- }
+ 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) {
+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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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
index adb4b24..b49128e 100644
--- a/zfs/openzfs_sysctl.h
+++ b/zfs/openzfs_sysctl.h
@@ -3,14 +3,14 @@
/*
htop - zfs/openzfs_sysctl.h
(C) 2014 Hisham H. Muhammad
-Released under the GNU GPL, see the COPYING file
+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_init(ZfsArcStats* stats);
-void openzfs_sysctl_updateArcStats(ZfsArcStats *stats);
+void openzfs_sysctl_updateArcStats(ZfsArcStats* stats);
#endif

© 2014-2024 Faster IT GmbH | imprint | privacy policy