!59 [sync] PR-55: 解决libcgroup工具无法挂载多个controller到同一挂载点的问题
From: @openeuler-sync-bot Reviewed-by: @xuxuepeng Signed-off-by: @xuxuepeng
This commit is contained in:
commit
22db5a4fec
@ -0,0 +1,73 @@
|
||||
From a20a50c1a133414f61d6cee0dc1b0cb66869bd95 Mon Sep 17 00:00:00 2001
|
||||
From: lipengyu <lipengyu@kylinos.cn>
|
||||
Date: Fri, 6 Dec 2024 15:07:10 +0800
|
||||
Subject: [PATCH] Add support for multipe controllers on same mount point
|
||||
|
||||
---
|
||||
src/config.c | 29 ++++++++++++++++++++++++++++-
|
||||
1 file changed, 28 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/config.c b/src/config.c
|
||||
index dfabbd1..d194b32 100644
|
||||
--- a/src/config.c
|
||||
+++ b/src/config.c
|
||||
@@ -635,6 +635,22 @@ void cgroup_config_cleanup_namespace_table(void)
|
||||
sizeof(struct cg_mount_table_s) * CG_CONTROLLER_MAX);
|
||||
}
|
||||
|
||||
+static int is_valid_controller(char *ctrl)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ static const char *ctrl_list[] = { "blkio", "cpu", "cpuacct", "cpuset", "devices",
|
||||
+ "freezer", "hugetlb", "memory", "misc", "net_cls",
|
||||
+ "net_prio", "perf_event", "pids", "rdma", NULL };
|
||||
+
|
||||
+ for (i = 0; ctrl_list[i]; i++) {
|
||||
+ if (strncmp(ctrl, ctrl_list[i], strlen(ctrl_list[i])) == 0)
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* Add necessary options for mount. Currently only 'none' option is added
|
||||
* for mounts with only 'name=xxx' and without real controller.
|
||||
@@ -663,6 +679,9 @@ static int cgroup_config_ajdust_mount_options(struct cg_mount_table_s *mount,
|
||||
break;
|
||||
strncpy(mount->name, controller, sizeof(mount->name));
|
||||
mount->name[sizeof(mount->name)-1] = '\0';
|
||||
+ free(controller);
|
||||
+ token = strtok_r(NULL, ",", &save);
|
||||
+ continue;
|
||||
}
|
||||
|
||||
if (strncmp(token, "nodev", strlen("nodev")) == 0) {
|
||||
@@ -675,6 +694,15 @@ static int cgroup_config_ajdust_mount_options(struct cg_mount_table_s *mount,
|
||||
*flags |= MS_NOSUID;
|
||||
}
|
||||
|
||||
+ if (is_valid_controller(token)) {
|
||||
+ controller = strdup(token);
|
||||
+ if (controller == NULL)
|
||||
+ break;
|
||||
+ strncat(mount->name, ",", FILENAME_MAX - strlen(mount->name)-1);
|
||||
+ strncat(mount->name, controller, FILENAME_MAX - strlen(mount->name) - 1);
|
||||
+ free(controller);
|
||||
+ }
|
||||
+
|
||||
} else if (!name_only) {
|
||||
/*
|
||||
* We have controller + name=, do the right thing, since
|
||||
@@ -687,7 +715,6 @@ static int cgroup_config_ajdust_mount_options(struct cg_mount_table_s *mount,
|
||||
token = strtok_r(NULL, ",", &save);
|
||||
}
|
||||
|
||||
- free(controller);
|
||||
free(opts);
|
||||
|
||||
if (name_only) {
|
||||
--
|
||||
2.25.1
|
||||
|
||||
13
config.patch
13
config.patch
@ -1,13 +0,0 @@
|
||||
--- libcgroup-0.42.2/samples/cgconfig.sysconfig.orig 2019-12-19 11:25:25.547000000 +0800
|
||||
+++ libcgroup-0.42.2/samples/cgconfig.sysconfig 2019-12-19 11:26:01.142000000 +0800
|
||||
@@ -5,8 +5,5 @@
|
||||
# controller to limit cpu.shares of this default group and allowing some more
|
||||
# important group take most of the CPU.
|
||||
#
|
||||
-# By default, create these groups:
|
||||
-CREATE_DEFAULT=yes
|
||||
-
|
||||
-# Uncomment following line to disable creation of the default group on startup:
|
||||
-# CREATE_DEFAULT=no
|
||||
+# By default, do not create these groups:
|
||||
+CREATE_DEFAULT=no
|
||||
@ -5,7 +5,7 @@
|
||||
Summary: Libcgroup is a library that abstracts the control group file system in Linux
|
||||
Name: libcgroup
|
||||
Version: 2.0.3
|
||||
Release: 2
|
||||
Release: 3
|
||||
License: LGPLv2+
|
||||
URL: http://libcg.sourceforge.net/
|
||||
Source0: https://github.com/%{name}/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz
|
||||
@ -13,7 +13,7 @@ Source1: cgconfig.service
|
||||
Provides: libcgroup-pam libcgroup-tools
|
||||
Obsoletes: libcgroup-pam libcgroup-tools
|
||||
|
||||
Patch0:config.patch
|
||||
Patch0: Add-support-for-multiple-controllers-on-same-mount-point.patch
|
||||
|
||||
BuildRequires: autoconf, automake, libtool
|
||||
BuildRequires: gcc,gcc-c++,byacc
|
||||
@ -41,6 +41,7 @@ It provides helpful information for libcgroup-pam,libcgroup-devel,libcgroup-tool
|
||||
|
||||
%prep
|
||||
%setup -q -n %{name}-%{version}
|
||||
%patch0 -p1
|
||||
|
||||
%build
|
||||
autoreconf -vif
|
||||
@ -129,6 +130,12 @@ getent group cgred >/dev/null || groupadd -r cgred
|
||||
%attr(0644, root, root) %{_mandir}/man8/*
|
||||
|
||||
%changelog
|
||||
* Tue Nov 26 2024 lipengyu <lipengyu@kylinos.cn> - 2.0.3-3
|
||||
- Type: bugfix
|
||||
- Id:NA
|
||||
- SUG:NA
|
||||
- DESC:Add support for multiple controllers on same mount point
|
||||
|
||||
* Mon Jun 12 2023 leizhongkai <leizhongkai@huawei.com> - 2.0.3-2
|
||||
- Type: upgrade
|
||||
- Id:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user