]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroup: Cleanup function usage 15662/head
authorMichal Koutný <mkoutny@suse.com>
Fri, 1 May 2020 12:00:42 +0000 (14:00 +0200)
committerMichal Koutný <mkoutny@suse.com>
Wed, 19 Aug 2020 09:41:53 +0000 (11:41 +0200)
Some masks shouldn't be needed externally, so keep their functions in
the module (others would fit there too but they're used in tests) to
think twice if something would depend on them.

Drop unused function cg_attach_many_everywhere.

Use cgroup_realized instead of cgroup_path when we actually ask for
realized.

This should not cause any functional changes.

src/core/cgroup.c
src/core/cgroup.h
src/shared/cgroup-setup.c
src/shared/cgroup-setup.h

index 860f36052b74e58cc8758b9d230c4a2f3f1947e3..a6a9e0c7d4a9aa9afcf5ef09de97bff5b309d48b 100644 (file)
@@ -1495,6 +1495,14 @@ CGroupMask unit_get_delegate_mask(Unit *u) {
         return CGROUP_MASK_EXTEND_JOINED(c->delegate_controllers);
 }
 
+static CGroupMask unit_get_subtree_mask(Unit *u) {
+
+        /* Returns the mask of this subtree, meaning of the group
+         * itself and its children. */
+
+        return unit_get_own_mask(u) | unit_get_members_mask(u);
+}
+
 CGroupMask unit_get_members_mask(Unit *u) {
         assert(u);
 
@@ -1532,7 +1540,7 @@ CGroupMask unit_get_siblings_mask(Unit *u) {
         return unit_get_subtree_mask(u); /* we are the top-level slice */
 }
 
-CGroupMask unit_get_disable_mask(Unit *u) {
+static CGroupMask unit_get_disable_mask(Unit *u) {
         CGroupContext *c;
 
         c = unit_get_cgroup_context(u);
@@ -1557,14 +1565,6 @@ CGroupMask unit_get_ancestor_disable_mask(Unit *u) {
         return mask;
 }
 
-CGroupMask unit_get_subtree_mask(Unit *u) {
-
-        /* Returns the mask of this subtree, meaning of the group
-         * itself and its children. */
-
-        return unit_get_own_mask(u) | unit_get_members_mask(u);
-}
-
 CGroupMask unit_get_target_mask(Unit *u) {
         CGroupMask mask;
 
@@ -2177,7 +2177,7 @@ static int unit_realize_cgroup_now_disable(Unit *u, ManagerState state) {
                 /* The cgroup for this unit might not actually be fully
                  * realised yet, in which case it isn't holding any controllers
                  * open anyway. */
-                if (!m->cgroup_path)
+                if (!m->cgroup_realized)
                         continue;
 
                 /* We must disable those below us first in order to release the
index be9632d8b6600d196dcbc08947dc47edcc86b8ad..9ac5c8bfc0b993a0a9567335eceeff777c2ce1e4 100644 (file)
@@ -203,8 +203,6 @@ CGroupMask unit_get_own_mask(Unit *u);
 CGroupMask unit_get_delegate_mask(Unit *u);
 CGroupMask unit_get_members_mask(Unit *u);
 CGroupMask unit_get_siblings_mask(Unit *u);
-CGroupMask unit_get_subtree_mask(Unit *u);
-CGroupMask unit_get_disable_mask(Unit *u);
 CGroupMask unit_get_ancestor_disable_mask(Unit *u);
 
 CGroupMask unit_get_target_mask(Unit *u);
index cd2ba6149e3f5a583d1eb7274d1c606b5f49de24..856e77629601bf08e382c167d633cda2d2ec49e4 100644 (file)
@@ -655,23 +655,6 @@ int cg_attach_everywhere(CGroupMask supported, const char *path, pid_t pid, cg_m
         return 0;
 }
 
-int cg_attach_many_everywhere(CGroupMask supported, const char *path, Set* pids, cg_migrate_callback_t path_callback, void *userdata) {
-        Iterator i;
-        void *pidp;
-        int r = 0;
-
-        SET_FOREACH(pidp, pids, i) {
-                pid_t pid = PTR_TO_PID(pidp);
-                int q;
-
-                q = cg_attach_everywhere(supported, path, pid, path_callback, userdata);
-                if (q < 0 && r >= 0)
-                        r = q;
-        }
-
-        return r;
-}
-
 int cg_migrate_v1_controllers(CGroupMask supported, CGroupMask mask, const char *from, cg_migrate_callback_t to_callback, void *userdata) {
         CGroupController c;
         CGroupMask done;
index 72c2b6ee6a5d7691e8bba7f6749d4f004e53fb52..43ce32e30d36fa0a2ef3433641c5b71da4b3f9f2 100644 (file)
@@ -28,7 +28,6 @@ int cg_migrate_recursive_fallback(const char *cfrom, const char *pfrom, const ch
 
 int cg_create_everywhere(CGroupMask supported, CGroupMask mask, const char *path);
 int cg_attach_everywhere(CGroupMask supported, const char *path, pid_t pid, cg_migrate_callback_t callback, void *userdata);
-int cg_attach_many_everywhere(CGroupMask supported, const char *path, Set* pids, cg_migrate_callback_t callback, void *userdata);
 int cg_migrate_v1_controllers(CGroupMask supported, CGroupMask mask, const char *from, cg_migrate_callback_t to_callback, void *userdata);
 int cg_trim_everywhere(CGroupMask supported, const char *path, bool delete_root);
 int cg_trim_v1_controllers(CGroupMask supported, CGroupMask mask, const char *path, bool delete_root);