mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-29 10:01:25 +00:00
cgroup: fix umount vs cgroup_cfts_commit() race
cgroup_cfts_commit() uses dget() to keep cgroup alive after cgroup_mutex is dropped, but dget() won't prevent cgroupfs from being umounted. When the race happens, vfs will see some dentries with non-zero refcnt while umount is in process. Keep running this: mount -t cgroup -o blkio xxx /cgroup umount /cgroup And this: modprobe cfq-iosched rmmod cfs-iosched After a while, the BUG() in shrink_dcache_for_umount_subtree() may be triggered: BUG: Dentry xxx{i=0,n=blkio.yyy} still in use (1) [umount of cgroup cgroup] Signed-off-by: Li Zefan <lizefan@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org> Cc: stable@vger.kernel.org
This commit is contained in:
parent
6db8e85c5c
commit
084457f284
1 changed files with 8 additions and 1 deletions
|
@ -2798,13 +2798,17 @@ static void cgroup_cfts_commit(struct cgroup_subsys *ss,
|
||||||
{
|
{
|
||||||
LIST_HEAD(pending);
|
LIST_HEAD(pending);
|
||||||
struct cgroup *cgrp, *n;
|
struct cgroup *cgrp, *n;
|
||||||
|
struct super_block *sb = ss->root->sb;
|
||||||
|
|
||||||
/* %NULL @cfts indicates abort and don't bother if @ss isn't attached */
|
/* %NULL @cfts indicates abort and don't bother if @ss isn't attached */
|
||||||
if (cfts && ss->root != &rootnode) {
|
if (cfts && ss->root != &rootnode &&
|
||||||
|
atomic_inc_not_zero(sb->s_active)) {
|
||||||
list_for_each_entry(cgrp, &ss->root->allcg_list, allcg_node) {
|
list_for_each_entry(cgrp, &ss->root->allcg_list, allcg_node) {
|
||||||
dget(cgrp->dentry);
|
dget(cgrp->dentry);
|
||||||
list_add_tail(&cgrp->cft_q_node, &pending);
|
list_add_tail(&cgrp->cft_q_node, &pending);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
sb = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&cgroup_mutex);
|
mutex_unlock(&cgroup_mutex);
|
||||||
|
@ -2827,6 +2831,9 @@ static void cgroup_cfts_commit(struct cgroup_subsys *ss,
|
||||||
dput(cgrp->dentry);
|
dput(cgrp->dentry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sb)
|
||||||
|
deactivate_super(sb);
|
||||||
|
|
||||||
mutex_unlock(&cgroup_cft_mutex);
|
mutex_unlock(&cgroup_cft_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue