All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: linux-cifs <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: Steve French <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: [PATCH 13/19] cifs: remove rfc1002 header from smb2 read/write requests
Date: Thu,  2 Nov 2017 18:03:06 +1100	[thread overview]
Message-ID: <20171102070312.18903-14-lsahlber@redhat.com> (raw)
In-Reply-To: <20171102070312.18903-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

Signed-off-by: Ronnie Sahlberg <lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
 fs/cifs/smb2pdu.c | 42 ++++++++++++++++++++----------------------
 fs/cifs/smb2pdu.h |  2 +-
 2 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 5dc0ec2cad1e..b0d4e9d15e29 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -2469,7 +2469,7 @@ smb2_new_read_req(void **buf, unsigned int *total_len,
 	struct smb2_sync_hdr *shdr;
 
 	rc = smb2_plain_req_init(SMB2_READ, io_parms->tcon, (void **) &req,
-				 total_len);
+			     total_len);
 	if (rc)
 		return rc;
 	if (io_parms->tcon->ses->server == NULL)
@@ -2679,7 +2679,7 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
 
 	iov[0].iov_base = &req_len;
 	iov[0].iov_len = sizeof(__be32);
-	iov[1].iov_base = req;
+	iov[1].iov_base = (char *)req;
 	iov[1].iov_len = total_len;
 
 	rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
@@ -2784,8 +2784,10 @@ smb2_async_writev(struct cifs_writedata *wdata,
 	struct TCP_Server_Info *server = tcon->ses->server;
 	struct kvec iov[2];
 	struct smb_rqst rqst = { };
+	unsigned int total_len;
+	__be32 rfc1002_marker;
 
-	rc = small_smb2_init(SMB2_WRITE, tcon, (void **) &req);
+	rc = smb2_plain_req_init(SMB2_WRITE, tcon, (void **) &req, &total_len);
 	if (rc) {
 		if (rc == -EAGAIN && wdata->credits) {
 			/* credits was reset by reconnect */
@@ -2801,7 +2803,7 @@ smb2_async_writev(struct cifs_writedata *wdata,
 	if (encryption_required(tcon))
 		flags |= CIFS_TRANSFORM_REQ;
 
-	shdr = get_sync_hdr(req);
+	shdr = (struct smb2_sync_hdr *)req;
 	shdr->ProcessId = cpu_to_le32(wdata->cfile->pid);
 
 	req->PersistentFileId = wdata->cfile->fid.persistent_fid;
@@ -2810,16 +2812,16 @@ smb2_async_writev(struct cifs_writedata *wdata,
 	req->WriteChannelInfoLength = 0;
 	req->Channel = 0;
 	req->Offset = cpu_to_le64(wdata->offset);
-	/* 4 for rfc1002 length field */
 	req->DataOffset = cpu_to_le16(
-				offsetof(struct smb2_write_req, Buffer) - 4);
+				offsetof(struct smb2_write_req, Buffer));
 	req->RemainingBytes = 0;
 
 	/* 4 for rfc1002 length field and 1 for Buffer */
 	iov[0].iov_len = 4;
-	iov[0].iov_base = req;
-	iov[1].iov_len = get_rfc1002_length(req) - 1;
-	iov[1].iov_base = (char *)req + 4;
+	rfc1002_marker = cpu_to_be32(total_len - 1 + wdata->bytes);
+	iov[0].iov_base = &rfc1002_marker;
+	iov[1].iov_len = total_len - 1;
+	iov[1].iov_base = (char *)req;
 
 	rqst.rq_iov = iov;
 	rqst.rq_nvec = 2;
@@ -2833,8 +2835,6 @@ smb2_async_writev(struct cifs_writedata *wdata,
 
 	req->Length = cpu_to_le32(wdata->bytes);
 
-	inc_rfc1001_len(&req->hdr, wdata->bytes - 1 /* Buffer */);
-
 	if (wdata->credits) {
 		shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(wdata->bytes,
 						    SMB2_MAX_BUFFER_SIZE));
@@ -2877,13 +2877,15 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
 	int resp_buftype;
 	struct kvec rsp_iov;
 	int flags = 0;
+	unsigned int total_len;
 
 	*nbytes = 0;
 
 	if (n_vec < 1)
 		return rc;
 
-	rc = small_smb2_init(SMB2_WRITE, io_parms->tcon, (void **) &req);
+	rc = smb2_plain_req_init(SMB2_WRITE, io_parms->tcon, (void **) &req,
+			     &total_len);
 	if (rc)
 		return rc;
 
@@ -2893,7 +2895,7 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
 	if (encryption_required(io_parms->tcon))
 		flags |= CIFS_TRANSFORM_REQ;
 
-	req->hdr.sync_hdr.ProcessId = cpu_to_le32(io_parms->pid);
+	req->sync_hdr.ProcessId = cpu_to_le32(io_parms->pid);
 
 	req->PersistentFileId = io_parms->persistent_fid;
 	req->VolatileFileId = io_parms->volatile_fid;
@@ -2902,20 +2904,16 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
 	req->Channel = 0;
 	req->Length = cpu_to_le32(io_parms->length);
 	req->Offset = cpu_to_le64(io_parms->offset);
-	/* 4 for rfc1002 length field */
 	req->DataOffset = cpu_to_le16(
-				offsetof(struct smb2_write_req, Buffer) - 4);
+				offsetof(struct smb2_write_req, Buffer));
 	req->RemainingBytes = 0;
 
 	iov[0].iov_base = (char *)req;
-	/* 4 for rfc1002 length field and 1 for Buffer */
-	iov[0].iov_len = get_rfc1002_length(req) + 4 - 1;
-
-	/* length of entire message including data to be written */
-	inc_rfc1001_len(req, io_parms->length - 1 /* Buffer */);
+	/* 1 for Buffer */
+	iov[0].iov_len = total_len - 1;
 
-	rc = SendReceive2(xid, io_parms->tcon->ses, iov, n_vec + 1,
-			  &resp_buftype, flags, &rsp_iov);
+	rc = SendReceive3(xid, io_parms->tcon->ses, iov, n_vec + 1,
+			      &resp_buftype, flags, &rsp_iov);
 	cifs_small_buf_release(req);
 	rsp = (struct smb2_write_rsp *)rsp_iov.iov_base;
 
diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h
index 0c33fc8cce71..3c856f058be7 100644
--- a/fs/cifs/smb2pdu.h
+++ b/fs/cifs/smb2pdu.h
@@ -868,7 +868,7 @@ struct smb2_read_rsp {
 #define SMB2_WRITEFLAG_WRITE_UNBUFFERED	0x00000002	/* SMB3.02 or later */
 
 struct smb2_write_req {
-	struct smb2_hdr hdr;
+	struct smb2_sync_hdr sync_hdr;
 	__le16 StructureSize; /* Must be 49 */
 	__le16 DataOffset; /* offset from start of SMB2 header to write data */
 	__le32 Length;
-- 
2.13.3

  parent reply	other threads:[~2017-11-02  7:03 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-02  7:02 [PATCH 00/19] cifs: remove rfc1002 header from all smb2 requests Ronnie Sahlberg
     [not found] ` <20171102070312.18903-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-02  7:02   ` [PATCH 01/19] cifs: Add SendReceive3 Ronnie Sahlberg
     [not found]     ` <20171102070312.18903-2-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-02 14:14       ` Aurélien Aptel
     [not found]         ` <87o9okvkcd.fsf-IBi9RG/b67k@public.gmane.org>
2017-11-03  6:25           ` Christoph Hellwig
2017-11-03  6:27       ` Christoph Hellwig
     [not found]         ` <20171103062715.GB8075-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2017-11-03  6:37           ` ronnie sahlberg
     [not found]             ` <CAN05THS8m9Z=KwiGarKh4qJT-X_ZnYU_AqVe26NNtF3Ad9j5nQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-03 13:36               ` Christoph Hellwig
2017-11-02  7:02   ` [PATCH 02/19] cifs: remove rfc1002 header from smb2_negotiate_req Ronnie Sahlberg
2017-11-02  7:02   ` [PATCH 03/19] cifs: remove rfc1002 header from smb2_logoff_req Ronnie Sahlberg
2017-11-02  7:02   ` [PATCH 04/19] cifs: remove rfc1002 header from smb2_tree_disconnect_req Ronnie Sahlberg
2017-11-02  7:02   ` [PATCH 05/19] cifs: remove rfc1002 header from smb2_close_req Ronnie Sahlberg
2017-11-02  7:02   ` [PATCH 06/19] cifs: remove rfc1002 header from smb2_ioctl_req Ronnie Sahlberg
2017-11-02  7:03   ` [PATCH 07/19] cifs: remove rfc1002 header from smb2_echo_req Ronnie Sahlberg
2017-11-02  7:03   ` [PATCH 08/19] cifs: remove rfc1002 header from smb2_sess_setup_req Ronnie Sahlberg
2017-11-02  7:03   ` [PATCH 09/19] cifs: remove rfc1002 header from smb2_tree_connect_req Ronnie Sahlberg
2017-11-02  7:03   ` [PATCH 10/19] cifs: remove rfc1002 header from smb2_create_req Ronnie Sahlberg
2017-11-02  7:03   ` [PATCH 11/19] cifs: remove rfc1002 header from smb2_flush_req Ronnie Sahlberg
2017-11-02  7:03   ` [PATCH 12/19] cifs: remove rfc1002 header from smb2_lock_req Ronnie Sahlberg
2017-11-02  7:03   ` Ronnie Sahlberg [this message]
2017-11-02  7:03   ` [PATCH 14/19] cifs: remove rfc1002 header from smb2_lease_ack Ronnie Sahlberg
2017-11-02  7:03   ` [PATCH 15/19] cifs: remove rfc1002 header from smb2_oplock_break we get from server Ronnie Sahlberg
2017-11-02  7:03   ` [PATCH 16/19] cifs: remove rfc1002 header from smb2_set_info_req Ronnie Sahlberg
2017-11-02  7:03   ` [PATCH 17/19] cifs: remove rfc1002 header from smb2_query_directory_req Ronnie Sahlberg
2017-11-02  7:03   ` [PATCH 18/19] cifs: remove rfc1002 header from smb2_query_info_req Ronnie Sahlberg
2017-11-02  7:03   ` [PATCH 19/19] cifs: remove small_smb2_init Ronnie Sahlberg
2017-11-08 14:38   ` [PATCH 00/19] cifs: remove rfc1002 header from all smb2 requests Aurélien Aptel
     [not found]     ` <87r2t8j0nc.fsf-IBi9RG/b67k@public.gmane.org>
2017-11-08 15:46       ` Aurélien Aptel
     [not found]         ` <87o9ocixio.fsf-IBi9RG/b67k@public.gmane.org>
2017-11-09  0:48           ` ronnie sahlberg
     [not found]             ` <CAN05THRX2dDBVA7+aCYnatYpm0EEH=iPdcwE40BSROOPmCPkcg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-17  1:16               ` Pavel Shilovsky
2017-11-09  1:14 [PATCH 00/19] Remove rfc1002 header from smb2 request structs Ronnie Sahlberg
     [not found] ` <20171109011433.14468-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09  1:14   ` [PATCH 13/19] cifs: remove rfc1002 header from smb2 read/write requests Ronnie Sahlberg
     [not found]     ` <20171109011433.14468-14-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-09 14:11       ` Aurélien Aptel
2017-11-17  1:42       ` Pavel Shilovsky
     [not found]         ` <CAKywueRU_HM44i04yv_gKza=tgsuxwfF4h-XfstbXTZe3AZQeg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-17  1:45           ` Leif Sahlberg
     [not found]             ` <546793899.27950063.1510883138100.JavaMail.zimbra-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-17  1:48               ` Pavel Shilovsky
2017-11-20  0:24 [PATCH 00/10] cifs: Remove rfc1002 header from smb2 request structs Ronnie Sahlberg
     [not found] ` <20171120002447.32322-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-20  0:24   ` [PATCH 13/19] cifs: remove rfc1002 header from smb2 read/write requests Ronnie Sahlberg
2017-11-21  0:04 [PATCH 00/19 Version 4] cifs: remove rfc1002 from smb2 requests Ronnie Sahlberg
     [not found] ` <20171121000442.24888-1-lsahlber-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-21  0:04   ` [PATCH 13/19] cifs: remove rfc1002 header from smb2 read/write requests Ronnie Sahlberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171102070312.18903-14-lsahlber@redhat.com \
    --to=lsahlber-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.