Blame SOURCES/0704-shared-sleep-config-exclude-zram-devices-from-hibern.patch

17b0f1
From 8fc26bd114d2aa997da261ac7c488d4c25116af3 Mon Sep 17 00:00:00 2001
17b0f1
From: Andrew Jorgensen <ajorgens@amazon.com>
17b0f1
Date: Wed, 25 Jul 2018 08:06:57 -0700
17b0f1
Subject: [PATCH] shared/sleep-config: exclude zram devices from hibernation
17b0f1
 candidates
17b0f1
17b0f1
On a host with sufficiently large zram but with no actual swap, logind will
17b0f1
respond to CanHibernate() with yes. With this patch, it will correctly respond
17b0f1
no, unless there are other swap devices to consider.
17b0f1
17b0f1
(cherry picked from commit 411ae92b407bd7b4549b205ad754bcd0e3dfd81f)
17b0f1
17b0f1
Resolves: #1609816
17b0f1
---
17b0f1
 src/shared/sleep-config.c | 17 ++++++++++++++---
17b0f1
 1 file changed, 14 insertions(+), 3 deletions(-)
17b0f1
17b0f1
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
17b0f1
index 1064fd5cbd..c4334652fc 100644
17b0f1
--- a/src/shared/sleep-config.c
17b0f1
+++ b/src/shared/sleep-config.c
17b0f1
@@ -25,6 +25,7 @@
17b0f1
 #include "sleep-config.h"
17b0f1
 #include "fileio.h"
17b0f1
 #include "log.h"
17b0f1
+#include "path-util.h"
17b0f1
 #include "strv.h"
17b0f1
 #include "util.h"
17b0f1
 
17b0f1
@@ -202,9 +203,19 @@ static int hibernation_partition_size(size_t *size, size_t *used) {
17b0f1
                         continue;
17b0f1
                 }
17b0f1
 
17b0f1
-                if (streq(type, "partition") && endswith(dev, "\\040(deleted)")) {
17b0f1
-                        log_warning("Ignoring deleted swapfile '%s'.", dev);
17b0f1
-                        continue;
17b0f1
+                if (streq(type, "partition")) {
17b0f1
+                        const char *fn;
17b0f1
+
17b0f1
+                        if (endswith(dev, "\\040(deleted)")) {
17b0f1
+                                log_warning("Ignoring deleted swapfile '%s'.", dev);
17b0f1
+                                continue;
17b0f1
+                        }
17b0f1
+
17b0f1
+                        fn = path_startswith(dev, "/dev/");
17b0f1
+                        if (fn && startswith(fn, "zram")) {
17b0f1
+                                log_debug("Ignoring compressed ram swap device '%s'.", dev);
17b0f1
+                                continue;
17b0f1
+                        }
17b0f1
                 }
17b0f1
 
17b0f1
                 *size = size_field;