Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] ksmbd-tools: add the "server request workqueue" option
@ 2026-12-01  5:54 Huiwen He
  2026-12-01  7:59 ` ChenXiaoSong
  0 siblings, 1 reply; 4+ messages in thread
From: Huiwen He @ 2026-12-01  5:54 UTC (permalink / raw)
  To: linux-cifs; +Cc: linkinjeon, stefan.chulski, chenxiaosong

From: Huiwen He <hehuiwen@kylinos.cn>

Let administrators select the kernel workqueue for incoming SMB
requests through ksmbd.conf. The global option accepts "percpu"
(the default) or "unbound" and takes effect at server startup.

Pass the selected mode to the kernel in the last reserved byte
of the startup request.

Signed-off-by: Huiwen He <hehuiwen@kylinos.cn>
---
 include/linux/ksmbd_server.h |  8 +++++++-
 include/tools.h              |  1 +
 ksmbd.conf.5.in              |  9 +++++++++
 ksmbd.conf.example           |  1 +
 mountd/ipc.c                 |  1 +
 tools/config_parser.c        | 13 +++++++++++++
 6 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/include/linux/ksmbd_server.h b/include/linux/ksmbd_server.h
index a712911..63cc06b 100644
--- a/include/linux/ksmbd_server.h
+++ b/include/linux/ksmbd_server.h
@@ -35,6 +35,11 @@ struct ksmbd_heartbeat {
 #define KSMBD_GLOBAL_FLAG_SMB3_ENCRYPTION_OFF	(1 << 3)
 #define KSMBD_GLOBAL_FLAG_DURABLE_HANDLES	(1 << 4)
 
+enum ksmbd_wq_mode {
+	KSMBD_WQ_PERCPU = 0,
+	KSMBD_WQ_UNBOUND = 1,
+};
+
 struct ksmbd_startup_request {
 	__u32	flags;
 	__s32	signing;
@@ -59,7 +64,8 @@ struct ksmbd_startup_request {
 	__u32   max_ip_connections;	/* Number of maximum connection per ip address */
 	__s8	aapl_model[32];		/* AAPL model string for Finder icon, e.g. "Xserve" */
 	__u32	max_sessions_per_connection; /* Maximum sessions per connection */
-	__s8	reserved[463];		/* Reserved room */
+	__s8	reserved[462];		/* Reserved room */
+	__u8	request_wq_mode;	/* enum ksmbd_wq_mode */
 	__u32	ifc_list_sz;
 	__s8	____payload[];
 } __attribute__((packed));
diff --git a/include/tools.h b/include/tools.h
index 063fc02..d4d7c24 100644
--- a/include/tools.h
+++ b/include/tools.h
@@ -61,6 +61,7 @@ struct smbconf_global {
 	unsigned short		ipc_timeout;
 	unsigned int		deadtime;
 	bool			bind_interfaces_only;
+	unsigned char		request_wq_mode;
 	char			**interfaces;
 	unsigned long		file_max;
 	unsigned int		smb2_max_read;
diff --git a/ksmbd.conf.5.in b/ksmbd.conf.5.in
index 8091823..b06b61d 100644
--- a/ksmbd.conf.5.in
+++ b/ksmbd.conf.5.in
@@ -335,6 +335,15 @@ Use of SMB3 multi-channel is supported.
 
 Default: \fBserver multi channel support = no\fR
 .TP
+\fBserver request workqueue\fR (G)
+Select the kernel workqueue for incoming SMB requests at server startup.
+With \fBpercpu\fR, requests use the per-CPU queue.
+With \fBunbound\fR, requests use the unbound queue.
+The kernel must support request workqueue selection.
+Restart the SMB server to apply changes.
+
+Default: \fBserver request workqueue = percpu\fR
+.TP
 \fBserver signing\fR (G)
 Client is allowed or required to use SMB2 signing.
 With \fBserver signing = disabled\fR or \fBserver signing = auto\fR, SMB2 signing is allowed if it is requested by the client.
diff --git a/ksmbd.conf.example b/ksmbd.conf.example
index 765726b..0897287 100644
--- a/ksmbd.conf.example
+++ b/ksmbd.conf.example
@@ -24,6 +24,7 @@
 	server max protocol = SMB3_11
 	server min protocol = SMB2_10
 	server multi channel support = no
+	server request workqueue = percpu
 	server signing = auto
 	server string = SMB SERVER
 	share:fake_fscaps = 64
diff --git a/mountd/ipc.c b/mountd/ipc.c
index f4aecf5..678b637 100644
--- a/mountd/ipc.c
+++ b/mountd/ipc.c
@@ -135,6 +135,7 @@ static int ipc_ksmbd_starting_up(void)
 
 	ev->flags = global_conf.flags;
 	ev->reserved[0] = KSMBD_IPC_FEATURE_QUOTA;
+	ev->request_wq_mode = global_conf.request_wq_mode;
 	ev->signing = global_conf.server_signing;
 	ev->tcp_port = global_conf.tcp_port;
 	ev->ipc_timeout = global_conf.ipc_timeout;
diff --git a/tools/config_parser.c b/tools/config_parser.c
index 9b617fa..4052b39 100644
--- a/tools/config_parser.c
+++ b/tools/config_parser.c
@@ -532,6 +532,18 @@ static int process_global_conf_kv(GHashTable *kv)
 		global_conf.krb5_support = cp_get_group_kv_bool(v);
 	}
 
+	if (group_kv_steal(kv, "server request workqueue", &k, &v)) {
+		g_strchomp(v);
+		if (!g_ascii_strcasecmp(v, "percpu"))
+			global_conf.request_wq_mode = KSMBD_WQ_PERCPU;
+		else if (!g_ascii_strcasecmp(v, "unbound"))
+			global_conf.request_wq_mode = KSMBD_WQ_UNBOUND;
+		else {
+			pr_err("Invalid server request workqueue `%s'\n", v);
+			return -EINVAL;
+		}
+	}
+
 	if (group_kv_steal(kv, "server multi channel support", &k, &v)) {
 		if (cp_get_group_kv_bool(v))
 			global_conf.flags |=
@@ -594,6 +606,7 @@ static void add_group_global_conf(void)
 	add_group_key_value("share:fake_fscaps = 64"); /* sparse files */
 	add_group_key_value("tcp port = 445");
 	add_group_key_value("workgroup = WORKGROUP");
+	add_group_key_value("server request workqueue = percpu");
 	add_group_key_value("server signing = auto");
 	add_group_key_value("smb2 leases = yes");
 }

base-commit: 728b3cbe011d79f543b561bd8427fd0b12c96a70

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ksmbd-tools: add the "server request workqueue" option
  2026-12-01  5:54 [PATCH] ksmbd-tools: add the "server request workqueue" option Huiwen He
@ 2026-12-01  7:59 ` ChenXiaoSong
  2026-12-01  8:37   ` ChenXiaoSong
  0 siblings, 1 reply; 4+ messages in thread
From: ChenXiaoSong @ 2026-12-01  7:59 UTC (permalink / raw)
  To: Huiwen He, linux-cifs; +Cc: linkinjeon, stefan.chulski

An invalid value for "server request workqueue" in ksmbd.conf will also 
affect the execution of ksmbd.adduser.

ksmbd.conf:
```
[global]
	server request workqueue = invalid_value
```

```
ksmbd.adduser --add new_user
[ksmbd.adduser/5978]: ERROR: Invalid server request workqueue 
`invalid_value'
```

On 12/1/26 13:54, Huiwen He wrote:
> diff --git a/tools/config_parser.c b/tools/config_parser.c
> index 9b617fa..4052b39 100644
> --- a/tools/config_parser.c
> +++ b/tools/config_parser.c
> @@ -532,6 +532,18 @@ static int process_global_conf_kv(GHashTable *kv)
>   		global_conf.krb5_support = cp_get_group_kv_bool(v);
>   	}
>   
> +	if (group_kv_steal(kv, "server request workqueue", &k, &v)) {
> +		g_strchomp(v);
> +		if (!g_ascii_strcasecmp(v, "percpu"))
> +			global_conf.request_wq_mode = KSMBD_WQ_PERCPU;
> +		else if (!g_ascii_strcasecmp(v, "unbound"))
> +			global_conf.request_wq_mode = KSMBD_WQ_UNBOUND;
> +		else {
> +			pr_err("Invalid server request workqueue `%s'\n", v);
> +			return -EINVAL;
> +		}
> +	}

-- 
ChenXiaoSong <chenxiaosong@chenxiaosong.com>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ksmbd-tools: add the "server request workqueue" option
  2026-12-01  7:59 ` ChenXiaoSong
@ 2026-12-01  8:37   ` ChenXiaoSong
  2026-12-01 10:36     ` hehuiwen
  0 siblings, 1 reply; 4+ messages in thread
From: ChenXiaoSong @ 2026-12-01  8:37 UTC (permalink / raw)
  To: Huiwen He, linux-cifs; +Cc: linkinjeon, stefan.chulski

We can return -EINVAL only when executing ksmbd.mountd.

```
--- a/tools/config_parser.c
+++ b/tools/config_parser.c
@@ -538,9 +538,11 @@ static int process_global_conf_kv(GHashTable *kv)
                         global_conf.request_wq_mode = KSMBD_WQ_PERCPU;
                 else if (!g_ascii_strcasecmp(v, "unbound"))
                         global_conf.request_wq_mode = KSMBD_WQ_UNBOUND;
-               else {
+               else if (TOOL_IS_MOUNTD) {
                         pr_err("Invalid server request workqueue 
`%s'\n", v);
                         return -EINVAL;
+               } else {
+                       pr_info("Ignoring invalid server request 
workqueue `%s'\n", v);
                 }
         }
```

On 12/1/26 15:59, ChenXiaoSong wrote:
> An invalid value for "server request workqueue" in ksmbd.conf will also 
> affect the execution of ksmbd.adduser.
> 
> ksmbd.conf:
> ```
> [global]
>      server request workqueue = invalid_value
> ```
> 
> ```
> ksmbd.adduser --add new_user
> [ksmbd.adduser/5978]: ERROR: Invalid server request workqueue 
> `invalid_value'
> ```
> 
> On 12/1/26 13:54, Huiwen He wrote:
>> diff --git a/tools/config_parser.c b/tools/config_parser.c
>> index 9b617fa..4052b39 100644
>> --- a/tools/config_parser.c
>> +++ b/tools/config_parser.c
>> @@ -532,6 +532,18 @@ static int process_global_conf_kv(GHashTable *kv)
>>           global_conf.krb5_support = cp_get_group_kv_bool(v);
>>       }
>> +    if (group_kv_steal(kv, "server request workqueue", &k, &v)) {
>> +        g_strchomp(v);
>> +        if (!g_ascii_strcasecmp(v, "percpu"))
>> +            global_conf.request_wq_mode = KSMBD_WQ_PERCPU;
>> +        else if (!g_ascii_strcasecmp(v, "unbound"))
>> +            global_conf.request_wq_mode = KSMBD_WQ_UNBOUND;
>> +        else {
>> +            pr_err("Invalid server request workqueue `%s'\n", v);
>> +            return -EINVAL;
>> +        }
>> +    }
> 

-- 
ChenXiaoSong <chenxiaosong@chenxiaosong.com>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ksmbd-tools: add the "server request workqueue" option
  2026-12-01  8:37   ` ChenXiaoSong
@ 2026-12-01 10:36     ` hehuiwen
  0 siblings, 0 replies; 4+ messages in thread
From: hehuiwen @ 2026-12-01 10:36 UTC (permalink / raw)
  To: ChenXiaoSong, linux-cifs; +Cc: linkinjeon, stefan.chulski


Thanks for pointing this out.

In v2, unrecognized values will fall back to "percpu" like
other global options, so tools such as ksmbd.adduser are no
longer affected (verified with an invalid value in ksmbd.conf).

Thanks,
Huiwen

在 2026/12/1 16:37, ChenXiaoSong 写道:
> We can return -EINVAL only when executing ksmbd.mountd.
> 
> ```
> --- a/tools/config_parser.c
> +++ b/tools/config_parser.c
> @@ -538,9 +538,11 @@ static int process_global_conf_kv(GHashTable *kv)
>                          global_conf.request_wq_mode = KSMBD_WQ_PERCPU;
>                  else if (!g_ascii_strcasecmp(v, "unbound"))
>                          global_conf.request_wq_mode = KSMBD_WQ_UNBOUND;
> -               else {
> +               else if (TOOL_IS_MOUNTD) {
>                          pr_err("Invalid server request workqueue 
> `%s'\n", v);
>                          return -EINVAL;
> +               } else {
> +                       pr_info("Ignoring invalid server request 
> workqueue `%s'\n", v);
>                  }
>          }
> ```
> 
> On 12/1/26 15:59, ChenXiaoSong wrote:
>> An invalid value for "server request workqueue" in ksmbd.conf will 
>> also affect the execution of ksmbd.adduser.
>>
>> ksmbd.conf:
>> ```
>> [global]
>>      server request workqueue = invalid_value
>> ```
>>
>> ```
>> ksmbd.adduser --add new_user
>> [ksmbd.adduser/5978]: ERROR: Invalid server request workqueue 
>> `invalid_value'
>> ```


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-01 10:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  5:54 [PATCH] ksmbd-tools: add the "server request workqueue" option Huiwen He
2026-12-01  7:59 ` ChenXiaoSong
2026-12-01  8:37   ` ChenXiaoSong
2026-12-01 10:36     ` hehuiwen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox