chiark / gitweb /
unit: trim cgroups when going down
authorLennart Poettering <lennart@poettering.net>
Sat, 10 Jul 2010 15:34:42 +0000 (17:34 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 10 Jul 2010 15:34:42 +0000 (17:34 +0200)
src/cgroup.c
src/cgroup.h
src/unit.c

index 27130a9..244a602 100644 (file)
@@ -101,6 +101,20 @@ void cgroup_bonding_free_list(CGroupBonding *first) {
                 cgroup_bonding_free(b);
 }
 
+void cgroup_bonding_trim(CGroupBonding *b, bool delete_root) {
+        assert(b);
+
+        if (b->realized && b->only_us && b->clean_up)
+                cg_trim(b->controller, b->path, delete_root);
+}
+
+void cgroup_bonding_trim_list(CGroupBonding *first, bool delete_root) {
+        CGroupBonding *b;
+
+        LIST_FOREACH(by_unit, b, first)
+                cgroup_bonding_trim(b, delete_root);
+}
+
 int cgroup_bonding_install(CGroupBonding *b, pid_t pid) {
         int r;
 
index 11d2aba..05c858c 100644 (file)
@@ -61,6 +61,9 @@ int cgroup_bonding_install_list(CGroupBonding *first, pid_t pid);
 int cgroup_bonding_kill(CGroupBonding *b, int sig);
 int cgroup_bonding_kill_list(CGroupBonding *first, int sig);
 
+void cgroup_bonding_trim(CGroupBonding *first, bool delete_root);
+void cgroup_bonding_trim_list(CGroupBonding *first, bool delete_root);
+
 int cgroup_bonding_is_empty(CGroupBonding *b);
 int cgroup_bonding_is_empty_list(CGroupBonding *first);
 
index c287310..18faae2 100644 (file)
@@ -973,6 +973,9 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns) {
         if (ns != os && ns == UNIT_MAINTENANCE)
                 log_notice("Unit %s entered maintenance state.", u->meta.id);
 
+        if (UNIT_IS_INACTIVE_OR_MAINTENANCE(ns))
+                cgroup_bonding_trim_list(u->meta.cgroup_bondings, true);
+
         timer_unit_notify(u, ns);
         path_unit_notify(u, ns);