[Devel] [PATCH VZ8 v0 02/14] cgroup/cfs: added 'activate' option to cgroup_add_file

Valeriy Vdovin valeriy.vdovin at virtuozzo.com
Tue Jan 19 21:01:42 MSK 2021


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 in later patches.

Signed-off-by: Valeriy Vdovin <valeriy.vdovin 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 4488df184235..797a3971ab46 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -3824,7 +3824,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;
@@ -3866,6 +3866,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;
 }
@@ -3903,7 +3905,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.27.0



More information about the Devel mailing list