Commit cbc125ef authored by Tejun Heo's avatar Tejun Heo

cgroup: separate out cgroup_has_live_children() from cgroup_destroy_locked()

We're expecting another user.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarLi Zefan <lizefan@huawei.com>
parent 9d800df1
...@@ -3295,6 +3295,21 @@ css_next_descendant_post(struct cgroup_subsys_state *pos, ...@@ -3295,6 +3295,21 @@ css_next_descendant_post(struct cgroup_subsys_state *pos,
return css_parent(pos); return css_parent(pos);
} }
static bool cgroup_has_live_children(struct cgroup *cgrp)
{
struct cgroup *child;
rcu_read_lock();
list_for_each_entry_rcu(child, &cgrp->children, sibling) {
if (!cgroup_is_dead(child)) {
rcu_read_unlock();
return true;
}
}
rcu_read_unlock();
return false;
}
/** /**
* css_advance_task_iter - advance a task itererator to the next css_set * css_advance_task_iter - advance a task itererator to the next css_set
* @it: the iterator to advance * @it: the iterator to advance
...@@ -4465,7 +4480,6 @@ static void kill_css(struct cgroup_subsys_state *css) ...@@ -4465,7 +4480,6 @@ static void kill_css(struct cgroup_subsys_state *css)
static int cgroup_destroy_locked(struct cgroup *cgrp) static int cgroup_destroy_locked(struct cgroup *cgrp)
__releases(&cgroup_mutex) __acquires(&cgroup_mutex) __releases(&cgroup_mutex) __acquires(&cgroup_mutex)
{ {
struct cgroup *child;
struct cgroup_subsys_state *css; struct cgroup_subsys_state *css;
bool empty; bool empty;
int ssid; int ssid;
...@@ -4487,15 +4501,7 @@ static int cgroup_destroy_locked(struct cgroup *cgrp) ...@@ -4487,15 +4501,7 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
* emptiness as dead children linger on it while being destroyed; * emptiness as dead children linger on it while being destroyed;
* otherwise, "rmdir parent/child parent" may fail with -EBUSY. * otherwise, "rmdir parent/child parent" may fail with -EBUSY.
*/ */
empty = true; if (cgroup_has_live_children(cgrp))
rcu_read_lock();
list_for_each_entry_rcu(child, &cgrp->children, sibling) {
empty = cgroup_is_dead(child);
if (!empty)
break;
}
rcu_read_unlock();
if (!empty)
return -EBUSY; return -EBUSY;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment