chiark / gitweb /
cgroup: rename cg_unified() → cg_unified_controller()
authorLennart Poettering <lennart@poettering.net>
Fri, 24 Feb 2017 17:00:04 +0000 (18:00 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 17 Jul 2017 15:58:36 +0000 (17:58 +0200)
cg_unified() is a bit generic a name, let's make clear that it checks
whether a specified controller is in unified mode.

src/basic/cgroup-util.c
src/basic/cgroup-util.h
src/core/cgroup.c

index 8cd064f0b53bea2f59d9e944f96b7e08dbf363d1..a0947b8c5851e20508e07ceecdc8a05d14ba0e22 100644 (file)
@@ -940,7 +940,7 @@ int cg_set_task_access(
         if (r < 0)
                 return r;
 
-        r = cg_unified(controller);
+        r = cg_unified_controller(controller);
         if (r < 0)
                 return r;
         if (r == 0) {
@@ -1016,7 +1016,7 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **path) {
         } else
                 controller = SYSTEMD_CGROUP_CONTROLLER;
 
-        unified = cg_unified(controller);
+        unified = cg_unified_controller(controller);
         if (unified < 0)
                 return unified;
         if (unified == 0) {
@@ -1094,7 +1094,7 @@ int cg_install_release_agent(const char *controller, const char *agent) {
 
         assert(agent);
 
-        r = cg_unified(controller);
+        r = cg_unified_controller(controller);
         if (r < 0)
                 return r;
         if (r > 0) /* doesn't apply to unified hierarchy */
@@ -1145,7 +1145,7 @@ int cg_uninstall_release_agent(const char *controller) {
         _cleanup_free_ char *fs = NULL;
         int r;
 
-        r = cg_unified(controller);
+        r = cg_unified_controller(controller);
         if (r < 0)
                 return r;
         if (r > 0) /* Doesn't apply to unified hierarchy */
@@ -1201,7 +1201,7 @@ int cg_is_empty_recursive(const char *controller, const char *path) {
         if (controller && (isempty(path) || path_equal(path, "/")))
                 return false;
 
-        r = cg_unified(controller);
+        r = cg_unified_controller(controller);
         if (r < 0)
                 return r;
         if (r > 0) {
@@ -2398,17 +2398,14 @@ int cg_kernel_controllers(Set *controllers) {
 
 static thread_local CGroupUnified unified_cache = CGROUP_UNIFIED_UNKNOWN;
 
-/* The hybrid mode was initially implemented in v232 and simply mounted
- * cgroup v2 on /sys/fs/cgroup/systemd.  This unfortunately broke other
- * tools (such as docker) which expected the v1 "name=systemd" hierarchy
- * on /sys/fs/cgroup/systemd.  From v233 and on, the hybrid mode mountnbs
- * v2 on /sys/fs/cgroup/unified and maintains "name=systemd" hierarchy
- * on /sys/fs/cgroup/systemd for compatibility with other tools.
+/* The hybrid mode was initially implemented in v232 and simply mounted cgroup v2 on /sys/fs/cgroup/systemd.  This
+ * unfortunately broke other tools (such as docker) which expected the v1 "name=systemd" hierarchy on
+ * /sys/fs/cgroup/systemd.  From v233 and on, the hybrid mode mountnbs v2 on /sys/fs/cgroup/unified and maintains
+ * "name=systemd" hierarchy on /sys/fs/cgroup/systemd for compatibility with other tools.
  *
- * To keep live upgrade working, we detect and support v232 layout.  When
- * v232 layout is detected, to keep cgroup v2 process management but
- * disable the compat dual layout, we return %true on
- * cg_unified(SYSTEMD_CGROUP_CONTROLLER) and %false on cg_hybrid_unified().
+ * To keep live upgrade working, we detect and support v232 layout.  When v232 layout is detected, to keep cgroup v2
+ * process management but disable the compat dual layout, we return %true on
+ * cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) and %false on cg_hybrid_unified().
  */
 static thread_local bool unified_systemd_v232;
 
@@ -2460,7 +2457,7 @@ static int cg_update_unified(void) {
         return 0;
 }
 
-int cg_unified(const char *controller) {
+int cg_unified_controller(const char *controller) {
         int r;
 
         r = cg_update_unified();
@@ -2477,7 +2474,7 @@ int cg_unified(const char *controller) {
 }
 
 int cg_all_unified(void) {
-        return cg_unified(NULL);
+        return cg_unified_controller(NULL);
 }
 
 #if 0 /// UNNEEDED by elogind
index 942f482288dc4b3d19ac35ba8f3b3b60b9485a3a..d8b6ef3dca4e838c38f6bfb3068de2ca33685ec3 100644 (file)
@@ -256,7 +256,7 @@ bool cg_ns_supported(void);
 #if 0 /// UNNEEDED by elogind
 int cg_all_unified(void);
 int cg_hybrid_unified(void);
-int cg_unified(const char *controller);
+int cg_unified_controller(const char *controller);
 int cg_unified_flush(void);
 
 bool cg_is_unified_wanted(void);
index bc5ff23a10c704e249a396e47c9051b7bad2e632..bda1d53499ddde46fa83820222484f9ed3635e88 100644 (file)
@@ -1261,7 +1261,7 @@ int unit_watch_cgroup(Unit *u) {
                 return 0;
 
         /* Only applies to the unified hierarchy */
-        r = cg_unified(SYSTEMD_CGROUP_CONTROLLER);
+        r = cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER);
         if (r < 0)
                 return log_error_errno(r, "Failed to determine whether the name=systemd hierarchy is unified: %m");
         if (r == 0)
@@ -1686,7 +1686,7 @@ int unit_watch_all_pids(Unit *u) {
         if (!u->cgroup_path)
                 return -ENOENT;
 
-        r = cg_unified(SYSTEMD_CGROUP_CONTROLLER);
+        r = cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER);
         if (r < 0)
                 return r;
         if (r > 0) /* On unified we can use proper notifications */
@@ -1814,7 +1814,7 @@ int manager_setup_cgroup(Manager *m) {
         if (r > 0)
                 log_debug("Unified cgroup hierarchy is located at %s.", path);
         else {
-                r = cg_unified(SYSTEMD_CGROUP_CONTROLLER);
+                r = cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER);
                 if (r < 0)
                         return log_error_errno(r, "Failed to determine whether systemd's own controller is in unified mode: %m");
                 if (r > 0)
@@ -1827,7 +1827,7 @@ int manager_setup_cgroup(Manager *m) {
                 const char *scope_path;
 
                 /* 3. Install agent */
-                if (cg_unified(SYSTEMD_CGROUP_CONTROLLER) > 0) {
+                if (cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) > 0) {
 
                         /* In the unified hierarchy we can get
                          * cgroup empty notifications via inotify. */