]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroup: freezer action must be NOP when cgroup v2 freezer is not available
authorMichal Sekletár <msekleta@redhat.com>
Tue, 8 Sep 2020 12:51:39 +0000 (14:51 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 8 Sep 2020 17:54:13 +0000 (19:54 +0200)
Low-level cgroup freezer state manipulation is invoked directly from the
job engine when we are about to execute the job in order to make sure
the unit is not frozen and job execution is not blocked because of
that.

Currently with cgroup v1 we would needlessly do a bunch of work in the
function and even falsely update the freezer state. Don't do any of this
and skip the function silently when v2 freezer is not available.

Following bug is fixed by this commit,

$ systemd-run --unit foo.service /bin/sleep infinity
$ systemctl restart foo.service
$ systemctl show -p FreezerState foo.service

Before (cgroup v1, i.e. full "legacy" mode):
FreezerState=thawing

After:
FreezerState=running

src/core/cgroup.c

index 6af08e78e6c23a6dd003b0a7eb7596b51595370f..962f821925ce9bb1f2059b924fddbd00a7a822a9 100644 (file)
@@ -3602,6 +3602,9 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
         assert(u);
         assert(IN_SET(action, FREEZER_FREEZE, FREEZER_THAW));
 
+        if (!cg_freezer_supported())
+                return 0;
+
         if (!u->cgroup_realized)
                 return -EBUSY;