diff options
author | Egor <egor@opensrc.club> | 2021-10-03 03:42:50 +0300 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-10-12 18:05:25 +0200 |
commit | 9561c3f1b87b3ab10d986fbceac1bb01f055f9e5 (patch) | |
tree | 58e72d7c034b72bf7776f08a061c08a2a8d48512 | |
parent | a59bde3c5a4d46bc0589f0b94010cba1b55bbced (diff) | |
download | systemd-9561c3f1b87b3ab10d986fbceac1bb01f055f9e5.tar.gz |
sleep: don't skip resume device with low priority/available space
this fixes hibernation when there's a higher priority swap preceding
the resume swap in /proc/swaps.
fixes #19486
(cherry picked from commit 936a7cb66a0b423e75ceef87f02537067ad17002)
(cherry picked from commit 20c776c5e92201e01d4bfbea4ecbc4df758bcf09)
-rw-r--r-- | src/shared/sleep-config.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index e975049da4..9c8b2f79f5 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -389,15 +389,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; |