diff mbox series

ksmbd-tools: add support for smb2 max credits parameter

Message ID 20211229141544.11729-1-linkinjeon@kernel.org (mailing list archive)
State New, archived
Headers show
Series ksmbd-tools: add support for smb2 max credits parameter | expand

Commit Message

Namjae Jeon Dec. 29, 2021, 2:15 p.m. UTC
Add smb2 max credits parameter to adjust maximum credits value to limit
number of outstanding requests.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
 Documentation/configuration.txt | 3 +++
 include/ksmbdtools.h            | 1 +
 include/linux/ksmbd_server.h    | 1 +
 lib/config_parser.c             | 5 +++++
 mountd/ipc.c                    | 1 +
 5 files changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/Documentation/configuration.txt b/Documentation/configuration.txt
index 5a15ce6..9580bf1 100644
--- a/Documentation/configuration.txt
+++ b/Documentation/configuration.txt
@@ -109,6 +109,9 @@  Define ksmbd configuration parameters list.
 		This boolean parameter controls whether ksmbd will support
 		SMB3 multi-channel. Warn that this is experimental feature
 		which means data can be corrupted under race conditions.
+	- smb2 max credits (default: 8192)
+		This option controls the maximum number of outstanding
+		simultaneous SMB2 operations.
 
 
 * Supported [share] level parameters list:
diff --git a/include/ksmbdtools.h b/include/ksmbdtools.h
index 5a12368..c51673e 100644
--- a/include/ksmbdtools.h
+++ b/include/ksmbdtools.h
@@ -52,6 +52,7 @@  struct smbconf_global {
 	unsigned int		smb2_max_read;
 	unsigned int		smb2_max_write;
 	unsigned int		smb2_max_trans;
+	unsigned int		smb2_max_credits;
 	unsigned int		share_fake_fscaps;
 	unsigned int		gen_subauth[3];
 	char			*krb5_keytab_file;
diff --git a/include/linux/ksmbd_server.h b/include/linux/ksmbd_server.h
index b1c5e63..647cfee 100644
--- a/include/linux/ksmbd_server.h
+++ b/include/linux/ksmbd_server.h
@@ -46,6 +46,7 @@  struct ksmbd_startup_request {
 	__u32	smb2_max_trans;
 	__u32	share_fake_fscaps;
 	__u32	sub_auth[3];
+	__u32	smb2_max_credits;
 	__u32	ifc_list_sz;
 	__s8	____payload[];
 };
diff --git a/lib/config_parser.c b/lib/config_parser.c
index ebbe2dd..aa1dbf2 100644
--- a/lib/config_parser.c
+++ b/lib/config_parser.c
@@ -548,6 +548,11 @@  static void global_group_kv(gpointer _k, gpointer _v, gpointer user_data)
 
 		return;
 	}
+
+	if (!cp_key_cmp(_k, "smb2 max credits")) {
+		global_conf.smb2_max_credits = memparse(_v);
+		return;
+	}
 }
 
 static void fixup_missing_global_group(void)
diff --git a/mountd/ipc.c b/mountd/ipc.c
index 15c59f5..eded431 100644
--- a/mountd/ipc.c
+++ b/mountd/ipc.c
@@ -173,6 +173,7 @@  static int ipc_ksmbd_starting_up(void)
 	ev->smb2_max_trans = global_conf.smb2_max_trans;
 	ev->share_fake_fscaps = global_conf.share_fake_fscaps;
 	memcpy(ev->sub_auth, global_conf.gen_subauth, sizeof(ev->sub_auth));
+	ev->smb2_max_credits = global_conf.smb2_max_credits;
 
 	if (global_conf.server_min_protocol) {
 		strncpy(ev->min_prot,