[PATCH 29/50] CIFS: Respect max buf size for SMB2 read and write

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Pavel Shilovsky <piastryyy@xxxxxxxxx>

Signed-off-by: Pavel Shilovsky <piastryyy@xxxxxxxxx>
---
 fs/cifs/connect.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 9015009..3a217d7 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -3093,6 +3093,18 @@ cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *pvolume_info)
 	unsigned int wsize = pvolume_info->wsize ? pvolume_info->wsize :
 				CIFS_DEFAULT_IOSIZE;
 
+#ifdef CONFIG_CIFS_SMB2
+	if (tcon->ses->server->is_smb2) {
+		wsize = min_t(unsigned int, wsize, server->max_write);
+		/*
+		 * limit write size to 2 ** 16, because we don't support
+		 * multicredit requests now.
+		 */
+		wsize = min_t(unsigned int, wsize, 2 << 15);
+		return wsize;
+	}
+#endif
+
 	/* can server support 24-bit write sizes? (via UNIX extensions) */
 	if (!tcon->unix_ext || !(unix_cap & CIFS_UNIX_LARGE_WRITE_CAP))
 		wsize = min_t(unsigned int, wsize, CIFS_MAX_RFC1002_WSIZE);
@@ -3121,6 +3133,20 @@ cifs_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *pvolume_info)
 	struct TCP_Server_Info *server = tcon->ses->server;
 	unsigned int rsize, defsize;
 
+#ifdef CONFIG_CIFS_SMB2
+	if (tcon->ses->server->is_smb2) {
+		rsize = pvolume_info->rsize ? pvolume_info->rsize :
+			CIFS_DEFAULT_IOSIZE;
+		rsize = min_t(unsigned int, rsize, server->max_read);
+		/*
+		 * limit write size to 2 ** 16, because we don't support
+		 * multicredit requests now.
+		 */
+		rsize = min_t(unsigned int, rsize, 2 << 15);
+		return rsize;
+	}
+#endif
+
 	/*
 	 * Set default value...
 	 *
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux