Commit f5688a6d authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French

cifs: remove rfc1002 header from smb2 read/write requests

Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <smfrench@gmail.com>
Acked-by: default avatarPavel Shilovsky <pshilov@microsoft.com>
Reviewed-by: default avatarAurelien Aptel <aaptel@suse.com>
parent ced93679
...@@ -2666,10 +2666,9 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms, ...@@ -2666,10 +2666,9 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
struct smb2_read_plain_req *req = NULL; struct smb2_read_plain_req *req = NULL;
struct smb2_read_rsp *rsp = NULL; struct smb2_read_rsp *rsp = NULL;
struct smb2_sync_hdr *shdr; struct smb2_sync_hdr *shdr;
struct kvec iov[2]; struct kvec iov[1];
struct kvec rsp_iov; struct kvec rsp_iov;
unsigned int total_len; unsigned int total_len;
__be32 req_len;
struct smb_rqst rqst = { .rq_iov = iov, struct smb_rqst rqst = { .rq_iov = iov,
.rq_nvec = 2 }; .rq_nvec = 2 };
int flags = CIFS_LOG_ERROR; int flags = CIFS_LOG_ERROR;
...@@ -2683,14 +2682,10 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms, ...@@ -2683,14 +2682,10 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
if (encryption_required(io_parms->tcon)) if (encryption_required(io_parms->tcon))
flags |= CIFS_TRANSFORM_REQ; flags |= CIFS_TRANSFORM_REQ;
req_len = cpu_to_be32(total_len); iov[0].iov_base = (char *)req;
iov[0].iov_len = total_len;
iov[0].iov_base = &req_len;
iov[0].iov_len = sizeof(__be32);
iov[1].iov_base = req;
iov[1].iov_len = total_len;
rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov); rc = smb2_send_recv(xid, ses, iov, 1, &resp_buftype, flags, &rsp_iov);
cifs_small_buf_release(req); cifs_small_buf_release(req);
rsp = (struct smb2_read_rsp *)rsp_iov.iov_base; rsp = (struct smb2_read_rsp *)rsp_iov.iov_base;
...@@ -2792,8 +2787,10 @@ smb2_async_writev(struct cifs_writedata *wdata, ...@@ -2792,8 +2787,10 @@ smb2_async_writev(struct cifs_writedata *wdata,
struct TCP_Server_Info *server = tcon->ses->server; struct TCP_Server_Info *server = tcon->ses->server;
struct kvec iov[2]; struct kvec iov[2];
struct smb_rqst rqst = { }; 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) {
if (rc == -EAGAIN && wdata->credits) { if (rc == -EAGAIN && wdata->credits) {
/* credits was reset by reconnect */ /* credits was reset by reconnect */
...@@ -2809,7 +2806,7 @@ smb2_async_writev(struct cifs_writedata *wdata, ...@@ -2809,7 +2806,7 @@ smb2_async_writev(struct cifs_writedata *wdata,
if (encryption_required(tcon)) if (encryption_required(tcon))
flags |= CIFS_TRANSFORM_REQ; flags |= CIFS_TRANSFORM_REQ;
shdr = get_sync_hdr(req); shdr = (struct smb2_sync_hdr *)req;
shdr->ProcessId = cpu_to_le32(wdata->cfile->pid); shdr->ProcessId = cpu_to_le32(wdata->cfile->pid);
req->PersistentFileId = wdata->cfile->fid.persistent_fid; req->PersistentFileId = wdata->cfile->fid.persistent_fid;
...@@ -2818,16 +2815,16 @@ smb2_async_writev(struct cifs_writedata *wdata, ...@@ -2818,16 +2815,16 @@ smb2_async_writev(struct cifs_writedata *wdata,
req->WriteChannelInfoLength = 0; req->WriteChannelInfoLength = 0;
req->Channel = 0; req->Channel = 0;
req->Offset = cpu_to_le64(wdata->offset); req->Offset = cpu_to_le64(wdata->offset);
/* 4 for rfc1002 length field */
req->DataOffset = cpu_to_le16( req->DataOffset = cpu_to_le16(
offsetof(struct smb2_write_req, Buffer) - 4); offsetof(struct smb2_write_req, Buffer));
req->RemainingBytes = 0; req->RemainingBytes = 0;
/* 4 for rfc1002 length field and 1 for Buffer */ /* 4 for rfc1002 length field and 1 for Buffer */
iov[0].iov_len = 4; iov[0].iov_len = 4;
iov[0].iov_base = req; rfc1002_marker = cpu_to_be32(total_len - 1 + wdata->bytes);
iov[1].iov_len = get_rfc1002_length(req) - 1; iov[0].iov_base = &rfc1002_marker;
iov[1].iov_base = (char *)req + 4; iov[1].iov_len = total_len - 1;
iov[1].iov_base = (char *)req;
rqst.rq_iov = iov; rqst.rq_iov = iov;
rqst.rq_nvec = 2; rqst.rq_nvec = 2;
...@@ -2841,8 +2838,6 @@ smb2_async_writev(struct cifs_writedata *wdata, ...@@ -2841,8 +2838,6 @@ smb2_async_writev(struct cifs_writedata *wdata,
req->Length = cpu_to_le32(wdata->bytes); req->Length = cpu_to_le32(wdata->bytes);
inc_rfc1001_len(&req->hdr, wdata->bytes - 1 /* Buffer */);
if (wdata->credits) { if (wdata->credits) {
shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(wdata->bytes, shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(wdata->bytes,
SMB2_MAX_BUFFER_SIZE)); SMB2_MAX_BUFFER_SIZE));
...@@ -2885,13 +2880,15 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms, ...@@ -2885,13 +2880,15 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
int resp_buftype; int resp_buftype;
struct kvec rsp_iov; struct kvec rsp_iov;
int flags = 0; int flags = 0;
unsigned int total_len;
*nbytes = 0; *nbytes = 0;
if (n_vec < 1) if (n_vec < 1)
return rc; 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) if (rc)
return rc; return rc;
...@@ -2901,7 +2898,7 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms, ...@@ -2901,7 +2898,7 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
if (encryption_required(io_parms->tcon)) if (encryption_required(io_parms->tcon))
flags |= CIFS_TRANSFORM_REQ; 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->PersistentFileId = io_parms->persistent_fid;
req->VolatileFileId = io_parms->volatile_fid; req->VolatileFileId = io_parms->volatile_fid;
...@@ -2910,20 +2907,16 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms, ...@@ -2910,20 +2907,16 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
req->Channel = 0; req->Channel = 0;
req->Length = cpu_to_le32(io_parms->length); req->Length = cpu_to_le32(io_parms->length);
req->Offset = cpu_to_le64(io_parms->offset); req->Offset = cpu_to_le64(io_parms->offset);
/* 4 for rfc1002 length field */
req->DataOffset = cpu_to_le16( req->DataOffset = cpu_to_le16(
offsetof(struct smb2_write_req, Buffer) - 4); offsetof(struct smb2_write_req, Buffer));
req->RemainingBytes = 0; req->RemainingBytes = 0;
iov[0].iov_base = (char *)req; iov[0].iov_base = (char *)req;
/* 4 for rfc1002 length field and 1 for Buffer */ /* 1 for Buffer */
iov[0].iov_len = get_rfc1002_length(req) + 4 - 1; iov[0].iov_len = total_len - 1;
/* length of entire message including data to be written */
inc_rfc1001_len(req, io_parms->length - 1 /* Buffer */);
rc = SendReceive2(xid, io_parms->tcon->ses, iov, n_vec + 1, rc = smb2_send_recv(xid, io_parms->tcon->ses, iov, n_vec + 1,
&resp_buftype, flags, &rsp_iov); &resp_buftype, flags, &rsp_iov);
cifs_small_buf_release(req); cifs_small_buf_release(req);
rsp = (struct smb2_write_rsp *)rsp_iov.iov_base; rsp = (struct smb2_write_rsp *)rsp_iov.iov_base;
......
...@@ -868,7 +868,7 @@ struct smb2_read_rsp { ...@@ -868,7 +868,7 @@ struct smb2_read_rsp {
#define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */ #define SMB2_WRITEFLAG_WRITE_UNBUFFERED 0x00000002 /* SMB3.02 or later */
struct smb2_write_req { struct smb2_write_req {
struct smb2_hdr hdr; struct smb2_sync_hdr sync_hdr;
__le16 StructureSize; /* Must be 49 */ __le16 StructureSize; /* Must be 49 */
__le16 DataOffset; /* offset from start of SMB2 header to write data */ __le16 DataOffset; /* offset from start of SMB2 header to write data */
__le32 Length; __le32 Length;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment