Skip to content

Commit 3d62123

Browse files
author
Steve French
committed
smb3: update default requested iosize to 4MB from 1MB for recent dialects
Modern servers often support 8MB as maximum i/o size, and we see some performance benefits (my testing showed 1 to 13% on write paths, and 1 to 3% on read paths for increasing the default to 4MB). If server doesn't support larger i/o size, during negotiate protocol it is already set correctly to the server's maximum if lower than 4MB. Signed-off-by: Steve French <stfrench@microsoft.com> Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
1 parent 6e4d3bb commit 3d62123

File tree

2 files changed

+55
-4
lines changed

2 files changed

+55
-4
lines changed

fs/cifs/cifsglob.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ compare_mid(__u16 mid, const struct smb_hdr *smb)
799799
* a single wsize request with a single call.
800800
*/
801801
#define CIFS_DEFAULT_IOSIZE (1024 * 1024)
802+
#define SMB3_DEFAULT_IOSIZE (4 * 1024 * 1024)
802803

803804
/*
804805
* Windows only supports a max of 60kb reads and 65535 byte writes. Default to

fs/cifs/smb2ops.c

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,31 @@ smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
280280
return wsize;
281281
}
282282

283+
static unsigned int
284+
smb3_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
285+
{
286+
struct TCP_Server_Info *server = tcon->ses->server;
287+
unsigned int wsize;
288+
289+
/* start with specified wsize, or default */
290+
wsize = volume_info->wsize ? volume_info->wsize : SMB3_DEFAULT_IOSIZE;
291+
wsize = min_t(unsigned int, wsize, server->max_write);
292+
#ifdef CONFIG_CIFS_SMB_DIRECT
293+
if (server->rdma) {
294+
if (server->sign)
295+
wsize = min_t(unsigned int,
296+
wsize, server->smbd_conn->max_fragmented_send_size);
297+
else
298+
wsize = min_t(unsigned int,
299+
wsize, server->smbd_conn->max_readwrite_size);
300+
}
301+
#endif
302+
if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))
303+
wsize = min_t(unsigned int, wsize, SMB2_MAX_BUFFER_SIZE);
304+
305+
return wsize;
306+
}
307+
283308
static unsigned int
284309
smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
285310
{
@@ -306,6 +331,31 @@ smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
306331
return rsize;
307332
}
308333

334+
static unsigned int
335+
smb3_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
336+
{
337+
struct TCP_Server_Info *server = tcon->ses->server;
338+
unsigned int rsize;
339+
340+
/* start with specified rsize, or default */
341+
rsize = volume_info->rsize ? volume_info->rsize : SMB3_DEFAULT_IOSIZE;
342+
rsize = min_t(unsigned int, rsize, server->max_read);
343+
#ifdef CONFIG_CIFS_SMB_DIRECT
344+
if (server->rdma) {
345+
if (server->sign)
346+
rsize = min_t(unsigned int,
347+
rsize, server->smbd_conn->max_fragmented_recv_size);
348+
else
349+
rsize = min_t(unsigned int,
350+
rsize, server->smbd_conn->max_readwrite_size);
351+
}
352+
#endif
353+
354+
if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))
355+
rsize = min_t(unsigned int, rsize, SMB2_MAX_BUFFER_SIZE);
356+
357+
return rsize;
358+
}
309359

310360
static int
311361
parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
@@ -3436,8 +3486,8 @@ struct smb_version_operations smb30_operations = {
34363486
.downgrade_oplock = smb2_downgrade_oplock,
34373487
.need_neg = smb2_need_neg,
34383488
.negotiate = smb2_negotiate,
3439-
.negotiate_wsize = smb2_negotiate_wsize,
3440-
.negotiate_rsize = smb2_negotiate_rsize,
3489+
.negotiate_wsize = smb3_negotiate_wsize,
3490+
.negotiate_rsize = smb3_negotiate_rsize,
34413491
.sess_setup = SMB2_sess_setup,
34423492
.logoff = SMB2_logoff,
34433493
.tree_connect = SMB2_tcon,
@@ -3540,8 +3590,8 @@ struct smb_version_operations smb311_operations = {
35403590
.downgrade_oplock = smb2_downgrade_oplock,
35413591
.need_neg = smb2_need_neg,
35423592
.negotiate = smb2_negotiate,
3543-
.negotiate_wsize = smb2_negotiate_wsize,
3544-
.negotiate_rsize = smb2_negotiate_rsize,
3593+
.negotiate_wsize = smb3_negotiate_wsize,
3594+
.negotiate_rsize = smb3_negotiate_rsize,
35453595
.sess_setup = SMB2_sess_setup,
35463596
.logoff = SMB2_logoff,
35473597
.tree_connect = SMB2_tcon,

0 commit comments

Comments
 (0)