daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
Brian Stinson 2593d8
From 069cf14150b55e6580cf1d482709a0e48c36ee84 Mon Sep 17 00:00:00 2001
Brian Stinson 2593d8
From: Andrew Jorgensen <ajorgens@amazon.com>
Brian Stinson 2593d8
Date: Wed, 25 Jul 2018 08:06:57 -0700
Brian Stinson 2593d8
Subject: [PATCH] shared/sleep-config: exclude zram devices from hibernation
Brian Stinson 2593d8
 candidates
Brian Stinson 2593d8
Brian Stinson 2593d8
On a host with sufficiently large zram but with no actual swap, logind will
Brian Stinson 2593d8
respond to CanHibernate() with yes. With this patch, it will correctly respond
Brian Stinson 2593d8
no, unless there are other swap devices to consider.
Brian Stinson 2593d8
Brian Stinson 2593d8
(cherry picked from commit 411ae92b407bd7b4549b205ad754bcd0e3dfd81f)
Brian Stinson 2593d8
Brian Stinson 2593d8
Resolves: #1763617
Brian Stinson 2593d8
---
Brian Stinson 2593d8
 src/shared/sleep-config.c | 16 +++++++++++++---
Brian Stinson 2593d8
 1 file changed, 13 insertions(+), 3 deletions(-)
Brian Stinson 2593d8
Brian Stinson 2593d8
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
Brian Stinson 2593d8
index 9e4ce183d3..a1523e3f21 100644
Brian Stinson 2593d8
--- a/src/shared/sleep-config.c
Brian Stinson 2593d8
+++ b/src/shared/sleep-config.c
Brian Stinson 2593d8
@@ -21,6 +21,7 @@
Brian Stinson 2593d8
 #include "log.h"
Brian Stinson 2593d8
 #include "macro.h"
Brian Stinson 2593d8
 #include "parse-util.h"
Brian Stinson 2593d8
+#include "path-util.h"
Brian Stinson 2593d8
 #include "sleep-config.h"
Brian Stinson 2593d8
 #include "string-util.h"
Brian Stinson 2593d8
 #include "strv.h"
Brian Stinson 2593d8
@@ -201,9 +202,18 @@ int find_hibernate_location(char **device, char **type, size_t *size, size_t *us
Brian Stinson 2593d8
                         continue;
Brian Stinson 2593d8
                 }
Brian Stinson 2593d8
 
Brian Stinson 2593d8
-                if (streq(type_field, "partition") && endswith(dev_field, "\\040(deleted)")) {
Brian Stinson 2593d8
-                        log_warning("Ignoring deleted swapfile '%s'.", dev_field);
Brian Stinson 2593d8
-                        continue;
Brian Stinson 2593d8
+                if (streq(type_field, "partition")) {
Brian Stinson 2593d8
+                        if (endswith(dev_field, "\\040(deleted)")) {
Brian Stinson 2593d8
+                                log_warning("Ignoring deleted swapfile '%s'.", dev_field);
Brian Stinson 2593d8
+                                continue;
Brian Stinson 2593d8
+                        }
Brian Stinson 2593d8
+
Brian Stinson 2593d8
+                        const char *fn;
Brian Stinson 2593d8
+                        fn = path_startswith(dev_field, "/dev/");
Brian Stinson 2593d8
+                        if (fn && startswith(fn, "zram")) {
Brian Stinson 2593d8
+                                log_debug("Ignoring compressed ram swap device '%s'.", dev_field);
Brian Stinson 2593d8
+                                continue;
Brian Stinson 2593d8
+                        }
Brian Stinson 2593d8
                 }
Brian Stinson 2593d8
                 if (device)
Brian Stinson 2593d8
                         *device = TAKE_PTR(dev_field);