Skip to content

Commit b8d64f8

Browse files
committed
smb3: add rasize mount parameter to improve readahead performance
In some cases readahead of more than the read size can help (to allow parallel i/o of read ahead which can improve performance). Ceph introduced a mount parameter "rasize" to allow controlling this. Add mount parameter "rasize" to allow control of amount of readahead requested of the server. If rasize not set, rasize defaults to negotiated rsize as before. Reviewed-by: Shyam Prasad N <sprasad@microsoft.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 423333b commit b8d64f8

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

fs/cifs/cifsfs.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,11 @@ cifs_read_super(struct super_block *sb)
217217
rc = super_setup_bdi(sb);
218218
if (rc)
219219
goto out_no_root;
220-
/* tune readahead according to rsize */
221-
sb->s_bdi->ra_pages = cifs_sb->ctx->rsize / PAGE_SIZE;
220+
/* tune readahead according to rsize if readahead size not set on mount */
221+
if (cifs_sb->ctx->rasize)
222+
sb->s_bdi->ra_pages = cifs_sb->ctx->rasize / PAGE_SIZE;
223+
else
224+
sb->s_bdi->ra_pages = cifs_sb->ctx->rsize / PAGE_SIZE;
222225

223226
sb->s_blocksize = CIFS_MAX_MSGSIZE;
224227
sb->s_blocksize_bits = 14; /* default 2**14 = CIFS_MAX_MSGSIZE */
@@ -649,6 +652,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
649652
seq_printf(s, ",rsize=%u", cifs_sb->ctx->rsize);
650653
seq_printf(s, ",wsize=%u", cifs_sb->ctx->wsize);
651654
seq_printf(s, ",bsize=%u", cifs_sb->ctx->bsize);
655+
if (cifs_sb->ctx->rasize)
656+
seq_printf(s, ",rasize=%u", cifs_sb->ctx->rasize);
652657
if (tcon->ses->server->min_offload)
653658
seq_printf(s, ",esize=%u", tcon->ses->server->min_offload);
654659
seq_printf(s, ",echo_interval=%lu",

fs/cifs/fs_context.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {
137137
fsparam_u32("min_enc_offload", Opt_min_enc_offload),
138138
fsparam_u32("esize", Opt_min_enc_offload),
139139
fsparam_u32("bsize", Opt_blocksize),
140+
fsparam_u32("rasize", Opt_rasize),
140141
fsparam_u32("rsize", Opt_rsize),
141142
fsparam_u32("wsize", Opt_wsize),
142143
fsparam_u32("actimeo", Opt_actimeo),
@@ -941,6 +942,26 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
941942
ctx->bsize = result.uint_32;
942943
ctx->got_bsize = true;
943944
break;
945+
case Opt_rasize:
946+
/*
947+
* readahead size realistically should never need to be
948+
* less than 1M (CIFS_DEFAULT_IOSIZE) or greater than 32M
949+
* (perhaps an exception should be considered in the
950+
* for the case of a large number of channels
951+
* when multichannel is negotiated) since that would lead
952+
* to plenty of parallel I/O in flight to the server.
953+
* Note that smaller read ahead sizes would
954+
* hurt performance of common tools like cp and scp
955+
* which often trigger sequential i/o with read ahead
956+
*/
957+
if ((result.uint_32 > (8 * SMB3_DEFAULT_IOSIZE)) ||
958+
(result.uint_32 < CIFS_DEFAULT_IOSIZE)) {
959+
cifs_errorf(fc, "%s: Invalid rasize %d vs. %d\n",
960+
__func__, result.uint_32, SMB3_DEFAULT_IOSIZE);
961+
goto cifs_parse_mount_err;
962+
}
963+
ctx->rasize = result.uint_32;
964+
break;
944965
case Opt_rsize:
945966
ctx->rsize = result.uint_32;
946967
ctx->got_rsize = true;
@@ -1377,7 +1398,9 @@ int smb3_init_fs_context(struct fs_context *fc)
13771398
ctx->cred_uid = current_uid();
13781399
ctx->linux_uid = current_uid();
13791400
ctx->linux_gid = current_gid();
1380-
ctx->bsize = 1024 * 1024; /* can improve cp performance significantly */
1401+
/* By default 4MB read ahead size, 1MB block size */
1402+
ctx->bsize = CIFS_DEFAULT_IOSIZE; /* can improve cp performance significantly */
1403+
ctx->rasize = 0; /* 0 = use default (ie negotiated rsize) for read ahead pages */
13811404

13821405
/*
13831406
* default to SFM style remapping of seven reserved characters

fs/cifs/fs_context.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ enum cifs_param {
120120
Opt_dirmode,
121121
Opt_min_enc_offload,
122122
Opt_blocksize,
123+
Opt_rasize,
123124
Opt_rsize,
124125
Opt_wsize,
125126
Opt_actimeo,
@@ -235,6 +236,7 @@ struct smb3_fs_context {
235236
/* reuse existing guid for multichannel */
236237
u8 client_guid[SMB2_CLIENT_GUID_SIZE];
237238
unsigned int bsize;
239+
unsigned int rasize;
238240
unsigned int rsize;
239241
unsigned int wsize;
240242
unsigned int min_offload;

0 commit comments

Comments
 (0)