]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroup: rename cg_unified() → cg_unified_controller()
authorLennart Poettering <lennart@poettering.net>
Fri, 24 Feb 2017 17:00:04 +0000 (18:00 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 24 Feb 2017 17:00:04 +0000 (18:00 +0100)
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
src/core/manager.c
src/core/scope.c
src/core/service.c
src/core/unit.c
src/nspawn/nspawn-cgroup.c
src/nspawn/nspawn.c

index 3bdcf18074baf5e39a4c20522167dedf5bf3bc6e..30a16287e75d3e8165551b22940c96b3e75dcd5c 100644 (file)
@@ -933,7 +933,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) {
@@ -1008,7 +1008,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) {
@@ -1083,7 +1083,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 */
@@ -1134,7 +1134,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 */
@@ -1190,7 +1190,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) {
@@ -2342,17 +2342,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;
 
@@ -2395,7 +2392,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();
@@ -2412,7 +2409,7 @@ int cg_unified(const char *controller) {
 }
 
 int cg_all_unified(void) {
-        return cg_unified(NULL);
+        return cg_unified_controller(NULL);
 }
 
 int cg_hybrid_unified(void) {
index fdc675ccd3c18928d067473f6383b97d581e30e2..a522095d9574ccb6e0ef24f8862f87a305a16579 100644 (file)
@@ -242,7 +242,7 @@ bool cg_ns_supported(void);
 
 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 ea6e10644701f9a73cc2a5c2128605fa2f315a8e..774b832a63c057fdd73a3b4b461bf2454c0818ba 100644 (file)
@@ -1259,7 +1259,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)
@@ -1684,7 +1684,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 */
@@ -1807,7 +1807,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)
@@ -1820,7 +1820,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. */
index 7a09ac1d6e93aa1707a486808167dd244bb669bf..cff38e28deaf4479761532def049f10ed7579b0e 100644 (file)
@@ -776,7 +776,7 @@ static int manager_setup_cgroups_agent(Manager *m) {
         if (!MANAGER_IS_SYSTEM(m))
                 return 0;
 
-        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 unified cgroups hierarchy is used: %m");
         if (r > 0) /* We don't need this anymore on the unified hierarchy */
index af93d577ddda9bed21fecdc923c9ac24e4a76de5..a1d5c1cfd541122bcfbe607009aadd6f484de5ba 100644 (file)
@@ -475,7 +475,7 @@ static void scope_sigchld_event(Unit *u, pid_t pid, int code, int status) {
 
         /* If the PID set is empty now, then let's finish this off
            (On unified we use proper notifications) */
-        if (cg_unified(SYSTEMD_CGROUP_CONTROLLER) == 0 && set_isempty(u->pids))
+        if (cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) == 0 && set_isempty(u->pids))
                 scope_notify_cgroup_empty_event(u);
 }
 
index 3872ea1d9bb96ef999a5b2b8c56349fae5884700..5581ec8b0620020f87352769b4a9d681a7d85f13 100644 (file)
@@ -2938,7 +2938,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
 
         /* If the PID set is empty now, then let's finish this off
            (On unified we use proper notifications) */
-        if (cg_unified(SYSTEMD_CGROUP_CONTROLLER) == 0 && set_isempty(u->pids))
+        if (cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) == 0 && set_isempty(u->pids))
                 service_notify_cgroup_empty_event(u);
 }
 
index 91f49aa210fc7033fa7946596aaba9324fcd5a0c..81a92b88416e6957174e6a096f13184d44090274 100644 (file)
@@ -3897,7 +3897,7 @@ int unit_kill_context(
                          * there we get proper events. Hence rely on
                          * them.*/
 
-                        if (cg_unified(SYSTEMD_CGROUP_CONTROLLER) > 0 ||
+                        if (cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) > 0 ||
                             (detect_container() == 0 && !unit_cgroup_delegate(u)))
                                 wait_for_exit = true;
 
index 3ca067e5bc2116d03f22212f2fc8b3b9493eebf5..d749756437c5f867d121ebd5e4c9b5c7389ffdf2 100644 (file)
@@ -80,7 +80,7 @@ int sync_cgroup(pid_t pid, CGroupUnified unified_requested, uid_t arg_uid_shift)
         const char *fn;
         int r, unified_controller;
 
-        unified_controller = cg_unified(SYSTEMD_CGROUP_CONTROLLER);
+        unified_controller = cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER);
         if (unified_controller < 0)
                 return log_error_errno(unified_controller, "Failed to determine whether the systemd hierarchy is unified: %m");
         if ((unified_controller > 0) == (unified_requested >= CGROUP_UNIFIED_SYSTEMD))
@@ -153,7 +153,7 @@ int create_subcgroup(pid_t pid, CGroupUnified unified_requested) {
         if (unified_requested == CGROUP_UNIFIED_NONE)
                 return 0;
 
-        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 systemd controller is unified: %m");
         if (r == 0)
index 46d4edd4da37d65e2debee0e3d6bf9e390a13361..52cda514ab46b5f9cf9dc230e001908669c01e6c 100644 (file)
@@ -346,7 +346,7 @@ static int detect_unified_cgroup_hierarchy(const char *directory) {
                         arg_unified_cgroup_hierarchy = CGROUP_UNIFIED_ALL;
                 else
                         arg_unified_cgroup_hierarchy = CGROUP_UNIFIED_NONE;
-        } else if (cg_unified(SYSTEMD_CGROUP_CONTROLLER) > 0) {
+        } else if (cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER) > 0) {
                 /* Mixed cgroup hierarchy support was added in 233 */
                 r = systemd_installation_has_version(directory, 233);
                 if (r < 0)