Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
6678889f
K
Kernel
项目概览
openeuler
/
Kernel
大约 2 年 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
6678889f
编写于
1月 17, 2019
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cgroup1_get_tree(): separate "get cgroup_root to use" into a separate helper
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
71d883c3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
41 deletion
+46
-41
kernel/cgroup/cgroup-v1.c
kernel/cgroup/cgroup-v1.c
+46
-41
未找到文件。
kernel/cgroup/cgroup-v1.c
浏览文件 @
6678889f
...
...
@@ -1135,7 +1135,15 @@ struct kernfs_syscall_ops cgroup1_kf_syscall_ops = {
.
show_path
=
cgroup_show_path
,
};
int
cgroup1_get_tree
(
struct
fs_context
*
fc
)
/*
* The guts of cgroup1 mount - find or create cgroup_root to use.
* Called with cgroup_mutex held; returns 0 on success, -E... on
* error and positive - in case when the candidate is busy dying.
* On success it stashes a reference to cgroup_root into given
* cgroup_fs_context; that reference is *NOT* counting towards the
* cgroup_root refcount.
*/
static
int
cgroup1_root_to_use
(
struct
fs_context
*
fc
)
{
struct
cgroup_namespace
*
ns
=
current
->
nsproxy
->
cgroup_ns
;
struct
cgroup_fs_context
*
ctx
=
cgroup_fc2context
(
fc
);
...
...
@@ -1143,16 +1151,10 @@ int cgroup1_get_tree(struct fs_context *fc)
struct
cgroup_subsys
*
ss
;
int
i
,
ret
;
/* Check if the caller has permission to mount. */
if
(
!
ns_capable
(
ns
->
user_ns
,
CAP_SYS_ADMIN
))
return
-
EPERM
;
cgroup_lock_and_drain_offline
(
&
cgrp_dfl_root
.
cgrp
);
/* First find the desired set of subsystems */
ret
=
check_cgroupfs_options
(
fc
);
if
(
ret
)
goto
out_unlock
;
return
ret
;
/*
* Destruction of cgroup root is asynchronous, so subsystems may
...
...
@@ -1166,12 +1168,8 @@ int cgroup1_get_tree(struct fs_context *fc)
ss
->
root
==
&
cgrp_dfl_root
)
continue
;
if
(
!
percpu_ref_tryget_live
(
&
ss
->
root
->
cgrp
.
self
.
refcnt
))
{
mutex_unlock
(
&
cgroup_mutex
);
msleep
(
10
);
ret
=
restart_syscall
();
goto
out_free
;
}
if
(
!
percpu_ref_tryget_live
(
&
ss
->
root
->
cgrp
.
self
.
refcnt
))
return
1
;
/* restart */
cgroup_put
(
&
ss
->
root
->
cgrp
);
}
...
...
@@ -1200,16 +1198,14 @@ int cgroup1_get_tree(struct fs_context *fc)
(
ctx
->
subsys_mask
!=
root
->
subsys_mask
))
{
if
(
!
name_match
)
continue
;
ret
=
-
EBUSY
;
goto
out_unlock
;
return
-
EBUSY
;
}
if
(
root
->
flags
^
ctx
->
flags
)
pr_warn
(
"new mount options do not match the existing superblock, will be ignored
\n
"
);
ctx
->
root
=
root
;
ret
=
0
;
goto
out_unlock
;
return
0
;
}
/*
...
...
@@ -1217,22 +1213,16 @@ int cgroup1_get_tree(struct fs_context *fc)
* specification is allowed for already existing hierarchies but we
* can't create new one without subsys specification.
*/
if
(
!
ctx
->
subsys_mask
&&
!
ctx
->
none
)
{
ret
=
cg_invalf
(
fc
,
"cgroup1: No subsys list or none specified"
);
goto
out_unlock
;
}
if
(
!
ctx
->
subsys_mask
&&
!
ctx
->
none
)
return
cg_invalf
(
fc
,
"cgroup1: No subsys list or none specified"
);
/* Hierarchies may only be created in the initial cgroup namespace. */
if
(
ns
!=
&
init_cgroup_ns
)
{
ret
=
-
EPERM
;
goto
out_unlock
;
}
if
(
ns
!=
&
init_cgroup_ns
)
return
-
EPERM
;
root
=
kzalloc
(
sizeof
(
*
root
),
GFP_KERNEL
);
if
(
!
root
)
{
ret
=
-
ENOMEM
;
goto
out_unlock
;
}
if
(
!
root
)
return
-
ENOMEM
;
ctx
->
root
=
root
;
init_cgroup_root
(
ctx
);
...
...
@@ -1240,23 +1230,38 @@ int cgroup1_get_tree(struct fs_context *fc)
ret
=
cgroup_setup_root
(
root
,
ctx
->
subsys_mask
);
if
(
ret
)
cgroup_free_root
(
root
);
return
ret
;
}
int
cgroup1_get_tree
(
struct
fs_context
*
fc
)
{
struct
cgroup_namespace
*
ns
=
current
->
nsproxy
->
cgroup_ns
;
struct
cgroup_fs_context
*
ctx
=
cgroup_fc2context
(
fc
);
int
ret
;
/* Check if the caller has permission to mount. */
if
(
!
ns_capable
(
ns
->
user_ns
,
CAP_SYS_ADMIN
))
return
-
EPERM
;
cgroup_lock_and_drain_offline
(
&
cgrp_dfl_root
.
cgrp
);
ret
=
cgroup1_root_to_use
(
fc
);
if
(
!
ret
&&
!
percpu_ref_tryget_live
(
&
ctx
->
root
->
cgrp
.
self
.
refcnt
))
ret
=
1
;
/* restart */
out_unlock:
if
(
!
ret
&&
!
percpu_ref_tryget_live
(
&
root
->
cgrp
.
self
.
refcnt
))
{
mutex_unlock
(
&
cgroup_mutex
);
msleep
(
10
);
return
restart_syscall
();
}
mutex_unlock
(
&
cgroup_mutex
);
out_free:
if
(
ret
)
return
ret
;
ret
=
cgroup_do_mount
(
fc
,
CGROUP_SUPER_MAGIC
,
ns
);
if
(
!
ret
&&
percpu_ref_is_dying
(
&
root
->
cgrp
.
self
.
refcnt
))
{
if
(
!
ret
)
ret
=
cgroup_do_mount
(
fc
,
CGROUP_SUPER_MAGIC
,
ns
);
if
(
!
ret
&&
percpu_ref_is_dying
(
&
ctx
->
root
->
cgrp
.
self
.
refcnt
))
{
struct
super_block
*
sb
=
fc
->
root
->
d_sb
;
dput
(
fc
->
root
);
deactivate_locked_super
(
sb
);
ret
=
1
;
}
if
(
unlikely
(
ret
>
0
))
{
msleep
(
10
);
return
restart_syscall
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录