From b8e8164f853fcf20adf3fcbf4278a38215bf91c4 Mon Sep 17 00:00:00 2001 From: Alastair Poole Date: Mon, 8 Jun 2020 10:39:43 +0100 Subject: [PATCH] ZFS: Changes. --- src/bin/system/disks.c | 24 ------------------------ src/bin/system/disks.h | 5 ----- src/bin/system/filesystems.c | 25 +++++++++++++++++++++++++ src/bin/system/filesystems.h | 5 +++++ src/bin/ui/ui.c | 3 ++- src/bin/ui/ui_disk.c | 7 +++++++ 6 files changed, 39 insertions(+), 30 deletions(-) diff --git a/src/bin/system/disks.c b/src/bin/system/disks.c index 9f6a683..e278211 100644 --- a/src/bin/system/disks.c +++ b/src/bin/system/disks.c @@ -87,30 +87,6 @@ _cmp_cb(const void *p1, const void *p2) return strcmp(s1, s2); } -Eina_Bool -disk_zfs_mounted_get(void) -{ - Eina_List *disks; - char *path; - Eina_Bool zfs_mounted = EINA_FALSE; - - disks = disks_get(); - EINA_LIST_FREE(disks, path) - { - Filesystem_Info *fs = filesystem_info_get(path); - if (fs) - { - if (fs->type == filesystem_id_by_name("ZFS")) - zfs_mounted = EINA_TRUE; - - filesystem_info_free(fs); - } - free(path); - } - - return zfs_mounted; -} - Eina_List * disks_get(void) { diff --git a/src/bin/system/disks.h b/src/bin/system/disks.h index 58051ec..0a8ff05 100644 --- a/src/bin/system/disks.h +++ b/src/bin/system/disks.h @@ -2,11 +2,6 @@ #define __DISKS_H__ #include "filesystems.h" -#include -#include - -Eina_Bool -disk_zfs_mounted_get(void); char * disk_mount_point_get(const char *path); diff --git a/src/bin/system/filesystems.c b/src/bin/system/filesystems.c index d1c0bf5..80f3773 100644 --- a/src/bin/system/filesystems.c +++ b/src/bin/system/filesystems.c @@ -158,3 +158,28 @@ filesystem_info_free(Filesystem_Info *fs) free(fs); } +Eina_Bool +filesystem_in_use(const char *name) +{ + Eina_List *disks; + char *path; + Eina_Bool fs_mounted = EINA_FALSE; + if (!name) return EINA_FALSE; + + disks = disks_get(); + EINA_LIST_FREE(disks, path) + { + Filesystem_Info *fs = filesystem_info_get(path); + if (fs) + { + if (fs->type == filesystem_id_by_name(name)) + fs_mounted = EINA_TRUE; + + filesystem_info_free(fs); + } + free(path); + } + + return fs_mounted; +} + diff --git a/src/bin/system/filesystems.h b/src/bin/system/filesystems.h index 4924766..95e1c7f 100644 --- a/src/bin/system/filesystems.h +++ b/src/bin/system/filesystems.h @@ -1,6 +1,8 @@ #ifndef __FILESYSTEMS_H__ #define __FILESYSTEMS_H__ +#include + typedef struct { unsigned long long total; unsigned long long used; @@ -25,4 +27,7 @@ filesystem_info_get(const char *path); void filesystem_info_free(Filesystem_Info *fs); +Eina_Bool +filesystem_in_use(const char *name); + #endif diff --git a/src/bin/ui/ui.c b/src/bin/ui/ui.c index 0df3c86..51cb68e 100644 --- a/src/bin/ui/ui.c +++ b/src/bin/ui/ui.c @@ -1684,7 +1684,8 @@ _ui_init(Evas_Object *parent) ui->cpu_times = NULL; ui->cpu_list = NULL; - ui->zfs_mounted = disk_zfs_mounted_get(); + // Only take account of the ZFS ARC if there is an active mount. + ui->zfs_mounted = filesystem_in_use("ZFS"); _ui = NULL; _evisum_config = NULL; diff --git a/src/bin/ui/ui_disk.c b/src/bin/ui/ui_disk.c index 9cc161d..0d70624 100644 --- a/src/bin/ui/ui_disk.c +++ b/src/bin/ui/ui_disk.c @@ -96,6 +96,7 @@ ui_tab_disk_update(Ui *ui) if (!ui->disk_visible) return; + // FIXME elm_box_clear(ui->disk_activity); disks = disks_get(); @@ -104,6 +105,9 @@ ui_tab_disk_update(Ui *ui) Filesystem_Info *fs = filesystem_info_get(path); if (fs) { + // ZFS usage may have changed during application's lifetime. + // Keep track of ZFS mounts else we may report bogus use + // of memory. if (fs->type == filesystem_id_by_name("ZFS")) zfs_mounted = EINA_TRUE; @@ -115,6 +119,9 @@ ui_tab_disk_update(Ui *ui) if (disks) eina_list_free(disks); + // Need to keep track of ZFS mounts. If we have no mounts + // then memory usage should not take into account the ZFS + // ARC memory allocation. if (!zfs_mounted) ui->zfs_mounted = EINA_FALSE; }