aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonnie Sahlberg <lsahlber@redhat.com>2018-04-09 04:06:26 -0400
committerSteve French <smfrench@gmail.com>2018-04-12 18:06:33 -0400
commit2e96467d9eb189b38954bcbbf1ee16762914f4cb (patch)
tree84a179ad8e3d58c31266b8852d8db976b632e186
parent5100d8a3fe034845926266a4e7f5bdcbb859088b (diff)
cifs: add pdu_size to the TCP_Server_Info structure
and get rid of some get_rfc1002_length() in smb2 Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <smfrench@gmail.com> Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
-rw-r--r--fs/cifs/cifsglob.h2
-rw-r--r--fs/cifs/cifssmb.c2
-rw-r--r--fs/cifs/connect.c3
-rw-r--r--fs/cifs/smb2ops.c8
4 files changed, 9 insertions, 6 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 56fee0330afc..5c1568ccd67d 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -665,6 +665,8 @@ struct TCP_Server_Info {
665 struct delayed_work echo; /* echo ping workqueue job */ 665 struct delayed_work echo; /* echo ping workqueue job */
666 char *smallbuf; /* pointer to current "small" buffer */ 666 char *smallbuf; /* pointer to current "small" buffer */
667 char *bigbuf; /* pointer to current "big" buffer */ 667 char *bigbuf; /* pointer to current "big" buffer */
668 /* Total size of this PDU. Only valid from cifs_demultiplex_thread */
669 unsigned int pdu_size;
668 unsigned int total_read; /* total amount of data read in this pass */ 670 unsigned int total_read; /* total amount of data read in this pass */
669#ifdef CONFIG_CIFS_FSCACHE 671#ifdef CONFIG_CIFS_FSCACHE
670 struct fscache_cookie *fscache; /* client index cache cookie */ 672 struct fscache_cookie *fscache; /* client index cache cookie */
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index abdc93d4fee8..890b3a40c79c 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -1456,7 +1456,7 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
1456 unsigned int data_offset, data_len; 1456 unsigned int data_offset, data_len;
1457 struct cifs_readdata *rdata = mid->callback_data; 1457 struct cifs_readdata *rdata = mid->callback_data;
1458 char *buf = server->smallbuf; 1458 char *buf = server->smallbuf;
1459 unsigned int buflen = get_rfc1002_length(buf) + 1459 unsigned int buflen = server->pdu_size +
1460 server->vals->header_preamble_size; 1460 server->vals->header_preamble_size;
1461 bool use_rdma_mr = false; 1461 bool use_rdma_mr = false;
1462 1462
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 4e0808f40195..48012a0addf1 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -772,7 +772,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid)
772{ 772{
773 int length; 773 int length;
774 char *buf = server->smallbuf; 774 char *buf = server->smallbuf;
775 unsigned int pdu_length = get_rfc1002_length(buf); 775 unsigned int pdu_length = server->pdu_size;
776 776
777 /* make sure this will fit in a large buffer */ 777 /* make sure this will fit in a large buffer */
778 if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) - 778 if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) -
@@ -881,6 +881,7 @@ cifs_demultiplex_thread(void *p)
881 * so we can now interpret the length field. 881 * so we can now interpret the length field.
882 */ 882 */
883 pdu_length = get_rfc1002_length(buf); 883 pdu_length = get_rfc1002_length(buf);
884 server->pdu_size = pdu_length;
884 885
885 cifs_dbg(FYI, "RFC1002 header 0x%x\n", pdu_length); 886 cifs_dbg(FYI, "RFC1002 header 0x%x\n", pdu_length);
886 if (!is_smb_response(server, buf[0])) 887 if (!is_smb_response(server, buf[0]))
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 968b1d43a1ea..def84fed3571 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -2550,7 +2550,7 @@ receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid)
2550 unsigned int npages; 2550 unsigned int npages;
2551 struct page **pages; 2551 struct page **pages;
2552 unsigned int len; 2552 unsigned int len;
2553 unsigned int buflen = get_rfc1002_length(buf) + server->vals->header_preamble_size; 2553 unsigned int buflen = server->pdu_size + server->vals->header_preamble_size;
2554 int rc; 2554 int rc;
2555 int i = 0; 2555 int i = 0;
2556 2556
@@ -2624,7 +2624,7 @@ receive_encrypted_standard(struct TCP_Server_Info *server,
2624{ 2624{
2625 int length; 2625 int length;
2626 char *buf = server->smallbuf; 2626 char *buf = server->smallbuf;
2627 unsigned int pdu_length = get_rfc1002_length(buf); 2627 unsigned int pdu_length = server->pdu_size;
2628 unsigned int buf_size; 2628 unsigned int buf_size;
2629 struct mid_q_entry *mid_entry; 2629 struct mid_q_entry *mid_entry;
2630 2630
@@ -2668,7 +2668,7 @@ static int
2668smb3_receive_transform(struct TCP_Server_Info *server, struct mid_q_entry **mid) 2668smb3_receive_transform(struct TCP_Server_Info *server, struct mid_q_entry **mid)
2669{ 2669{
2670 char *buf = server->smallbuf; 2670 char *buf = server->smallbuf;
2671 unsigned int pdu_length = get_rfc1002_length(buf); 2671 unsigned int pdu_length = server->pdu_size;
2672 struct smb2_transform_hdr *tr_hdr = (struct smb2_transform_hdr *)buf; 2672 struct smb2_transform_hdr *tr_hdr = (struct smb2_transform_hdr *)buf;
2673 unsigned int orig_len = le32_to_cpu(tr_hdr->OriginalMessageSize); 2673 unsigned int orig_len = le32_to_cpu(tr_hdr->OriginalMessageSize);
2674 2674
@@ -2699,7 +2699,7 @@ smb3_handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid)
2699{ 2699{
2700 char *buf = server->large_buf ? server->bigbuf : server->smallbuf; 2700 char *buf = server->large_buf ? server->bigbuf : server->smallbuf;
2701 2701
2702 return handle_read_data(server, mid, buf, get_rfc1002_length(buf) + 2702 return handle_read_data(server, mid, buf, server->pdu_size +
2703 server->vals->header_preamble_size, 2703 server->vals->header_preamble_size,
2704 NULL, 0, 0); 2704 NULL, 0, 0);
2705} 2705}