Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH][SMB3]Adjust cifssb maximum read size
@ 2022-03-07 18:46 Rohith Surabattula
  2022-03-07 18:58 ` Paulo Alcantara
  2022-03-07 19:01 ` Steve French
  0 siblings, 2 replies; 4+ messages in thread
From: Rohith Surabattula @ 2022-03-07 18:46 UTC (permalink / raw)
  To: linux-cifs, Steve French, Shyam Prasad N, ronnie sahlberg,
	Paulo Alcantara

[-- Attachment #1: Type: text/plain, Size: 325 bytes --]

Hi All,

When session gets reconnected during mount then read size in super
block fs context gets set to zero and after negotiate, rsize is not
modified which results in incorrect read with requested bytes as zero.

Attaching 2 patches, one for releases before 5.17 and other for latest.
Please take a look.

Regards,
Rohith

[-- Attachment #2: SMB3-After-5.17-Adjust-cifssb-maximum-read-size.patch --]
[-- Type: application/octet-stream, Size: 1935 bytes --]

From 9405927193198cc03a6ceeae1a19fa9dae25a6cc Mon Sep 17 00:00:00 2001
From: Rohith Surabattula <rohiths@microsoft.com>
Date: Mon, 7 Mar 2022 18:37:22 +0000
Subject: [PATCH] [SMB3][After 5.17]Adjust cifssb maximum read size

When session gets reconnected during mount then read size in super block fs context
gets set to zero and after negotiate, rsize is not modified which results in incorrect
read with requested bytes as zero.

Signed-off-by: Rohith Surabattula <rohiths@microsoft.com>
---
 fs/cifs/cifsfs.c | 2 ++
 fs/cifs/file.c   | 6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 082c21478686..dfcef71278a1 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -210,6 +210,8 @@ cifs_read_super(struct super_block *sb)
 	if (rc)
 		goto out_no_root;
 	/* tune readahead according to rsize if readahead size not set on mount */
+	if (cifs_sb->ctx->rsize == 0)
+		cifs_sb->ctx->rsize = tcon->ses->server->ops->negotiate_rsize(tcon, cifs_sb->ctx);
 	if (cifs_sb->ctx->rasize)
 		sb->s_bdi->ra_pages = cifs_sb->ctx->rasize / PAGE_SIZE;
 	else
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index e7af802dcfa6..c9f4fa41f1c3 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -3740,6 +3740,9 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file,
 				break;
 		}
 
+		if (cifs_sb->ctx->rsize == 0)
+			cifs_sb->ctx->rsize = server->ops->negotiate_rsize(tlink_tcon(open_file->tlink), cifs_sb->ctx);
+
 		rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize,
 						   &rsize, credits);
 		if (rc)
@@ -4474,6 +4477,9 @@ static void cifs_readahead(struct readahead_control *ractl)
 			}
 		}
 
+		if (cifs_sb->ctx->rsize == 0)
+			cifs_sb->ctx->rsize = server->ops->negotiate_rsize(tlink_tcon(open_file->tlink), cifs_sb->ctx);
+
 		rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize,
 						   &rsize, credits);
 		if (rc)
-- 
2.32.0


[-- Attachment #3: SMB3-Before-5.17-Adjust-cifssb-maximum-read-size.patch --]
[-- Type: application/octet-stream, Size: 1958 bytes --]

From aa12841d59dc4b52d4035676e95ce9d051fe30d1 Mon Sep 17 00:00:00 2001
From: Rohith Surabattula <rohiths@microsoft.com>
Date: Mon, 7 Mar 2022 17:30:26 +0000
Subject: [PATCH] [SMB3][Before 5.17]Adjust cifssb maximum read size

When session gets reconnected during mount then read size in super block fs context
gets set to zero and after negotiate, rsize is not modified which results in incorrect
read with requested bytes as zero.

Signed-off-by: Rohith Surabattula <rohiths@microsoft.com>
---
 fs/cifs/cifsfs.c | 2 ++
 fs/cifs/file.c   | 6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 2ffcb29d5c8f..29f4f419d5fa 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -219,6 +219,8 @@ cifs_read_super(struct super_block *sb)
 	if (rc)
 		goto out_no_root;
 	/* tune readahead according to rsize if readahead size not set on mount */
+	if (cifs_sb->ctx->rsize == 0)
+		cifs_sb->ctx->rsize = tcon->ses->server->ops->negotiate_rsize(tcon, cifs_sb->ctx);
 	if (cifs_sb->ctx->rasize)
 		sb->s_bdi->ra_pages = cifs_sb->ctx->rasize / PAGE_SIZE;
 	else
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 0cc05bf81189..00ba0f46c5db 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -3720,6 +3720,9 @@ cifs_send_async_read(loff_t offset, size_t len, struct cifsFileInfo *open_file,
 				break;
 		}
 
+		if (cifs_sb->ctx->rsize == 0)
+			cifs_sb->ctx->rsize = server->ops->negotiate_rsize(tlink_tcon(open_file->tlink), cifs_sb->ctx);
+
 		rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize,
 						   &rsize, credits);
 		if (rc)
@@ -4491,6 +4494,9 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
 				break;
 		}
 
+		if (cifs_sb->ctx->rsize == 0)
+			cifs_sb->ctx->rsize = server->ops->negotiate_rsize(tlink_tcon(open_file->tlink), cifs_sb->ctx);
+
 		rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize,
 						   &rsize, credits);
 		if (rc)
-- 
2.32.0


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

end of thread, other threads:[~2022-03-07 19:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-07 18:46 [PATCH][SMB3]Adjust cifssb maximum read size Rohith Surabattula
2022-03-07 18:58 ` Paulo Alcantara
2022-03-07 19:33   ` Steve French
2022-03-07 19:01 ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox