提交 a015edd2 编写于 作者: T Tejun Heo

cgroup: use restart_syscall() for mount retries

cgroup_mount() uses dumb delay-and-retry logic to wait for cgroup_root
which is being destroyed.  The retry currently loops inside
cgroup_mount() proper.  This patch makes it return with
restart_syscall() instead so that retry travels out to userland
boundary.

This slightly simplifies the logic and more importantly makes the
retry logic behave better when the wait for some reason becomes
lengthy or infinite by allowing the operation to be suspended or
terminated from userland.

v2: The original patch forgot to free memory allocated for @opts.
    Fixed.  Caught by Li Zefan.
Signed-off-by: NTejun Heo <tj@kernel.org>
Acked-by: NLi Zefan <lizefan@huawei.com>
上级 8353da1f
...@@ -1681,7 +1681,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, ...@@ -1681,7 +1681,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
ret = parse_cgroupfs_options(data, &opts); ret = parse_cgroupfs_options(data, &opts);
if (ret) if (ret)
goto out_unlock; goto out_unlock;
retry:
/* look for a matching existing root */ /* look for a matching existing root */
if (!opts.subsys_mask && !opts.none && !opts.name) { if (!opts.subsys_mask && !opts.none && !opts.name) {
cgrp_dfl_root_visible = true; cgrp_dfl_root_visible = true;
...@@ -1740,8 +1740,8 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, ...@@ -1740,8 +1740,8 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
if (!atomic_inc_not_zero(&root->cgrp.refcnt)) { if (!atomic_inc_not_zero(&root->cgrp.refcnt)) {
mutex_unlock(&cgroup_mutex); mutex_unlock(&cgroup_mutex);
msleep(10); msleep(10);
mutex_lock(&cgroup_mutex); ret = restart_syscall();
goto retry; goto out_free;
} }
ret = 0; ret = 0;
...@@ -1772,7 +1772,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, ...@@ -1772,7 +1772,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
out_unlock: out_unlock:
mutex_unlock(&cgroup_mutex); mutex_unlock(&cgroup_mutex);
out_free:
kfree(opts.release_agent); kfree(opts.release_agent);
kfree(opts.name); kfree(opts.name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册