aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-09-18 19:20:35 -0400
committerSteve French <smfrench@gmail.com>2012-09-24 22:46:31 -0400
commitfec344e3f31aa911297cd3a4639432d983b1f324 (patch)
treec46deb8e54d4a1f00be47f7d34e572730b0df988 /fs/cifs
parentfb308a6f22f7f4f3574dab6b36c4a3598e50cf05 (diff)
cifs: change cifs_call_async to use smb_rqst structs
For now, none of the callers populate rq_pages. That will be done for writes in a later patch. While we're at it, change the prototype of setup_async_request not to need a return pointer argument. Just return the pointer to the mid_q_entry or an ERR_PTR. Reviewed-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/cifsglob.h8
-rw-r--r--fs/cifs/cifsproto.h16
-rw-r--r--fs/cifs/cifssmb.c20
-rw-r--r--fs/cifs/smb2pdu.c15
-rw-r--r--fs/cifs/smb2proto.h9
-rw-r--r--fs/cifs/smb2transport.c40
-rw-r--r--fs/cifs/transport.c56
7 files changed, 85 insertions, 79 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 5ea50dd316c5..a81790005e57 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -201,11 +201,11 @@ struct smb_version_operations {
201 struct mid_q_entry *); 201 struct mid_q_entry *);
202 bool (*compare_fids)(struct cifsFileInfo *, struct cifsFileInfo *); 202 bool (*compare_fids)(struct cifsFileInfo *, struct cifsFileInfo *);
203 /* setup request: allocate mid, sign message */ 203 /* setup request: allocate mid, sign message */
204 int (*setup_request)(struct cifs_ses *, struct kvec *, unsigned int, 204 struct mid_q_entry *(*setup_request)(struct cifs_ses *,
205 struct mid_q_entry **); 205 struct smb_rqst *);
206 /* setup async request: allocate mid, sign message */ 206 /* setup async request: allocate mid, sign message */
207 int (*setup_async_request)(struct TCP_Server_Info *, struct kvec *, 207 struct mid_q_entry *(*setup_async_request)(struct TCP_Server_Info *,
208 unsigned int, struct mid_q_entry **); 208 struct smb_rqst *);
209 /* check response: verify signature, map error */ 209 /* check response: verify signature, map error */
210 int (*check_receive)(struct mid_q_entry *, struct TCP_Server_Info *, 210 int (*check_receive)(struct mid_q_entry *, struct TCP_Server_Info *,
211 bool); 211 bool);
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index e97a1843ab98..3b628f2af258 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -70,20 +70,20 @@ extern struct mid_q_entry *AllocMidQEntry(const struct smb_hdr *smb_buffer,
70extern void DeleteMidQEntry(struct mid_q_entry *midEntry); 70extern void DeleteMidQEntry(struct mid_q_entry *midEntry);
71extern void cifs_delete_mid(struct mid_q_entry *mid); 71extern void cifs_delete_mid(struct mid_q_entry *mid);
72extern void cifs_wake_up_task(struct mid_q_entry *mid); 72extern void cifs_wake_up_task(struct mid_q_entry *mid);
73extern int cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov, 73extern int cifs_call_async(struct TCP_Server_Info *server,
74 unsigned int nvec, mid_receive_t *receive, 74 struct smb_rqst *rqst,
75 mid_callback_t *callback, void *cbdata, 75 mid_receive_t *receive, mid_callback_t *callback,
76 const int flags); 76 void *cbdata, const int flags);
77extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *, 77extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *,
78 struct smb_hdr * /* input */ , 78 struct smb_hdr * /* input */ ,
79 struct smb_hdr * /* out */ , 79 struct smb_hdr * /* out */ ,
80 int * /* bytes returned */ , const int); 80 int * /* bytes returned */ , const int);
81extern int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses, 81extern int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
82 char *in_buf, int flags); 82 char *in_buf, int flags);
83extern int cifs_setup_request(struct cifs_ses *, struct kvec *, unsigned int, 83extern struct mid_q_entry *cifs_setup_request(struct cifs_ses *,
84 struct mid_q_entry **); 84 struct smb_rqst *);
85extern int cifs_setup_async_request(struct TCP_Server_Info *, struct kvec *, 85extern struct mid_q_entry *cifs_setup_async_request(struct TCP_Server_Info *,
86 unsigned int, struct mid_q_entry **); 86 struct smb_rqst *);
87extern int cifs_check_receive(struct mid_q_entry *mid, 87extern int cifs_check_receive(struct mid_q_entry *mid,
88 struct TCP_Server_Info *server, bool log_error); 88 struct TCP_Server_Info *server, bool log_error);
89extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *, 89extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *,
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 6786b5ee5326..2f86c84468cb 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -725,6 +725,8 @@ CIFSSMBEcho(struct TCP_Server_Info *server)
725 ECHO_REQ *smb; 725 ECHO_REQ *smb;
726 int rc = 0; 726 int rc = 0;
727 struct kvec iov; 727 struct kvec iov;
728 struct smb_rqst rqst = { .rq_iov = &iov,
729 .rq_nvec = 1 };
728 730
729 cFYI(1, "In echo request"); 731 cFYI(1, "In echo request");
730 732
@@ -742,7 +744,7 @@ CIFSSMBEcho(struct TCP_Server_Info *server)
742 iov.iov_base = smb; 744 iov.iov_base = smb;
743 iov.iov_len = be32_to_cpu(smb->hdr.smb_buf_length) + 4; 745 iov.iov_len = be32_to_cpu(smb->hdr.smb_buf_length) + 4;
744 746
745 rc = cifs_call_async(server, &iov, 1, NULL, cifs_echo_callback, 747 rc = cifs_call_async(server, &rqst, NULL, cifs_echo_callback,
746 server, CIFS_ASYNC_OP | CIFS_ECHO_OP); 748 server, CIFS_ASYNC_OP | CIFS_ECHO_OP);
747 if (rc) 749 if (rc)
748 cFYI(1, "Echo request failed: %d", rc); 750 cFYI(1, "Echo request failed: %d", rc);
@@ -1585,6 +1587,8 @@ cifs_async_readv(struct cifs_readdata *rdata)
1585 READ_REQ *smb = NULL; 1587 READ_REQ *smb = NULL;
1586 int wct; 1588 int wct;
1587 struct cifs_tcon *tcon = tlink_tcon(rdata->cfile->tlink); 1589 struct cifs_tcon *tcon = tlink_tcon(rdata->cfile->tlink);
1590 struct smb_rqst rqst = { .rq_iov = rdata->iov,
1591 .rq_nvec = 1 };
1588 1592
1589 cFYI(1, "%s: offset=%llu bytes=%u", __func__, 1593 cFYI(1, "%s: offset=%llu bytes=%u", __func__,
1590 rdata->offset, rdata->bytes); 1594 rdata->offset, rdata->bytes);
@@ -1628,9 +1632,8 @@ cifs_async_readv(struct cifs_readdata *rdata)
1628 rdata->iov[0].iov_len = be32_to_cpu(smb->hdr.smb_buf_length) + 4; 1632 rdata->iov[0].iov_len = be32_to_cpu(smb->hdr.smb_buf_length) + 4;
1629 1633
1630 kref_get(&rdata->refcount); 1634 kref_get(&rdata->refcount);
1631 rc = cifs_call_async(tcon->ses->server, rdata->iov, 1, 1635 rc = cifs_call_async(tcon->ses->server, &rqst, cifs_readv_receive,
1632 cifs_readv_receive, cifs_readv_callback, 1636 cifs_readv_callback, rdata, 0);
1633 rdata, 0);
1634 1637
1635 if (rc == 0) 1638 if (rc == 0)
1636 cifs_stats_inc(&tcon->stats.cifs_stats.num_reads); 1639 cifs_stats_inc(&tcon->stats.cifs_stats.num_reads);
@@ -2035,6 +2038,7 @@ cifs_async_writev(struct cifs_writedata *wdata)
2035 int wct; 2038 int wct;
2036 struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink); 2039 struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink);
2037 struct kvec *iov = NULL; 2040 struct kvec *iov = NULL;
2041 struct smb_rqst rqst = { };
2038 2042
2039 if (tcon->ses->capabilities & CAP_LARGE_FILES) { 2043 if (tcon->ses->capabilities & CAP_LARGE_FILES) {
2040 wct = 14; 2044 wct = 14;
@@ -2051,11 +2055,13 @@ cifs_async_writev(struct cifs_writedata *wdata)
2051 goto async_writev_out; 2055 goto async_writev_out;
2052 2056
2053 /* 1 iov per page + 1 for header */ 2057 /* 1 iov per page + 1 for header */
2054 iov = kzalloc((wdata->nr_pages + 1) * sizeof(*iov), GFP_NOFS); 2058 rqst.rq_nvec = wdata->nr_pages + 1;
2059 iov = kzalloc((rqst.rq_nvec) * sizeof(*iov), GFP_NOFS);
2055 if (iov == NULL) { 2060 if (iov == NULL) {
2056 rc = -ENOMEM; 2061 rc = -ENOMEM;
2057 goto async_writev_out; 2062 goto async_writev_out;
2058 } 2063 }
2064 rqst.rq_iov = iov;
2059 2065
2060 smb->hdr.Pid = cpu_to_le16((__u16)wdata->pid); 2066 smb->hdr.Pid = cpu_to_le16((__u16)wdata->pid);
2061 smb->hdr.PidHigh = cpu_to_le16((__u16)(wdata->pid >> 16)); 2067 smb->hdr.PidHigh = cpu_to_le16((__u16)(wdata->pid >> 16));
@@ -2104,8 +2110,8 @@ cifs_async_writev(struct cifs_writedata *wdata)
2104 } 2110 }
2105 2111
2106 kref_get(&wdata->refcount); 2112 kref_get(&wdata->refcount);
2107 rc = cifs_call_async(tcon->ses->server, iov, wdata->nr_pages + 1, 2113 rc = cifs_call_async(tcon->ses->server, &rqst, NULL,
2108 NULL, cifs_writev_callback, wdata, 0); 2114 cifs_writev_callback, wdata, 0);
2109 2115
2110 if (rc == 0) 2116 if (rc == 0)
2111 cifs_stats_inc(&tcon->stats.cifs_stats.num_writes); 2117 cifs_stats_inc(&tcon->stats.cifs_stats.num_writes);
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index e188d137cab2..a04301b69b4e 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1171,6 +1171,8 @@ SMB2_echo(struct TCP_Server_Info *server)
1171 struct smb2_echo_req *req; 1171 struct smb2_echo_req *req;
1172 int rc = 0; 1172 int rc = 0;
1173 struct kvec iov; 1173 struct kvec iov;
1174 struct smb_rqst rqst = { .rq_iov = &iov,
1175 .rq_nvec = 1 };
1174 1176
1175 cFYI(1, "In echo request"); 1177 cFYI(1, "In echo request");
1176 1178
@@ -1184,7 +1186,7 @@ SMB2_echo(struct TCP_Server_Info *server)
1184 /* 4 for rfc1002 length field */ 1186 /* 4 for rfc1002 length field */
1185 iov.iov_len = get_rfc1002_length(req) + 4; 1187 iov.iov_len = get_rfc1002_length(req) + 4;
1186 1188
1187 rc = cifs_call_async(server, &iov, 1, NULL, smb2_echo_callback, server, 1189 rc = cifs_call_async(server, &rqst, NULL, smb2_echo_callback, server,
1188 CIFS_ECHO_OP); 1190 CIFS_ECHO_OP);
1189 if (rc) 1191 if (rc)
1190 cFYI(1, "Echo request failed: %d", rc); 1192 cFYI(1, "Echo request failed: %d", rc);
@@ -1344,6 +1346,8 @@ smb2_async_readv(struct cifs_readdata *rdata)
1344 int rc; 1346 int rc;
1345 struct smb2_hdr *buf; 1347 struct smb2_hdr *buf;
1346 struct cifs_io_parms io_parms; 1348 struct cifs_io_parms io_parms;
1349 struct smb_rqst rqst = { .rq_iov = rdata->iov,
1350 .rq_nvec = 1 };
1347 1351
1348 cFYI(1, "%s: offset=%llu bytes=%u", __func__, 1352 cFYI(1, "%s: offset=%llu bytes=%u", __func__,
1349 rdata->offset, rdata->bytes); 1353 rdata->offset, rdata->bytes);
@@ -1363,7 +1367,7 @@ smb2_async_readv(struct cifs_readdata *rdata)
1363 rdata->iov[0].iov_len = get_rfc1002_length(rdata->iov[0].iov_base) + 4; 1367 rdata->iov[0].iov_len = get_rfc1002_length(rdata->iov[0].iov_base) + 4;
1364 1368
1365 kref_get(&rdata->refcount); 1369 kref_get(&rdata->refcount);
1366 rc = cifs_call_async(io_parms.tcon->ses->server, rdata->iov, 1, 1370 rc = cifs_call_async(io_parms.tcon->ses->server, &rqst,
1367 cifs_readv_receive, smb2_readv_callback, 1371 cifs_readv_receive, smb2_readv_callback,
1368 rdata, 0); 1372 rdata, 0);
1369 if (rc) 1373 if (rc)
@@ -1484,6 +1488,7 @@ smb2_async_writev(struct cifs_writedata *wdata)
1484 struct smb2_write_req *req = NULL; 1488 struct smb2_write_req *req = NULL;
1485 struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink); 1489 struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink);
1486 struct kvec *iov = NULL; 1490 struct kvec *iov = NULL;
1491 struct smb_rqst rqst;
1487 1492
1488 rc = small_smb2_init(SMB2_WRITE, tcon, (void **) &req); 1493 rc = small_smb2_init(SMB2_WRITE, tcon, (void **) &req);
1489 if (rc) 1494 if (rc)
@@ -1495,6 +1500,8 @@ smb2_async_writev(struct cifs_writedata *wdata)
1495 rc = -ENOMEM; 1500 rc = -ENOMEM;
1496 goto async_writev_out; 1501 goto async_writev_out;
1497 } 1502 }
1503 rqst.rq_iov = iov;
1504 rqst.rq_nvec = wdata->nr_pages + 1;
1498 1505
1499 req->hdr.ProcessId = cpu_to_le32(wdata->cfile->pid); 1506 req->hdr.ProcessId = cpu_to_le32(wdata->cfile->pid);
1500 1507
@@ -1530,8 +1537,8 @@ smb2_async_writev(struct cifs_writedata *wdata)
1530 inc_rfc1001_len(&req->hdr, wdata->bytes - 1 /* Buffer */); 1537 inc_rfc1001_len(&req->hdr, wdata->bytes - 1 /* Buffer */);
1531 1538
1532 kref_get(&wdata->refcount); 1539 kref_get(&wdata->refcount);
1533 rc = cifs_call_async(tcon->ses->server, iov, wdata->nr_pages + 1, 1540 rc = cifs_call_async(tcon->ses->server, &rqst, NULL,
1534 NULL, smb2_writev_callback, wdata, 0); 1541 smb2_writev_callback, wdata, 0);
1535 1542
1536 if (rc) 1543 if (rc)
1537 kref_put(&wdata->refcount, cifs_writedata_release); 1544 kref_put(&wdata->refcount, cifs_writedata_release);
diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h
index a9bda043e26e..aeb30dbdf8b8 100644
--- a/fs/cifs/smb2proto.h
+++ b/fs/cifs/smb2proto.h
@@ -43,11 +43,10 @@ extern __le16 *cifs_convert_path_to_utf16(const char *from,
43extern int smb2_verify_signature(struct smb_rqst *, struct TCP_Server_Info *); 43extern int smb2_verify_signature(struct smb_rqst *, struct TCP_Server_Info *);
44extern int smb2_check_receive(struct mid_q_entry *mid, 44extern int smb2_check_receive(struct mid_q_entry *mid,
45 struct TCP_Server_Info *server, bool log_error); 45 struct TCP_Server_Info *server, bool log_error);
46extern int smb2_setup_request(struct cifs_ses *ses, struct kvec *iov, 46extern struct mid_q_entry *smb2_setup_request(struct cifs_ses *ses,
47 unsigned int nvec, struct mid_q_entry **ret_mid); 47 struct smb_rqst *rqst);
48extern int smb2_setup_async_request(struct TCP_Server_Info *server, 48extern struct mid_q_entry *smb2_setup_async_request(
49 struct kvec *iov, unsigned int nvec, 49 struct TCP_Server_Info *server, struct smb_rqst *rqst);
50 struct mid_q_entry **ret_mid);
51extern void smb2_echo_request(struct work_struct *work); 50extern void smb2_echo_request(struct work_struct *work);
52extern bool smb2_is_valid_oplock_break(char *buffer, 51extern bool smb2_is_valid_oplock_break(char *buffer,
53 struct TCP_Server_Info *srv); 52 struct TCP_Server_Info *srv);
diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c
index 9ca4bcfb34c6..2a5fdf26f79f 100644
--- a/fs/cifs/smb2transport.c
+++ b/fs/cifs/smb2transport.c
@@ -281,50 +281,44 @@ smb2_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
281 return map_smb2_to_linux_error(mid->resp_buf, log_error); 281 return map_smb2_to_linux_error(mid->resp_buf, log_error);
282} 282}
283 283
284int 284struct mid_q_entry *
285smb2_setup_request(struct cifs_ses *ses, struct kvec *iov, 285smb2_setup_request(struct cifs_ses *ses, struct smb_rqst *rqst)
286 unsigned int nvec, struct mid_q_entry **ret_mid)
287{ 286{
288 int rc; 287 int rc;
289 struct smb2_hdr *hdr = (struct smb2_hdr *)iov[0].iov_base; 288 struct smb2_hdr *hdr = (struct smb2_hdr *)rqst->rq_iov[0].iov_base;
290 struct mid_q_entry *mid; 289 struct mid_q_entry *mid;
291 struct smb_rqst rqst = { .rq_iov = iov,
292 .rq_nvec = nvec };
293 290
294 smb2_seq_num_into_buf(ses->server, hdr); 291 smb2_seq_num_into_buf(ses->server, hdr);
295 292
296 rc = smb2_get_mid_entry(ses, hdr, &mid); 293 rc = smb2_get_mid_entry(ses, hdr, &mid);
297 if (rc) 294 if (rc)
298 return rc; 295 return ERR_PTR(rc);
299 rc = smb2_sign_rqst(&rqst, ses->server); 296 rc = smb2_sign_rqst(rqst, ses->server);
300 if (rc) 297 if (rc) {
301 cifs_delete_mid(mid); 298 cifs_delete_mid(mid);
302 *ret_mid = mid; 299 return ERR_PTR(rc);
303 return rc; 300 }
301 return mid;
304} 302}
305 303
306int 304struct mid_q_entry *
307smb2_setup_async_request(struct TCP_Server_Info *server, struct kvec *iov, 305smb2_setup_async_request(struct TCP_Server_Info *server, struct smb_rqst *rqst)
308 unsigned int nvec, struct mid_q_entry **ret_mid)
309{ 306{
310 int rc = 0; 307 int rc;
311 struct smb2_hdr *hdr = (struct smb2_hdr *)iov[0].iov_base; 308 struct smb2_hdr *hdr = (struct smb2_hdr *)rqst->rq_iov[0].iov_base;
312 struct mid_q_entry *mid; 309 struct mid_q_entry *mid;
313 struct smb_rqst rqst = { .rq_iov = iov,
314 .rq_nvec = nvec };
315 310
316 smb2_seq_num_into_buf(server, hdr); 311 smb2_seq_num_into_buf(server, hdr);
317 312
318 mid = smb2_mid_entry_alloc(hdr, server); 313 mid = smb2_mid_entry_alloc(hdr, server);
319 if (mid == NULL) 314 if (mid == NULL)
320 return -ENOMEM; 315 return ERR_PTR(-ENOMEM);
321 316
322 rc = smb2_sign_rqst(&rqst, server); 317 rc = smb2_sign_rqst(rqst, server);
323 if (rc) { 318 if (rc) {
324 DeleteMidQEntry(mid); 319 DeleteMidQEntry(mid);
325 return rc; 320 return ERR_PTR(rc);
326 } 321 }
327 322
328 *ret_mid = mid; 323 return mid;
329 return rc;
330} 324}
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index b6097344cd5b..2126ab185045 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -454,12 +454,11 @@ wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ)
454 return 0; 454 return 0;
455} 455}
456 456
457int 457struct mid_q_entry *
458cifs_setup_async_request(struct TCP_Server_Info *server, struct kvec *iov, 458cifs_setup_async_request(struct TCP_Server_Info *server, struct smb_rqst *rqst)
459 unsigned int nvec, struct mid_q_entry **ret_mid)
460{ 459{
461 int rc; 460 int rc;
462 struct smb_hdr *hdr = (struct smb_hdr *)iov[0].iov_base; 461 struct smb_hdr *hdr = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
463 struct mid_q_entry *mid; 462 struct mid_q_entry *mid;
464 463
465 /* enable signing if server requires it */ 464 /* enable signing if server requires it */
@@ -468,16 +467,15 @@ cifs_setup_async_request(struct TCP_Server_Info *server, struct kvec *iov,
468 467
469 mid = AllocMidQEntry(hdr, server); 468 mid = AllocMidQEntry(hdr, server);
470 if (mid == NULL) 469 if (mid == NULL)
471 return -ENOMEM; 470 return ERR_PTR(-ENOMEM);
472 471
473 rc = cifs_sign_smbv(iov, nvec, server, &mid->sequence_number); 472 rc = cifs_sign_rqst(rqst, server, &mid->sequence_number);
474 if (rc) { 473 if (rc) {
475 DeleteMidQEntry(mid); 474 DeleteMidQEntry(mid);
476 return rc; 475 return ERR_PTR(rc);
477 } 476 }
478 477
479 *ret_mid = mid; 478 return mid;
480 return 0;
481} 479}
482 480
483/* 481/*
@@ -485,9 +483,9 @@ cifs_setup_async_request(struct TCP_Server_Info *server, struct kvec *iov,
485 * the result. Caller is responsible for dealing with timeouts. 483 * the result. Caller is responsible for dealing with timeouts.
486 */ 484 */
487int 485int
488cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov, 486cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
489 unsigned int nvec, mid_receive_t *receive, 487 mid_receive_t *receive, mid_callback_t *callback,
490 mid_callback_t *callback, void *cbdata, const int flags) 488 void *cbdata, const int flags)
491{ 489{
492 int rc, timeout, optype; 490 int rc, timeout, optype;
493 struct mid_q_entry *mid; 491 struct mid_q_entry *mid;
@@ -500,12 +498,12 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov,
500 return rc; 498 return rc;
501 499
502 mutex_lock(&server->srv_mutex); 500 mutex_lock(&server->srv_mutex);
503 rc = server->ops->setup_async_request(server, iov, nvec, &mid); 501 mid = server->ops->setup_async_request(server, rqst);
504 if (rc) { 502 if (IS_ERR(mid)) {
505 mutex_unlock(&server->srv_mutex); 503 mutex_unlock(&server->srv_mutex);
506 add_credits(server, 1, optype); 504 add_credits(server, 1, optype);
507 wake_up(&server->request_q); 505 wake_up(&server->request_q);
508 return rc; 506 return PTR_ERR(mid);
509 } 507 }
510 508
511 mid->receive = receive; 509 mid->receive = receive;
@@ -520,7 +518,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov,
520 518
521 519
522 cifs_in_send_inc(server); 520 cifs_in_send_inc(server);
523 rc = smb_sendv(server, iov, nvec); 521 rc = smb_send_rqst(server, rqst);
524 cifs_in_send_dec(server); 522 cifs_in_send_dec(server);
525 cifs_save_when_sent(mid); 523 cifs_save_when_sent(mid);
526 mutex_unlock(&server->srv_mutex); 524 mutex_unlock(&server->srv_mutex);
@@ -630,22 +628,22 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
630 return map_smb_to_linux_error(mid->resp_buf, log_error); 628 return map_smb_to_linux_error(mid->resp_buf, log_error);
631} 629}
632 630
633int 631struct mid_q_entry *
634cifs_setup_request(struct cifs_ses *ses, struct kvec *iov, 632cifs_setup_request(struct cifs_ses *ses, struct smb_rqst *rqst)
635 unsigned int nvec, struct mid_q_entry **ret_mid)
636{ 633{
637 int rc; 634 int rc;
638 struct smb_hdr *hdr = (struct smb_hdr *)iov[0].iov_base; 635 struct smb_hdr *hdr = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
639 struct mid_q_entry *mid; 636 struct mid_q_entry *mid;
640 637
641 rc = allocate_mid(ses, hdr, &mid); 638 rc = allocate_mid(ses, hdr, &mid);
642 if (rc) 639 if (rc)
643 return rc; 640 return ERR_PTR(rc);
644 rc = cifs_sign_smbv(iov, nvec, ses->server, &mid->sequence_number); 641 rc = cifs_sign_rqst(rqst, ses->server, &mid->sequence_number);
645 if (rc) 642 if (rc) {
646 cifs_delete_mid(mid); 643 cifs_delete_mid(mid);
647 *ret_mid = mid; 644 return ERR_PTR(rc);
648 return rc; 645 }
646 return mid;
649} 647}
650 648
651int 649int
@@ -658,6 +656,8 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
658 struct mid_q_entry *midQ; 656 struct mid_q_entry *midQ;
659 char *buf = iov[0].iov_base; 657 char *buf = iov[0].iov_base;
660 unsigned int credits = 1; 658 unsigned int credits = 1;
659 struct smb_rqst rqst = { .rq_iov = iov,
660 .rq_nvec = n_vec };
661 661
662 timeout = flags & CIFS_TIMEOUT_MASK; 662 timeout = flags & CIFS_TIMEOUT_MASK;
663 optype = flags & CIFS_OP_MASK; 663 optype = flags & CIFS_OP_MASK;
@@ -695,13 +695,13 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
695 695
696 mutex_lock(&ses->server->srv_mutex); 696 mutex_lock(&ses->server->srv_mutex);
697 697
698 rc = ses->server->ops->setup_request(ses, iov, n_vec, &midQ); 698 midQ = ses->server->ops->setup_request(ses, &rqst);
699 if (rc) { 699 if (IS_ERR(midQ)) {
700 mutex_unlock(&ses->server->srv_mutex); 700 mutex_unlock(&ses->server->srv_mutex);
701 cifs_small_buf_release(buf); 701 cifs_small_buf_release(buf);
702 /* Update # of requests on wire to server */ 702 /* Update # of requests on wire to server */
703 add_credits(ses->server, 1, optype); 703 add_credits(ses->server, 1, optype);
704 return rc; 704 return PTR_ERR(midQ);
705 } 705 }
706 706
707 midQ->mid_state = MID_REQUEST_SUBMITTED; 707 midQ->mid_state = MID_REQUEST_SUBMITTED;