[RHEL8,COMMIT] cgroup/cfs: added 'activate' option to cgroup_add_file

Submitted by Konstantin Khorenko on March 3, 2021, 5:22 p.m.

Details

Message ID 202103031722.123HMdcY295483@finist-co8.sw.ru
State New
Series "Port release_agent virtualization from vz7"
Headers show

Commit Message

Konstantin Khorenko March 3, 2021, 5:22 p.m.
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.5
------>
commit 4a0b1219c4ca72b0a3b79654b45c7004ba7d7571
Author: Valeriy Vdovin <valeriy.vdovin@virtuozzo.com>
Date:   Thu Jan 28 12:04:25 2021 +0300

    cgroup/cfs: added 'activate' option to cgroup_add_file
    
    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@virtuozzo.com>
---
 kernel/cgroup/cgroup.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index b71d4ccb2f0c..946031fcb393 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -3823,7 +3823,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;
@@ -3865,6 +3865,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;
 }
@@ -3902,7 +3904,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);