Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Huiwen He <huiwen.he@linux.dev>
To: linux-cifs@vger.kernel.org
Cc: linkinjeon@kernel.org, stefan.chulski@broadcom.com,
	chenxiaosong@chenxiaosong.com
Subject: [PATCH v2] ksmbd-tools: add the "server request workqueue" option
Date: Tue,  1 Dec 2026 18:38:34 +0800	[thread overview]
Message-ID: <20261201103834.2280954-1-huiwen.he@linux.dev> (raw)

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.
Fall back to per-CPU for unrecognized values so a typo does not
prevent mountd or other tools from loading the configuration.

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

Signed-off-by: Huiwen He <hehuiwen@kylinos.cn>
---
Changes in v2:
- Fall back to per-CPU for unrecognized values so ksmbd.adduser can
  still load ksmbd.conf, as reported by ChenXiaoSong.

 include/linux/ksmbd_server.h |  8 +++++++-
 include/tools.h              |  1 +
 ksmbd.conf.5.in              | 10 ++++++++++
 ksmbd.conf.example           |  1 +
 mountd/ipc.c                 |  1 +
 tools/config_parser.c        |  9 +++++++++
 6 files changed, 29 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..17f1542 100644
--- a/ksmbd.conf.5.in
+++ b/ksmbd.conf.5.in
@@ -335,6 +335,16 @@ 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.
+Unrecognized values use the default.
+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..0f5140b 100644
--- a/tools/config_parser.c
+++ b/tools/config_parser.c
@@ -532,6 +532,14 @@ 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, "unbound"))
+			global_conf.request_wq_mode = KSMBD_WQ_UNBOUND;
+		else
+			global_conf.request_wq_mode = KSMBD_WQ_PERCPU;
+	}
+
 	if (group_kv_steal(kv, "server multi channel support", &k, &v)) {
 		if (cp_get_group_kv_bool(v))
 			global_conf.flags |=
@@ -594,6 +602,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

                 reply	other threads:[~2026-12-01 10:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201103834.2280954-1-huiwen.he@linux.dev \
    --to=huiwen.he@linux.dev \
    --cc=chenxiaosong@chenxiaosong.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=stefan.chulski@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox