linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] smb3: add rasize mount parameter to improve performance  of readahead
@ 2021-04-24 19:27 Steve French
  2021-04-24 20:08 ` Steve French
  2021-04-25  2:09 ` Matthew Wilcox
  0 siblings, 2 replies; 15+ messages in thread
From: Steve French @ 2021-04-24 19:27 UTC (permalink / raw)
  To: CIFS; +Cc: Jeff Layton, David Howells, Matthew Wilcox

In some cases readahead of more than the read size can help
(to allow parallel i/o of read ahead which can improve performance).

Using the buildbot test systems, this resulted in an average improvement
of 14% to the Windows server test target for the first 12 tests I
tried (no multichannel)
changing to 12MB rasize (read ahead size).   Similarly increasing the
rasize to 12MB to Azure (this time with multichannel, 4 channels)
improved performance 37%

Note that Ceph had already introduced a mount parameter "rasize" to
allow controlling this.  Add mount parameter "rasize" to cifs.ko to
allow control of read ahead (rasize defaults to 4MB which is typically
what it used to default to to the many servers whose rsize was that).

Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/cifsfs.c     |  1 +
 fs/cifs/fs_context.c | 25 ++++++++++++++++++++++++-
 fs/cifs/fs_context.h |  2 ++
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 39f4889a036b..a1217682da1f 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -649,6 +649,7 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
  seq_printf(s, ",rsize=%u", cifs_sb->ctx->rsize);
  seq_printf(s, ",wsize=%u", cifs_sb->ctx->wsize);
  seq_printf(s, ",bsize=%u", cifs_sb->ctx->bsize);
+ seq_printf(s, ",rasize=%u", cifs_sb->ctx->rasize);
  if (tcon->ses->server->min_offload)
  seq_printf(s, ",esize=%u", tcon->ses->server->min_offload);
  seq_printf(s, ",echo_interval=%lu",
diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
index 74758e954035..5ce1f7b854e7 100644
--- a/fs/cifs/fs_context.c
+++ b/fs/cifs/fs_context.c
@@ -137,6 +137,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {
  fsparam_u32("min_enc_offload", Opt_min_enc_offload),
  fsparam_u32("esize", Opt_min_enc_offload),
  fsparam_u32("bsize", Opt_blocksize),
+ fsparam_u32("rasize", Opt_rasize),
  fsparam_u32("rsize", Opt_rsize),
  fsparam_u32("wsize", Opt_wsize),
  fsparam_u32("actimeo", Opt_actimeo),
@@ -941,6 +942,26 @@ static int smb3_fs_context_parse_param(struct
fs_context *fc,
  ctx->bsize = result.uint_32;
  ctx->got_bsize = true;
  break;
+ case Opt_rasize:
+ /*
+ * readahead size realistically should never need to be
+ * less than 1M (CIFS_DEFAULT_IOSIZE) or greater than 32M
+ * (perhaps an exception should be considered in the
+ * for the case of a large number of channels
+ * when multichannel is negotiated) since that would lead
+ * to plenty of parallel I/O in flight to the server.
+ * Note that smaller read ahead sizes would
+ * hurt performance of common tools like cp and scp
+ * which often trigger sequential i/o with read ahead
+ */
+ if ((result.uint_32 > (8 * SMB3_DEFAULT_IOSIZE)) ||
+     (result.uint_32 < CIFS_DEFAULT_IOSIZE)) {
+ cifs_errorf(fc, "%s: Invalid rasize %d vs. %d\n",
+ __func__, result.uint_32, SMB3_DEFAULT_IOSIZE);
+ goto cifs_parse_mount_err;
+ }
+ ctx->rasize = result.uint_32;
+ break;
  case Opt_rsize:
  ctx->rsize = result.uint_32;
  ctx->got_rsize = true;
@@ -1377,7 +1398,9 @@ int smb3_init_fs_context(struct fs_context *fc)
  ctx->cred_uid = current_uid();
  ctx->linux_uid = current_uid();
  ctx->linux_gid = current_gid();
- ctx->bsize = 1024 * 1024; /* can improve cp performance significantly */
+ /* By default 4MB read ahead size, 1MB block size */
+ ctx->bsize = CIFS_DEFAULT_IOSIZE; /* can improve cp performance
significantly */
+ ctx->rasize = SMB3_DEFAULT_IOSIZE; /* can improve sequential read ahead */

  /*
  * default to SFM style remapping of seven reserved characters
diff --git a/fs/cifs/fs_context.h b/fs/cifs/fs_context.h
index 56d7a75e2390..2a71c8e411ac 100644
--- a/fs/cifs/fs_context.h
+++ b/fs/cifs/fs_context.h
@@ -120,6 +120,7 @@ enum cifs_param {
  Opt_dirmode,
  Opt_min_enc_offload,
  Opt_blocksize,
+ Opt_rasize,
  Opt_rsize,
  Opt_wsize,
  Opt_actimeo,
@@ -235,6 +236,7 @@ struct smb3_fs_context {
  /* reuse existing guid for multichannel */
  u8 client_guid[SMB2_CLIENT_GUID_SIZE];
  unsigned int bsize;
+ unsigned int rasize;
  unsigned int rsize;
  unsigned int wsize;
  unsigned int min_offload;

-- 
Thanks,

Steve

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-05-01 18:51 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-24 19:27 [PATCH] smb3: add rasize mount parameter to improve performance of readahead Steve French
2021-04-24 20:08 ` Steve French
2021-04-25  2:09 ` Matthew Wilcox
2021-04-25  2:36   ` Steve French
2021-04-25 16:50     ` Steve French
2021-04-26  4:52       ` Shyam Prasad N
2021-04-26 11:54         ` Matthew Wilcox
2021-04-27  2:23           ` Steve French
2021-04-30 10:49           ` Shyam Prasad N
2021-04-30 11:59             ` Matthew Wilcox
2021-04-30 12:53               ` Shyam Prasad N
2021-04-30 19:22               ` Steve French
2021-05-01 18:35                 ` Matthew Wilcox
2021-05-01 18:47                   ` Steve French
2021-05-01 18:50                     ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).