[Devel] [PATCH RH9 2/6] cgroup/cfs: added 'activate' option to cgroup_add_file

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Mon Oct 18 15:50:06 MSK 2021


From: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>

In kernfs files get created in 'deactivated' state, which means they are
not visible. Add option to activate the file after creation immediately
making it visible in the parent directory. Will be used when adding
release agent files to ve cgroup roots.

Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>

vz9 change: cleanup commit message

https://jira.sw.ru/browse/PSBM-134002
(cherry picked from vz8 commit 53fae899bb7e04cbe8ba229c4e2134c8688e65bf)
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 kernel/cgroup/cgroup.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index c64797ecd49a..ff9f5b9dc219 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -4188,7 +4188,7 @@ static void cgroup_file_notify_timer(struct timer_list *timer)
 }
 
 static int cgroup_add_file(struct cgroup_subsys_state *css, struct cgroup *cgrp,
-			   struct cftype *cft)
+			   struct cftype *cft, bool activate)
 {
 	char name[CGROUP_FILE_NAME_MAX];
 	struct kernfs_node *kn;
@@ -4230,6 +4230,8 @@ static int cgroup_add_file(struct cgroup_subsys_state *css, struct cgroup *cgrp,
 		if (IS_ERR(kn_link))
 			return PTR_ERR(kn_link);
 	}
+	if (activate)
+		kernfs_activate(kn);
 
 	return 0;
 }
@@ -4269,7 +4271,7 @@ static int cgroup_addrm_files(struct cgroup_subsys_state *css,
 		if ((cft->flags & CFTYPE_DEBUG) && !cgroup_debug)
 			continue;
 		if (is_add) {
-			ret = cgroup_add_file(css, cgrp, cft);
+			ret = cgroup_add_file(css, cgrp, cft, false);
 			if (ret) {
 				pr_warn("%s: failed to add %s, err=%d\n",
 					__func__, cft->name, ret);
-- 
2.31.1



More information about the Devel mailing list