Commit d643a8a4 authored by Stefan Metzmacher's avatar Stefan Metzmacher Committed by Steve French

cifs: introduce cifs_io_parms in smb2_async_writev()

This will simplify the following changes and makes it easy to get
in passed in from the caller in future.
Signed-off-by: default avatarStefan Metzmacher <metze@samba.org>
Cc: Steve French <smfrench@gmail.com>
Cc: Tom Talpey <tom@talpey.com>
Cc: Long Li <longli@microsoft.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: David Howells <dhowells@redhat.com>
Cc: linux-cifs@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 89542781
...@@ -4504,10 +4504,27 @@ smb2_async_writev(struct cifs_writedata *wdata, ...@@ -4504,10 +4504,27 @@ smb2_async_writev(struct cifs_writedata *wdata,
struct kvec iov[1]; struct kvec iov[1];
struct smb_rqst rqst = { }; struct smb_rqst rqst = { };
unsigned int total_len; unsigned int total_len;
struct cifs_io_parms _io_parms;
struct cifs_io_parms *io_parms = NULL;
if (!wdata->server) if (!wdata->server)
server = wdata->server = cifs_pick_channel(tcon->ses); server = wdata->server = cifs_pick_channel(tcon->ses);
/*
* in future we may get cifs_io_parms passed in from the caller,
* but for now we construct it here...
*/
_io_parms = (struct cifs_io_parms) {
.tcon = tcon,
.server = server,
.offset = wdata->offset,
.length = wdata->bytes,
.persistent_fid = wdata->cfile->fid.persistent_fid,
.volatile_fid = wdata->cfile->fid.volatile_fid,
.pid = wdata->pid,
};
io_parms = &_io_parms;
rc = smb2_plain_req_init(SMB2_WRITE, tcon, server, rc = smb2_plain_req_init(SMB2_WRITE, tcon, server,
(void **) &req, &total_len); (void **) &req, &total_len);
if (rc) if (rc)
...@@ -4517,26 +4534,31 @@ smb2_async_writev(struct cifs_writedata *wdata, ...@@ -4517,26 +4534,31 @@ smb2_async_writev(struct cifs_writedata *wdata,
flags |= CIFS_TRANSFORM_REQ; flags |= CIFS_TRANSFORM_REQ;
shdr = (struct smb2_hdr *)req; shdr = (struct smb2_hdr *)req;
shdr->Id.SyncId.ProcessId = cpu_to_le32(wdata->cfile->pid); shdr->Id.SyncId.ProcessId = cpu_to_le32(io_parms->pid);
req->PersistentFileId = wdata->cfile->fid.persistent_fid; req->PersistentFileId = io_parms->persistent_fid;
req->VolatileFileId = wdata->cfile->fid.volatile_fid; req->VolatileFileId = io_parms->volatile_fid;
req->WriteChannelInfoOffset = 0; req->WriteChannelInfoOffset = 0;
req->WriteChannelInfoLength = 0; req->WriteChannelInfoLength = 0;
req->Channel = 0; req->Channel = 0;
req->Offset = cpu_to_le64(wdata->offset); req->Offset = cpu_to_le64(io_parms->offset);
req->DataOffset = cpu_to_le16( req->DataOffset = cpu_to_le16(
offsetof(struct smb2_write_req, Buffer)); offsetof(struct smb2_write_req, Buffer));
req->RemainingBytes = 0; req->RemainingBytes = 0;
trace_smb3_write_enter(0 /* xid */, wdata->cfile->fid.persistent_fid, trace_smb3_write_enter(0 /* xid */,
tcon->tid, tcon->ses->Suid, wdata->offset, wdata->bytes); io_parms->persistent_fid,
io_parms->tcon->tid,
io_parms->tcon->ses->Suid,
io_parms->offset,
io_parms->length);
#ifdef CONFIG_CIFS_SMB_DIRECT #ifdef CONFIG_CIFS_SMB_DIRECT
/* /*
* If we want to do a server RDMA read, fill in and append * If we want to do a server RDMA read, fill in and append
* smbd_buffer_descriptor_v1 to the end of write request * smbd_buffer_descriptor_v1 to the end of write request
*/ */
if (server->rdma && !server->sign && wdata->bytes >= if (server->rdma && !server->sign && io_parms->length >=
server->smbd_conn->rdma_readwrite_threshold) { server->smbd_conn->rdma_readwrite_threshold) {
struct smbd_buffer_descriptor_v1 *v1; struct smbd_buffer_descriptor_v1 *v1;
...@@ -4590,14 +4612,14 @@ smb2_async_writev(struct cifs_writedata *wdata, ...@@ -4590,14 +4612,14 @@ smb2_async_writev(struct cifs_writedata *wdata,
} }
#endif #endif
cifs_dbg(FYI, "async write at %llu %u bytes\n", cifs_dbg(FYI, "async write at %llu %u bytes\n",
wdata->offset, wdata->bytes); io_parms->offset, io_parms->length);
#ifdef CONFIG_CIFS_SMB_DIRECT #ifdef CONFIG_CIFS_SMB_DIRECT
/* For RDMA read, I/O size is in RemainingBytes not in Length */ /* For RDMA read, I/O size is in RemainingBytes not in Length */
if (!wdata->mr) if (!wdata->mr)
req->Length = cpu_to_le32(wdata->bytes); req->Length = cpu_to_le32(io_parms->length);
#else #else
req->Length = cpu_to_le32(wdata->bytes); req->Length = cpu_to_le32(io_parms->length);
#endif #endif
if (wdata->credits.value > 0) { if (wdata->credits.value > 0) {
...@@ -4605,7 +4627,7 @@ smb2_async_writev(struct cifs_writedata *wdata, ...@@ -4605,7 +4627,7 @@ smb2_async_writev(struct cifs_writedata *wdata,
SMB2_MAX_BUFFER_SIZE)); SMB2_MAX_BUFFER_SIZE));
shdr->CreditRequest = cpu_to_le16(le16_to_cpu(shdr->CreditCharge) + 8); shdr->CreditRequest = cpu_to_le16(le16_to_cpu(shdr->CreditCharge) + 8);
rc = adjust_credits(server, &wdata->credits, wdata->bytes); rc = adjust_credits(server, &wdata->credits, io_parms->length);
if (rc) if (rc)
goto async_writev_out; goto async_writev_out;
...@@ -4618,9 +4640,12 @@ smb2_async_writev(struct cifs_writedata *wdata, ...@@ -4618,9 +4640,12 @@ smb2_async_writev(struct cifs_writedata *wdata,
if (rc) { if (rc) {
trace_smb3_write_err(0 /* no xid */, trace_smb3_write_err(0 /* no xid */,
req->PersistentFileId, io_parms->persistent_fid,
tcon->tid, tcon->ses->Suid, wdata->offset, io_parms->tcon->tid,
wdata->bytes, rc); io_parms->tcon->ses->Suid,
io_parms->offset,
io_parms->length,
rc);
kref_put(&wdata->refcount, release); kref_put(&wdata->refcount, release);
cifs_stats_fail_inc(tcon, SMB2_WRITE_HE); cifs_stats_fail_inc(tcon, SMB2_WRITE_HE);
} }
......
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