[Devel] [PATCH vz9 05/14] ve/umh: init work separately from other subprocess_info parameters

Nikita Yushchenko nikita.yushchenko at virtuozzo.com
Mon Sep 27 09:29:51 MSK 2021


From: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>

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);
 
-- 
2.30.2



More information about the Devel mailing list