systemd/5004-disable-session-freeze.patch

54 lines
3.0 KiB
Diff

From: Michal Koutný <mkoutny@suse.com>
Date: Wed, 24 Jul 2024 14:20:17 +0200
Subject: Disable session freeze
Freezing of user.slice is not reliable and it breaks regular suspend/resume
operations for users [1].
Disable the partial (user.slice) freezing (rely on kernel freezing of every
task upon suspend) since the benefit of user.slice freezing does not outweight
the breakage caused by cgroup freezing implementation.
[1] https://github.com/systemd/systemd/issues/33083
---
src/home/homework.c | 7 ++++---
src/sleep/sleep.c | 8 +++++---
2 files changed, 9 insertions(+), 6 deletions(-)
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -603,12 +603,14 @@ static int run(int argc, char *argv[]) {
r = getenv_bool("SYSTEMD_SLEEP_FREEZE_USER_SESSIONS");
if (r < 0 && r != -ENXIO)
log_warning_errno(r, "Cannot parse value of $SYSTEMD_SLEEP_FREEZE_USER_SESSIONS, ignoring.");
+ if (r == -ENXIO)
+ r = 0; /* Do not freeze by default unless requested */
if (r != 0)
(void) unit_freezer_new_freeze(SPECIAL_USER_SLICE, &user_slice_freezer);
else
- log_notice("User sessions remain unfrozen on explicit request ($SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=0).\n"
- "This is not recommended, and might result in unexpected behavior, particularly\n"
- "in suspend-then-hibernate operations or setups with encrypted home directories.");
+ log_notice("User sessions remain unfrozen (add $SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=1 to override),\n"
+ "relying on kernel to perform the freeze.\n"
+ "This is a temporary downstream workaround for https://github.com/systemd/systemd/issues/33083.");
switch (arg_operation) {
--- a/src/home/homework.c
+++ b/src/home/homework.c
@@ -1879,10 +1879,11 @@ static int user_session_freezer(uid_t ui
r = getenv_bool("SYSTEMD_HOME_LOCK_FREEZE_SESSION");
if (r < 0 && r != -ENXIO)
log_warning_errno(r, "Cannot parse value of $SYSTEMD_HOME_LOCK_FREEZE_SESSION, ignoring: %m");
- else if (r == 0) {
+ else if (r == 0 || r == -ENXIO) { /* Do not freeze by default unless requested */
if (freeze_now)
- log_notice("Session remains unfrozen on explicit request ($SYSTEMD_HOME_LOCK_FREEZE_SESSION=0).\n"
- "This is not recommended, and might result in unexpected behavior including data loss!");
+ log_notice("Session remains unfrozen (add $SYSTEMD_HOME_LOCK_FREEZE_SESSION=1 to override).\n"
+ "This is a temporary downstream workaround for https://github.com/systemd/systemd/issues/33083.\n"
+ "Home locking is thus experimental and might result in unexpected behavior including data loss!");
*ret = NULL;
return 0;