0b4d5a
From 45d093a37b6f8c2ceae9bfd090c5265f35413b46 Mon Sep 17 00:00:00 2001
0b4d5a
From: =?UTF-8?q?Michal=20Sekleta=CC=81r?= <msekleta@redhat.com>
0b4d5a
Date: Tue, 8 Sep 2020 14:51:39 +0200
0b4d5a
Subject: [PATCH] cgroup: freezer action must be NOP when cgroup v2 freezer is
0b4d5a
 not available
0b4d5a
0b4d5a
Low-level cgroup freezer state manipulation is invoked directly from the
0b4d5a
job engine when we are about to execute the job in order to make sure
0b4d5a
the unit is not frozen and job execution is not blocked because of
0b4d5a
that.
0b4d5a
0b4d5a
Currently with cgroup v1 we would needlessly do a bunch of work in the
0b4d5a
function and even falsely update the freezer state. Don't do any of this
0b4d5a
and skip the function silently when v2 freezer is not available.
0b4d5a
0b4d5a
Following bug is fixed by this commit,
0b4d5a
0b4d5a
$ systemd-run --unit foo.service /bin/sleep infinity
0b4d5a
$ systemctl restart foo.service
0b4d5a
$ systemctl show -p FreezerState foo.service
0b4d5a
0b4d5a
Before (cgroup v1, i.e. full "legacy" mode):
0b4d5a
FreezerState=thawing
0b4d5a
0b4d5a
After:
0b4d5a
FreezerState=running
0b4d5a
0b4d5a
(cherry picked from commit 9a1e90aee556b7a30d87553a891a4175ae77ed68)
0b4d5a
0b4d5a
Resolves: #1868831
0b4d5a
---
0b4d5a
 src/core/cgroup.c | 3 +++
0b4d5a
 1 file changed, 3 insertions(+)
0b4d5a
0b4d5a
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
0b4d5a
index e0eb184fd2..f1ce070f9a 100644
0b4d5a
--- a/src/core/cgroup.c
0b4d5a
+++ b/src/core/cgroup.c
0b4d5a
@@ -2936,6 +2936,9 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
0b4d5a
         assert(u);
0b4d5a
         assert(IN_SET(action, FREEZER_FREEZE, FREEZER_THAW));
0b4d5a
 
0b4d5a
+        if (!cg_freezer_supported())
0b4d5a
+                return 0;
0b4d5a
+
0b4d5a
         if (!u->cgroup_realized)
0b4d5a
                 return -EBUSY;
0b4d5a