]> git.ipfire.org Git - thirdparty/systemd.git/commit
core: simplify cg_[all_]unified()
authorTejun Heo <htejun@fb.com>
Mon, 21 Nov 2016 19:45:53 +0000 (14:45 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 18 Feb 2017 22:51:13 +0000 (17:51 -0500)
commit415fc41ceaeada2e32639f24f134b1c248b9e43f
tree5e8a3a3af6bfaec96c4653ad36e8090f81d86a30
parentbd15ab41a1347fed8266845f875842d1502e02a6
core: simplify cg_[all_]unified()

cg_[all_]unified() test whether a specific controller or all controllers are on
the unified hierarchy.  While what's being asked is a simple binary question,
the callers must assume that the functions may fail any time, which
unnecessarily complicates their usages.  This complication is unnecessary.
Internally, the test result is cached anyway and there are only a few places
where the test actually needs to be performed.

This patch simplifies cg_[all_]unified().

* cg_[all_]unified() are updated to return bool.  If the result can't be
  decided, assertion failure is triggered.  Error handlings from their callers
  are dropped.

* cg_unified_flush() is updated to calculate the new result synchrnously and
  return whether it succeeded or not.  Places which need to flush the test
  result are updated to test for failure.  This ensures that all the following
  cg_[all_]unified() tests succeed.

* Places which expected possible cg_[all_]unified() failures are updated to
  call and test cg_unified_flush() before calling cg_[all_]unified().  This
  includes functions used while setting up mounts during boot and
  manager_setup_cgroup().
13 files changed:
src/basic/cgroup-util.c
src/basic/cgroup-util.h
src/cgls/cgls.c
src/cgtop/cgtop.c
src/core/cgroup.c
src/core/manager.c
src/core/scope.c
src/core/service.c
src/core/unit.c
src/libsystemd/sd-bus/test-bus-creds.c
src/nspawn/nspawn-cgroup.c
src/nspawn/nspawn-mount.c
src/nspawn/nspawn.c