dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

Blame SOURCES/0118-zramctl-make-mm_stat-parser-more-robust.patch

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