[RFC][PATCH 8/9 v2] cgroup: avoid creating new cgroup under a cgroupbeing destroyed

From: KAMEZAWA Hiroyuki
Date: Fri Apr 27 2012 - 02:06:14 EST


When ->pre_destroy() is called, it should be guaranteed that
new child cgroup is not created under a cgroup, where pre_destroy()
is running. If not, ->pre_destroy() must check children and
return -EBUSY, which causes warning.

Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
---
kernel/cgroup.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 7a3076b..003ceed 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -3970,6 +3970,15 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,

mutex_lock(&cgroup_mutex);

+ /*
+ * prevent making child cgroup when ->pre_destroy() is running.
+ */
+ if (test_bit(CGRP_WAIT_ON_RMDIR, &parent->flags)) {
+ mutex_unlock(&cgroup_mutex);
+ atomic_dec(&sb->s_active);
+ return -EBUSY;
+ }
+
init_cgroup_housekeeping(cgrp);

cgrp->parent = parent;
--
1.7.4.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/