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
70a49815
Commit
70a49815
authored
Aug 30, 2017
by
Stéphane Graber
Committed by
GitHub
Aug 30, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1769 from brauner/2017-08-30/improve_empty_cgroup_deletion
Revert "cgfsng: try to delete parent cgroups"
parents
2e02bbdb
cf7faeb3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
67 deletions
+11
-67
cgfsng.c
src/lxc/cgroups/cgfsng.c
+11
-67
No files found.
src/lxc/cgroups/cgfsng.c
View file @
70a49815
...
@@ -1272,91 +1272,35 @@ static int rmdir_wrapper(void *data)
...
@@ -1272,91 +1272,35 @@ static int rmdir_wrapper(void *data)
return
cgroup_rmdir
(
path
);
return
cgroup_rmdir
(
path
);
}
}
int
recursive_destroy
(
char
*
path
,
struct
lxc_conf
*
conf
)
void
recursive_destroy
(
char
*
path
,
struct
lxc_conf
*
conf
)
{
{
int
r
;
int
r
;
if
(
conf
&&
!
lxc_list_empty
(
&
conf
->
id_map
))
if
(
conf
&&
!
lxc_list_empty
(
&
conf
->
id_map
))
r
=
userns_exec_1
(
conf
,
rmdir_wrapper
,
path
,
"rmdir_wrapper"
);
r
=
userns_exec_1
(
conf
,
rmdir_wrapper
,
path
,
"rmdir_wrapper"
);
else
else
r
=
cgroup_rmdir
(
path
);
r
=
cgroup_rmdir
(
path
);
if
(
r
<
0
)
if
(
r
<
0
)
ERROR
(
"Error destroying %s"
,
path
);
ERROR
(
"Error destroying %s"
,
path
);
return
r
;
}
}
static
void
cgfsng_destroy
(
void
*
hdata
,
struct
lxc_conf
*
conf
)
static
void
cgfsng_destroy
(
void
*
hdata
,
struct
lxc_conf
*
conf
)
{
{
int
i
;
char
*
clean_parent
,
*
clean_fullcgpath
;
char
**
fields
;
size_t
recurse_upwards
=
0
;
struct
cgfsng_handler_data
*
d
=
hdata
;
struct
cgfsng_handler_data
*
d
=
hdata
;
if
(
!
d
)
if
(
!
d
)
return
;
return
;
if
(
!
d
->
container_cgroup
||
!
hierarchies
)
if
(
d
->
container_cgroup
&&
hierarchies
)
{
return
;
int
i
;
for
(
i
=
0
;
hierarchies
[
i
];
i
++
)
{
if
(
d
->
cgroup_meta
.
dir
)
struct
hierarchy
*
h
=
hierarchies
[
i
];
clean_parent
=
d
->
cgroup_meta
.
dir
;
if
(
h
->
fullcgpath
)
{
else
recursive_destroy
(
h
->
fullcgpath
,
conf
);
clean_parent
=
d
->
cgroup_pattern
;
free
(
h
->
fullcgpath
);
fields
=
lxc_normalize_path
(
clean_parent
);
h
->
fullcgpath
=
NULL
;
if
(
fields
)
{
}
recurse_upwards
=
lxc_array_len
((
void
**
)
fields
);
if
(
recurse_upwards
>
0
&&
clean_parent
==
d
->
cgroup_pattern
)
recurse_upwards
--
;
lxc_free_array
((
void
**
)
fields
,
free
);
}
for
(
i
=
0
;
hierarchies
[
i
];
i
++
)
{
int
ret
;
size_t
j
;
struct
hierarchy
*
h
=
hierarchies
[
i
];
if
(
!
h
->
fullcgpath
)
continue
;
clean_fullcgpath
=
lxc_deslashify
(
h
->
fullcgpath
);
if
(
!
clean_fullcgpath
)
clean_fullcgpath
=
h
->
fullcgpath
;
/* Delete the container's cgroup */
ret
=
recursive_destroy
(
clean_fullcgpath
,
conf
);
if
(
ret
<
0
)
goto
next
;
if
(
h
->
fullcgpath
==
clean_fullcgpath
)
goto
next
;
/* Delete parent cgroups as specified in the containers config
* file. This takes care of not having useless empty cgroups
* around.
*/
for
(
j
=
0
;
j
<
recurse_upwards
;
j
++
)
{
char
*
s
=
clean_fullcgpath
;
s
=
strrchr
(
s
,
'/'
);
if
(
!
s
)
break
;
*
s
=
'\0'
;
/* If we fail to delete a cgroup we know that any parent
* cgroup also cannot be removed.
*/
ret
=
recursive_destroy
(
clean_fullcgpath
,
conf
);
if
(
ret
<
0
)
break
;
}
}
next:
if
(
h
->
fullcgpath
!=
clean_fullcgpath
)
free
(
clean_fullcgpath
);
free
(
h
->
fullcgpath
);
h
->
fullcgpath
=
NULL
;
}
}
free_handler_data
(
d
);
free_handler_data
(
d
);
...
...
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