]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/mount-setup: if unified hierarchy is not supported, fall back to legacy
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 19 Feb 2017 20:59:21 +0000 (15:59 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 22 Feb 2017 16:52:31 +0000 (11:52 -0500)
We need this to gracefully support older or strangely configured kernels.

v2:
- do not install a callback handler, just embed the right conditions into
  cg_is_*_wanted()

v3:
- fix bug in cg_is_legacy_wanted()

src/basic/cgroup-util.c
src/core/mount-setup.c

index 0b8bda89ea79b1f53b323d5e5232011887917a89..8d60ded5fe20f178278cf2c3b8757444f254e143 100644 (file)
@@ -2429,7 +2429,14 @@ bool cg_is_unified_wanted(void) {
 }
 
 bool cg_is_legacy_wanted(void) {
-        return !cg_is_unified_wanted();
+        /* Check if we have cgroups2 already mounted. */
+        if (cg_unified_flush() >= 0 &&
+            unified_cache == CGROUP_UNIFIED_ALL)
+                return false;
+
+        /* Otherwise, assume that at least partial legacy is wanted,
+         * since cgroups2 should already be mounted at this point. */
+        return true;
 }
 
 bool cg_is_hybrid_wanted(void) {
@@ -2438,11 +2445,6 @@ bool cg_is_hybrid_wanted(void) {
         bool b;
         const bool is_default = DEFAULT_HIERARCHY == CGROUP_UNIFIED_SYSTEMD;
 
-        /* If the unified hierarchy is requested in full, no need to
-         * bother with this. */
-        if (cg_is_unified_wanted())
-                return 0;
-
         /* If the hierarchy is already mounted, then follow whatever
          * was chosen for it. */
         if (cg_unified_flush() >= 0)
index c107aa0a545dc4d2a713d4153fc6fceb71ed72db..7295efbf3148b4082c764c80aaaa270ee246c003 100644 (file)
@@ -96,7 +96,7 @@ static const MountPoint mount_table[] = {
         { "tmpfs",       "/run",                      "tmpfs",      "mode=755",                MS_NOSUID|MS_NODEV|MS_STRICTATIME,
           NULL,          MNT_FATAL|MNT_IN_CONTAINER },
         { "cgroup",      "/sys/fs/cgroup",            "cgroup2",    NULL,                      MS_NOSUID|MS_NOEXEC|MS_NODEV,
-          cg_is_unified_wanted, MNT_FATAL|MNT_IN_CONTAINER },
+          cg_is_unified_wanted, MNT_IN_CONTAINER },
         { "tmpfs",       "/sys/fs/cgroup",            "tmpfs",      "mode=755",                MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME,
           cg_is_legacy_wanted, MNT_FATAL|MNT_IN_CONTAINER },
         { "cgroup",      "/sys/fs/cgroup/unified",    "cgroup2",    NULL,                      MS_NOSUID|MS_NOEXEC|MS_NODEV,