|
|
531551 |
From a7f11e525e9dd5abf844ada0ddd0ae74950e2e40 Mon Sep 17 00:00:00 2001
|
|
|
531551 |
From: Karel Zak <kzak@redhat.com>
|
|
|
531551 |
Date: Thu, 30 Mar 2017 12:10:01 +0200
|
|
|
531551 |
Subject: [PATCH] zramctl: make mm_stat parser more robust
|
|
|
531551 |
|
|
|
531551 |
Let's fallback to attribute files if mm_stat file is incomplete. It
|
|
|
531551 |
should not happen, but I have seen RHEL7 kernel where is no
|
|
|
531551 |
num_migrated/pages_compacted attribute...
|
|
|
531551 |
|
|
|
531551 |
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1358755
|
|
|
531551 |
Upstream: http://github.com/karelzak/util-linux/commit/2546d54bd8b0ceac75d6d7e6c483479022d97509
|
|
|
531551 |
Signed-off-by: Karel Zak <kzak@redhat.com>
|
|
|
531551 |
---
|
|
|
531551 |
sys-utils/zramctl.c | 8 ++++++--
|
|
|
531551 |
1 file changed, 6 insertions(+), 2 deletions(-)
|
|
|
531551 |
|
|
|
531551 |
diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c
|
|
|
531551 |
index 853401c..c3112d6 100644
|
|
|
531551 |
--- a/sys-utils/zramctl.c
|
|
|
531551 |
+++ b/sys-utils/zramctl.c
|
|
|
531551 |
@@ -359,8 +359,12 @@ static char *get_mm_stat(struct zram *z, size_t idx, int bytes)
|
|
|
531551 |
str = sysfs_strdup(sysfs, "mm_stat");
|
|
|
531551 |
if (str) {
|
|
|
531551 |
z->mm_stat = strv_split(str, " ");
|
|
|
531551 |
- if (strv_length(z->mm_stat) < ARRAY_SIZE(mm_stat_names))
|
|
|
531551 |
- errx(EXIT_FAILURE, _("Failed to parse mm_stat"));
|
|
|
531551 |
+
|
|
|
531551 |
+ /* make sure kernel provides mm_stat as expected */
|
|
|
531551 |
+ if (strv_length(z->mm_stat) < ARRAY_SIZE(mm_stat_names)) {
|
|
|
531551 |
+ strv_free(z->mm_stat);
|
|
|
531551 |
+ z->mm_stat = NULL;
|
|
|
531551 |
+ }
|
|
|
531551 |
}
|
|
|
531551 |
z->mm_stat_probed = 1;
|
|
|
531551 |
free(str);
|
|
|
531551 |
--
|
|
|
531551 |
2.9.3
|
|
|
531551 |
|