]> git.ipfire.org Git - thirdparty/systemd.git/commit
core: make hybrid cgroup unified mode keep compat /sys/fs/cgroup/systemd hierarchy
authorTejun Heo <htejun@fb.com>
Mon, 21 Nov 2016 19:45:53 +0000 (14:45 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 20 Feb 2017 17:28:35 +0000 (12:28 -0500)
commit2977724b09eb997fc84a80517447b5d4a70770c7
tree45fc98bb8093c2349f0467e1868d2e0f1b3948e2
parent2dcb526d7a43cc4ac9493877ceb05810ff56dbae
core: make hybrid cgroup unified mode keep compat /sys/fs/cgroup/systemd hierarchy

Currently the hybrid mode mounts cgroup v2 on /sys/fs/cgroup instead of the v1
name=systemd hierarchy.  While this works fine for systemd itself, it breaks
tools which expect cgroup v1 hierarchy on /sys/fs/cgroup/systemd.

This patch updates the hybrid mode so that it mounts v2 hierarchy on
/sys/fs/cgroup/unified and keeps v1 "name=systemd" hierarchy on
/sys/fs/cgroup/systemd for compatibility.  systemd itself doesn't depend on the
"name=systemd" hierarchy at all.  All operations take place on the v2 hierarchy
as before but the v1 hierarchy is kept in sync so that any tools which expect
it to be there can keep doing so.  This allows systemd to take advantage of
cgroup v2 process management without requiring other tools to be aware of the
hybrid mode.

The hybrid mode is implemented by mapping the special systemd controller to
/sys/fs/cgroup/unified and making the basic cgroup utility operations -
cg_attach(), cg_create(), cg_rmdir() and cg_trim() - also operate on the
/sys/fs/cgroup/systemd hierarchy whenever the cgroup2 hierarchy is updated.

While a bit messy, this will allow dropping complications from using cgroup v1
for process management a lot sooner than otherwise possible which should make
it a net gain in terms of maintainability.

v2: Fixed !cgns breakage reported by @evverx and renamed the unified mount
    point to /sys/fs/cgroup/unified as suggested by @brauner.

v3: chown the compat hierarchy too on delegation.  Suggested by @evverx.

v4: [zj]
- drop the change to default, full "legacy" is still the default.
src/basic/cgroup-util.c
src/basic/cgroup-util.h
src/basic/def.h
src/core/mount-setup.c
src/nspawn/nspawn-mount.c
src/nspawn/nspawn.c