teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

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

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