[Devel] [PATCH RHEL COMMIT] ve/umh: init work separately from other subprocess_info parameters

Konstantin Khorenko khorenko at virtuozzo.com
Tue Sep 28 14:42:35 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after ark-5.14
------>
commit 333e643058eedc3623187b24bd9b31f5e3a3ea8b
Author: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
Date:   Tue Sep 28 14:42:35 2021 +0300

    ve/umh: init work separately from other subprocess_info parameters
    
    By default UHM requests are handled by a workqueue, i.e. they need "struct
    work" parameter.
    It will be different in containers, so move this work init and usage out of
    generic subprocess handling code.
    
    Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
    
    (cherry-picked from vz8 commit 12e306e3c6a7 ("ve/umh: init work separately
    from other subprocess_info parameters"))
    
    Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
 kernel/umh.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/kernel/umh.c b/kernel/umh.c
index 8654aa356b26..e63fd7c9430a 100644
--- a/kernel/umh.c
+++ b/kernel/umh.c
@@ -157,11 +157,8 @@ static void call_usermodehelper_exec_sync(struct subprocess_info *sub_info)
  * to perform the usermodehelper request.
  *
  */
-static void call_usermodehelper_exec_work(struct work_struct *work)
+static void __call_usermodehelper_exec_work(struct subprocess_info *sub_info)
 {
-	struct subprocess_info *sub_info =
-		container_of(work, struct subprocess_info, work);
-
 	if (sub_info->wait & UMH_WAIT_PROC) {
 		call_usermodehelper_exec_sync(sub_info);
 	} else {
@@ -180,6 +177,14 @@ static void call_usermodehelper_exec_work(struct work_struct *work)
 	}
 }
 
+static void call_usermodehelper_exec_work(struct work_struct *work)
+{
+	struct subprocess_info *sub_info =
+		container_of(work, struct subprocess_info, work);
+
+	__call_usermodehelper_exec_work(sub_info);
+}
+
 /*
  * If set, call_usermodehelper_exec() will exit immediately returning -EBUSY
  * (used for preventing user land processes from being created after the user
@@ -373,8 +378,6 @@ static struct subprocess_info *__call_usermodehelper_setup(const char *path,
 	if (!sub_info)
 		goto out;
 
-	INIT_WORK(&sub_info->work, call_usermodehelper_exec_work);
-
 #ifdef CONFIG_STATIC_USERMODEHELPER
 	sub_info->path = CONFIG_STATIC_USERMODEHELPER_PATH;
 #else
@@ -397,10 +400,15 @@ struct subprocess_info *call_usermodehelper_setup(const char *path, char **argv,
 		void (*cleanup)(struct subprocess_info *info),
 		void *data)
 {
-	return __call_usermodehelper_setup(path, argv, envp, gfp_mask,
+	struct subprocess_info *info;
+
+	info = __call_usermodehelper_setup(path, argv, envp, gfp_mask,
 					   init, cleanup,
 					   call_usermodehelper_queue,
 					   data);
+	if (info)
+		INIT_WORK(&info->work, call_usermodehelper_exec_work);
+	return info;
 }
 EXPORT_SYMBOL(call_usermodehelper_setup);
 


More information about the Devel mailing list