Skip to content

Commit 65bb45b

Browse files
namjaejeonsmfrench
authored andcommitted
ksmbd: add smbd max io size parameter
Add 'smbd max io size' parameter to adjust smbd-direct max read/write size. Signed-off-by: Namjae Jeon <[email protected]> Reviewed-by: Hyunchul Lee <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 65ca7a3 commit 65bb45b

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

fs/ksmbd/ksmbd_netlink.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ struct ksmbd_startup_request {
104104
*/
105105
__u32 sub_auth[3]; /* Subauth value for Security ID */
106106
__u32 smb2_max_credits; /* MAX credits */
107-
__u32 reserved[128]; /* Reserved room */
107+
__u32 smbd_max_io_size; /* smbd read write size */
108+
__u32 reserved[127]; /* Reserved room */
108109
__u32 ifc_list_sz; /* interfaces list size */
109110
__s8 ____payload[];
110111
};

fs/ksmbd/transport_ipc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "mgmt/ksmbd_ida.h"
2727
#include "connection.h"
2828
#include "transport_tcp.h"
29+
#include "transport_rdma.h"
2930

3031
#define IPC_WAIT_TIMEOUT (2 * HZ)
3132

@@ -303,6 +304,8 @@ static int ipc_server_config_on_startup(struct ksmbd_startup_request *req)
303304
init_smb2_max_trans_size(req->smb2_max_trans);
304305
if (req->smb2_max_credits)
305306
init_smb2_max_credits(req->smb2_max_credits);
307+
if (req->smbd_max_io_size)
308+
init_smbd_max_io_size(req->smbd_max_io_size);
306309

307310
ret = ksmbd_set_netbios_name(req->netbios_name);
308311
ret |= ksmbd_set_server_string(req->server_string);

fs/ksmbd/transport_rdma.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static int smb_direct_max_fragmented_recv_size = 1024 * 1024;
8080
/* The maximum single-message size which can be received */
8181
static int smb_direct_max_receive_size = 8192;
8282

83-
static int smb_direct_max_read_write_size = 8 * 1024 * 1024;
83+
static int smb_direct_max_read_write_size = SMBD_DEFAULT_IOSIZE;
8484

8585
static LIST_HEAD(smb_direct_device_list);
8686
static DEFINE_RWLOCK(smb_direct_device_lock);
@@ -214,6 +214,12 @@ struct smb_direct_rdma_rw_msg {
214214
struct scatterlist sg_list[];
215215
};
216216

217+
void init_smbd_max_io_size(unsigned int sz)
218+
{
219+
sz = clamp_val(sz, SMBD_MIN_IOSIZE, SMBD_MAX_IOSIZE);
220+
smb_direct_max_read_write_size = sz;
221+
}
222+
217223
static inline int get_buf_page_count(void *buf, int size)
218224
{
219225
return DIV_ROUND_UP((uintptr_t)buf + size, PAGE_SIZE) -

fs/ksmbd/transport_rdma.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
#ifndef __KSMBD_TRANSPORT_RDMA_H__
88
#define __KSMBD_TRANSPORT_RDMA_H__
99

10+
#define SMBD_DEFAULT_IOSIZE (8 * 1024 * 1024)
11+
#define SMBD_MIN_IOSIZE (512 * 1024)
12+
#define SMBD_MAX_IOSIZE (16 * 1024 * 1024)
13+
1014
/* SMB DIRECT negotiation request packet [MS-SMBD] 2.2.1 */
1115
struct smb_direct_negotiate_req {
1216
__le16 min_version;
@@ -52,10 +56,12 @@ struct smb_direct_data_transfer {
5256
int ksmbd_rdma_init(void);
5357
void ksmbd_rdma_destroy(void);
5458
bool ksmbd_rdma_capable_netdev(struct net_device *netdev);
59+
void init_smbd_max_io_size(unsigned int sz);
5560
#else
5661
static inline int ksmbd_rdma_init(void) { return 0; }
5762
static inline int ksmbd_rdma_destroy(void) { return 0; }
5863
static inline bool ksmbd_rdma_capable_netdev(struct net_device *netdev) { return false; }
64+
static inline void init_smbd_max_io_size(unsigned int sz) { }
5965
#endif
6066

6167
#endif /* __KSMBD_TRANSPORT_RDMA_H__ */

0 commit comments

Comments
 (0)