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
cb423bd3
Unverified
Commit
cb423bd3
authored
Feb 17, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: rework cgroup tree removal on creation failure
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
2291719e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
+21
-16
cgfsng.c
src/lxc/cgroups/cgfsng.c
+21
-16
No files found.
src/lxc/cgroups/cgfsng.c
View file @
cb423bd3
...
@@ -1159,26 +1159,28 @@ static bool cgroup_tree_create(struct cgroup_ops *ops, struct lxc_conf *conf,
...
@@ -1159,26 +1159,28 @@ static bool cgroup_tree_create(struct cgroup_ops *ops, struct lxc_conf *conf,
return
true
;
return
true
;
}
}
static
void
cgroup_tree_leaf_remove
(
struct
hierarchy
*
h
,
bool
payload
)
static
void
cgroup_tree_leaf_remove
(
struct
hierarchy
*
h
,
const
char
*
path_prune
,
bool
payload
)
{
{
__do_free
char
*
full_path
=
NULL
,
*
__limit_path
=
NULL
;
int
ret
;
char
*
limit_path
=
NULL
;
if
(
payload
)
{
if
(
payload
)
{
__lxc_unused
__do_close
int
fd
=
move_fd
(
h
->
cgfd_con
);
if
(
h
->
container_full_path
!=
h
->
container_limit_path
)
full_path
=
move_ptr
(
h
->
container_full_path
);
free_disarm
(
h
->
container_limit_path
);
limit_path
=
move_ptr
(
h
->
container_limit_path
);
free_disarm
(
h
->
container_full_path
);
if
(
limit_path
!=
full_path
)
__limit_path
=
limit_path
;
close_prot_errno_disarm
(
h
->
cgfd_con
);
close_prot_errno_disarm
(
h
->
cgfd_limit
);
}
else
{
}
else
{
__lxc_unused
__do_close
int
fd
=
move_fd
(
h
->
cgfd_mon
);
free_disarm
(
h
->
monitor_full_path
);
full_path
=
move_ptr
(
h
->
monitor_full_path
);
close_prot_errno_disarm
(
h
->
cgfd_mon
);
}
}
if
(
full_path
&&
rmdir
(
full_path
))
ret
=
cgroup_tree_prune
(
h
->
dfd_base
,
path_prune
);
SYSWARN
(
"Failed to rmdir(
\"
%s
\"
) cgroup"
,
full_path
);
if
(
ret
<
0
)
if
(
limit_path
&&
rmdir
(
limit_path
))
SYSWARN
(
"Failed to destroy %d(%s)"
,
h
->
dfd_base
,
path_prune
);
SYSWARN
(
"Failed to rmdir(
\"
%s
\"
) cgroup"
,
limit_path
);
else
TRACE
(
"Removed cgroup tree %d(%s)"
,
h
->
dfd_base
,
path_prune
);
}
}
__cgfsng_ops
static
void
cgfsng_monitor_destroy
(
struct
cgroup_ops
*
ops
,
__cgfsng_ops
static
void
cgfsng_monitor_destroy
(
struct
cgroup_ops
*
ops
,
...
@@ -1356,7 +1358,8 @@ __cgfsng_ops static bool cgfsng_monitor_create(struct cgroup_ops *ops, struct lx
...
@@ -1356,7 +1358,8 @@ __cgfsng_ops static bool cgfsng_monitor_create(struct cgroup_ops *ops, struct lx
DEBUG
(
"Failed to create cgroup
\"
%s
\"
"
,
maybe_empty
(
ops
->
hierarchies
[
i
]
->
monitor_full_path
));
DEBUG
(
"Failed to create cgroup
\"
%s
\"
"
,
maybe_empty
(
ops
->
hierarchies
[
i
]
->
monitor_full_path
));
for
(
int
j
=
0
;
j
<
i
;
j
++
)
for
(
int
j
=
0
;
j
<
i
;
j
++
)
cgroup_tree_leaf_remove
(
ops
->
hierarchies
[
j
],
false
);
cgroup_tree_leaf_remove
(
ops
->
hierarchies
[
j
],
monitor_cgroup
,
false
);
idx
++
;
idx
++
;
break
;
break
;
...
@@ -1454,7 +1457,9 @@ __cgfsng_ops static bool cgfsng_payload_create(struct cgroup_ops *ops, struct lx
...
@@ -1454,7 +1457,9 @@ __cgfsng_ops static bool cgfsng_payload_create(struct cgroup_ops *ops, struct lx
DEBUG
(
"Failed to create cgroup
\"
%s
\"
"
,
ops
->
hierarchies
[
i
]
->
container_full_path
?:
"(null)"
);
DEBUG
(
"Failed to create cgroup
\"
%s
\"
"
,
ops
->
hierarchies
[
i
]
->
container_full_path
?:
"(null)"
);
for
(
int
j
=
0
;
j
<
i
;
j
++
)
for
(
int
j
=
0
;
j
<
i
;
j
++
)
cgroup_tree_leaf_remove
(
ops
->
hierarchies
[
j
],
true
);
cgroup_tree_leaf_remove
(
ops
->
hierarchies
[
j
],
limiting_cgroup
?:
container_cgroup
,
true
);
idx
++
;
idx
++
;
break
;
break
;
...
...
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