ksmbd: add smbd max io size parameter
authorNamjae Jeon <linkinjeon@kernel.org>
Mon, 16 May 2022 07:22:43 +0000 (16:22 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Feb 2023 07:27:24 +0000 (08:27 +0100)
commit 65bb45b97b578c8eed1ffa80caec84708df49729 upstream.

Add 'smbd max io size' parameter to adjust smbd-direct max read/write
size.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ksmbd/ksmbd_netlink.h
fs/ksmbd/transport_ipc.c
fs/ksmbd/transport_rdma.c
fs/ksmbd/transport_rdma.h

index 71bfb7d..192cb13 100644 (file)
@@ -104,7 +104,8 @@ struct ksmbd_startup_request {
                                         */
        __u32   sub_auth[3];            /* Subauth value for Security ID */
        __u32   smb2_max_credits;       /* MAX credits */
-       __u32   reserved[128];          /* Reserved room */
+       __u32   smbd_max_io_size;       /* smbd read write size */
+       __u32   reserved[127];          /* Reserved room */
        __u32   ifc_list_sz;            /* interfaces list size */
        __s8    ____payload[];
 };
index 3ad6881..7cb0eeb 100644 (file)
@@ -26,6 +26,7 @@
 #include "mgmt/ksmbd_ida.h"
 #include "connection.h"
 #include "transport_tcp.h"
+#include "transport_rdma.h"
 
 #define IPC_WAIT_TIMEOUT       (2 * HZ)
 
@@ -303,6 +304,8 @@ static int ipc_server_config_on_startup(struct ksmbd_startup_request *req)
                init_smb2_max_trans_size(req->smb2_max_trans);
        if (req->smb2_max_credits)
                init_smb2_max_credits(req->smb2_max_credits);
+       if (req->smbd_max_io_size)
+               init_smbd_max_io_size(req->smbd_max_io_size);
 
        ret = ksmbd_set_netbios_name(req->netbios_name);
        ret |= ksmbd_set_server_string(req->server_string);
index a2fd5a4..9d67419 100644 (file)
@@ -75,7 +75,7 @@ static int smb_direct_max_fragmented_recv_size = 1024 * 1024;
 /*  The maximum single-message size which can be received */
 static int smb_direct_max_receive_size = 8192;
 
-static int smb_direct_max_read_write_size = 1024 * 1024;
+static int smb_direct_max_read_write_size = SMBD_DEFAULT_IOSIZE;
 
 static int smb_direct_max_outstanding_rw_ops = 8;
 
@@ -201,6 +201,12 @@ struct smb_direct_rdma_rw_msg {
        struct scatterlist      sg_list[0];
 };
 
+void init_smbd_max_io_size(unsigned int sz)
+{
+       sz = clamp_val(sz, SMBD_MIN_IOSIZE, SMBD_MAX_IOSIZE);
+       smb_direct_max_read_write_size = sz;
+}
+
 static inline int get_buf_page_count(void *buf, int size)
 {
        return DIV_ROUND_UP((uintptr_t)buf + size, PAGE_SIZE) -
index 0fa8adc..04a7a37 100644 (file)
@@ -9,6 +9,10 @@
 
 #define SMB_DIRECT_PORT        5445
 
+#define SMBD_DEFAULT_IOSIZE (8 * 1024 * 1024)
+#define SMBD_MIN_IOSIZE (512 * 1024)
+#define SMBD_MAX_IOSIZE (16 * 1024 * 1024)
+
 /* SMB DIRECT negotiation request packet [MS-SMBD] 2.2.1 */
 struct smb_direct_negotiate_req {
        __le16 min_version;
@@ -54,10 +58,12 @@ struct smb_direct_data_transfer {
 int ksmbd_rdma_init(void);
 int ksmbd_rdma_destroy(void);
 bool ksmbd_rdma_capable_netdev(struct net_device *netdev);
+void init_smbd_max_io_size(unsigned int sz);
 #else
 static inline int ksmbd_rdma_init(void) { return 0; }
 static inline int ksmbd_rdma_destroy(void) { return 0; }
 static inline bool ksmbd_rdma_capable_netdev(struct net_device *netdev) { return false; }
+static inline void init_smbd_max_io_size(unsigned int sz) { }
 #endif
 
 #endif /* __KSMBD_TRANSPORT_RDMA_H__ */