Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
b7967f52
Unverified
Commit
b7967f52
authored
Feb 17, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: distinguish between tmpfs and unified based cgroup layouts file descriptors
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
0bdd81d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
14 deletions
+19
-14
cgfsng.c
src/lxc/cgroups/cgfsng.c
+19
-14
No files found.
src/lxc/cgroups/cgfsng.c
View file @
b7967f52
...
...
@@ -1929,7 +1929,7 @@ static inline int cgroupfs_bind_mount(int cg_flags, struct hierarchy *h,
__cgfsng_ops
static
bool
cgfsng_mount
(
struct
cgroup_ops
*
ops
,
struct
lxc_handler
*
handler
,
int
cg_flags
)
{
__do_close
int
dfd_mnt_
cgrou
pfs
=
-
EBADF
,
fd_fs
=
-
EBADF
;
__do_close
int
dfd_mnt_
tm
pfs
=
-
EBADF
,
fd_fs
=
-
EBADF
;
__do_free
char
*
cgroup_root
=
NULL
;
bool
in_cgroup_ns
=
false
,
wants_force_mount
=
false
;
struct
lxc_conf
*
conf
=
handler
->
conf
;
...
...
@@ -1994,16 +1994,15 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops,
else
if
(
cg_flags
&
LXC_AUTO_CGROUP_FULL_NOSPEC
)
cg_flags
=
LXC_AUTO_CGROUP_FULL_MIXED
;
dfd_mnt_cgroupfs
=
open_at
(
rootfs
->
dfd_mnt
,
DEFAULT_CGROUP_MOUNTPOINT_RELATIVE
,
PROTECT_OPATH_DIRECTORY
,
PROTECT_LOOKUP_BENEATH_XDEV
,
0
);
if
(
dfd_mnt_cgroupfs
<
0
)
return
syserrno
(
-
errno
,
"Failed to open %d(%s)"
,
rootfs
->
dfd_mnt
,
DEFAULT_CGROUP_MOUNTPOINT_RELATIVE
);
/* This is really the codepath that we want. */
if
(
pure_unified_layout
(
ops
))
{
__do_close
int
dfd_mnt_unified
=
-
EBADF
;
dfd_mnt_unified
=
open_at
(
rootfs
->
dfd_mnt
,
DEFAULT_CGROUP_MOUNTPOINT_RELATIVE
,
PROTECT_OPATH_DIRECTORY
,
PROTECT_LOOKUP_BENEATH_XDEV
,
0
);
if
(
dfd_mnt_unified
<
0
)
return
syserrno
(
-
errno
,
"Failed to open %d(%s)"
,
rootfs
->
dfd_mnt
,
DEFAULT_CGROUP_MOUNTPOINT_RELATIVE
);
/*
* If cgroup namespaces are supported but the container will
* not have CAP_SYS_ADMIN after it has started we need to mount
...
...
@@ -2034,7 +2033,7 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops,
* 11. cgroup-full:ro:force -> Not supported.
* 12. cgroup-full:mixed:force -> Not supported.
*/
ret
=
cgroupfs_mount
(
cg_flags
,
ops
->
unified
,
rootfs
,
dfd_mnt_
cgroupfs
,
""
);
ret
=
cgroupfs_mount
(
cg_flags
,
ops
->
unified
,
rootfs
,
dfd_mnt_
unified
,
""
);
if
(
ret
<
0
)
return
syserrno
(
false
,
"Failed to force mount cgroup filesystem in cgroup namespace"
);
...
...
@@ -2102,6 +2101,12 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops,
return
log_error_errno
(
false
,
errno
,
"Failed to mount tmpfs on %s"
,
DEFAULT_CGROUP_MOUNTPOINT_RELATIVE
);
dfd_mnt_tmpfs
=
open_at
(
rootfs
->
dfd_mnt
,
DEFAULT_CGROUP_MOUNTPOINT_RELATIVE
,
PROTECT_OPATH_DIRECTORY
,
PROTECT_LOOKUP_BENEATH_XDEV
,
0
);
if
(
dfd_mnt_tmpfs
<
0
)
return
syserrno
(
-
errno
,
"Failed to open %d(%s)"
,
rootfs
->
dfd_mnt
,
DEFAULT_CGROUP_MOUNTPOINT_RELATIVE
);
for
(
int
i
=
0
;
ops
->
hierarchies
[
i
];
i
++
)
{
__do_free
char
*
controllerpath
=
NULL
,
*
path2
=
NULL
;
struct
hierarchy
*
h
=
ops
->
hierarchies
[
i
];
...
...
@@ -2111,9 +2116,9 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops,
continue
;
controller
++
;
ret
=
mkdirat
(
dfd_mnt_
cgrou
pfs
,
controller
,
0000
);
ret
=
mkdirat
(
dfd_mnt_
tm
pfs
,
controller
,
0000
);
if
(
ret
<
0
)
return
log_error_errno
(
false
,
errno
,
"Failed to create cgroup mountpoint %d(%s)"
,
dfd_mnt_
cgrou
pfs
,
controller
);
return
log_error_errno
(
false
,
errno
,
"Failed to create cgroup mountpoint %d(%s)"
,
dfd_mnt_
tm
pfs
,
controller
);
if
(
in_cgroup_ns
&&
wants_force_mount
)
{
/*
...
...
@@ -2121,7 +2126,7 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops,
* will not have CAP_SYS_ADMIN after it has started we
* need to mount the cgroups manually.
*/
ret
=
cgroupfs_mount
(
cg_flags
,
h
,
rootfs
,
dfd_mnt_
cgrou
pfs
,
controller
);
ret
=
cgroupfs_mount
(
cg_flags
,
h
,
rootfs
,
dfd_mnt_
tm
pfs
,
controller
);
if
(
ret
<
0
)
return
false
;
...
...
@@ -2129,7 +2134,7 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops,
}
/* Here is where the ancient kernel section begins. */
ret
=
cgroupfs_bind_mount
(
cg_flags
,
h
,
rootfs
,
dfd_mnt_
cgrou
pfs
,
controller
);
ret
=
cgroupfs_bind_mount
(
cg_flags
,
h
,
rootfs
,
dfd_mnt_
tm
pfs
,
controller
);
if
(
ret
<
0
)
return
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment