diff mbox series

[08/19] API/cgroup: refuse to mount blkio when io controller is mounted

Message ID 81ac339d9c92668acabbdd396092bc4b67119872.1651176646.git.luke.nowakowskikrijger@canonical.com
State Changes Requested
Headers show
Series Expand Cgroup lib and modify controller tests | expand

Commit Message

Luke Nowakowski-Krijger April 28, 2022, 8:39 p.m. UTC
Mounting the v1 blkio controller while v2 io controller is mounted
unmounts the io controller, triggering a tst_brk that the number of
controller has gone down.

Because these controllers don't seem to be compatible, tst_brk with
TCONF and report that we refused to mount the blkio controller while the
io controller is mounted.

Signed-off-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com>
---
 lib/tst_cgroup.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Petr Vorel May 3, 2022, 3:10 p.m. UTC | #1
Hi Luke,

> Mounting the v1 blkio controller while v2 io controller is mounted
> unmounts the io controller, triggering a tst_brk that the number of
> controller has gone down.

> Because these controllers don't seem to be compatible, tst_brk with
> TCONF and report that we refused to mount the blkio controller while the
> io controller is mounted.

> Signed-off-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com>
> ---
>  lib/tst_cgroup.c | 5 +++++
>  1 file changed, 5 insertions(+)

> diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
> index 254f4aaca..6794046e2 100644
> --- a/lib/tst_cgroup.c
> +++ b/lib/tst_cgroup.c
> @@ -717,6 +717,11 @@ static void cgroup_mount_v1(struct cgroup_ctrl *const ctrl)
>  	char mnt_path[PATH_MAX];
>  	int made_dir = 0;

> +	if (ctrl->ctrl_indx == CTRL_BLKIO && controllers[CTRL_IO].ctrl_root) {
> +		tst_brk(TCONF,
> +			"IO controller found on V2 root, skipping blkio mount that would unmount IO controller");
Good catch! I'm just not sure if it wouldn't be better to use tst_res(TCONF,
..); return;
Because with tst_brk we're not skipping the test but quiting, right?
That's not true for tst_cgctl.c used in shell API (your changes),
but it'd be for tests which use C API.

Kind regards,
Petr

> +	}
> +
>  	sprintf(mnt_path, "%s%s", cgroup_mount_ltp_prefix, ctrl->ctrl_name);

>  	if (!mkdir(mnt_path, 0777)) {
diff mbox series

Patch

diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
index 254f4aaca..6794046e2 100644
--- a/lib/tst_cgroup.c
+++ b/lib/tst_cgroup.c
@@ -717,6 +717,11 @@  static void cgroup_mount_v1(struct cgroup_ctrl *const ctrl)
 	char mnt_path[PATH_MAX];
 	int made_dir = 0;
 
+	if (ctrl->ctrl_indx == CTRL_BLKIO && controllers[CTRL_IO].ctrl_root) {
+		tst_brk(TCONF,
+			"IO controller found on V2 root, skipping blkio mount that would unmount IO controller");
+	}
+
 	sprintf(mnt_path, "%s%s", cgroup_mount_ltp_prefix, ctrl->ctrl_name);
 
 	if (!mkdir(mnt_path, 0777)) {