dryang / rpms / systemd

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