]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sleep: don't skip resume device with low priority/available space
authorEgor <egor@opensrc.club>
Sun, 3 Oct 2021 00:42:50 +0000 (03:42 +0300)
committerLennart Poettering <lennart@poettering.net>
Mon, 4 Oct 2021 08:23:42 +0000 (10:23 +0200)
this fixes hibernation when there's a higher priority swap preceding
the resume swap in /proc/swaps.

fixes #19486

src/shared/sleep-config.c

index dbaecb3a0f2c981c4b1145b4f329ee3cf5113a33..8ec3d09a58314428a7e4531ae6e2d65613ae4772 100644 (file)
@@ -392,15 +392,17 @@ int find_hibernate_location(HibernateLocation **ret_hibernate_location) {
                 }
 
                 /* prefer resume device or highest priority swap with most remaining space */
-                if (hibernate_location && swap->priority < hibernate_location->swap->priority) {
-                        log_debug("%s: ignoring device with lower priority", swap->device);
-                        continue;
-                }
-                if (hibernate_location &&
-                    (swap->priority == hibernate_location->swap->priority
-                     && swap->size - swap->used < hibernate_location->swap->size - hibernate_location->swap->used)) {
-                        log_debug("%s: ignoring device with lower usable space", swap->device);
-                        continue;
+                if (sys_resume == 0) {
+                        if (hibernate_location && swap->priority < hibernate_location->swap->priority) {
+                                log_debug("%s: ignoring device with lower priority", swap->device);
+                                continue;
+                        }
+                        if (hibernate_location &&
+                            (swap->priority == hibernate_location->swap->priority
+                             && swap->size - swap->used < hibernate_location->swap->size - hibernate_location->swap->used)) {
+                                log_debug("%s: ignoring device with lower usable space", swap->device);
+                                continue;
+                        }
                 }
 
                 dev_t swap_device;