aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilov@microsoft.com>2016-11-16 17:06:17 -0500
committerSteve French <smfrench@gmail.com>2017-02-01 17:46:36 -0500
commit9b7c18a2d4b798963ea80f6769701dcc4c24b55e (patch)
tree5bae0246771770c48892534805407b136a823066
parent9bb17e0916a03ab901fb684e874d77a1e96b3d1e (diff)
CIFS: Add mid handle callback
We need to process read responses differently because the data should go directly into preallocated pages. This can be done by specifying a mid handle callback. Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
-rw-r--r--fs/cifs/cifsglob.h8
-rw-r--r--fs/cifs/cifsproto.h2
-rw-r--r--fs/cifs/cifssmb.c6
-rw-r--r--fs/cifs/smb2pdu.c10
-rw-r--r--fs/cifs/transport.c5
5 files changed, 20 insertions, 11 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 35cf62ba5416..8a04a013a4ac 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1312,6 +1312,13 @@ typedef int (mid_receive_t)(struct TCP_Server_Info *server,
1312 */ 1312 */
1313typedef void (mid_callback_t)(struct mid_q_entry *mid); 1313typedef void (mid_callback_t)(struct mid_q_entry *mid);
1314 1314
1315/*
1316 * This is the protopyte for mid handle function. This is called once the mid
1317 * has been recognized after decryption of the message.
1318 */
1319typedef int (mid_handle_t)(struct TCP_Server_Info *server,
1320 struct mid_q_entry *mid);
1321
1315/* one of these for every pending CIFS request to the server */ 1322/* one of these for every pending CIFS request to the server */
1316struct mid_q_entry { 1323struct mid_q_entry {
1317 struct list_head qhead; /* mids waiting on reply from this server */ 1324 struct list_head qhead; /* mids waiting on reply from this server */
@@ -1326,6 +1333,7 @@ struct mid_q_entry {
1326#endif 1333#endif
1327 mid_receive_t *receive; /* call receive callback */ 1334 mid_receive_t *receive; /* call receive callback */
1328 mid_callback_t *callback; /* call completion callback */ 1335 mid_callback_t *callback; /* call completion callback */
1336 mid_handle_t *handle; /* call handle mid callback */
1329 void *callback_data; /* general purpose pointer for callback */ 1337 void *callback_data; /* general purpose pointer for callback */
1330 void *resp_buf; /* pointer to received SMB header */ 1338 void *resp_buf; /* pointer to received SMB header */
1331 int mid_state; /* wish this were enum but can not pass to wait_event */ 1339 int mid_state; /* wish this were enum but can not pass to wait_event */
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 26872f54ca3f..057dcdd34244 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -78,7 +78,7 @@ extern void cifs_wake_up_task(struct mid_q_entry *mid);
78extern int cifs_call_async(struct TCP_Server_Info *server, 78extern int cifs_call_async(struct TCP_Server_Info *server,
79 struct smb_rqst *rqst, 79 struct smb_rqst *rqst,
80 mid_receive_t *receive, mid_callback_t *callback, 80 mid_receive_t *receive, mid_callback_t *callback,
81 void *cbdata, const int flags); 81 mid_handle_t *handle, void *cbdata, const int flags);
82extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses, 82extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
83 struct smb_rqst *rqst, int *resp_buf_type, 83 struct smb_rqst *rqst, int *resp_buf_type,
84 const int flags, struct kvec *resp_iov); 84 const int flags, struct kvec *resp_iov);
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index be9fa7ffe799..d4b92e33d50c 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -731,7 +731,7 @@ CIFSSMBEcho(struct TCP_Server_Info *server)
731 iov[1].iov_len = get_rfc1002_length(smb); 731 iov[1].iov_len = get_rfc1002_length(smb);
732 iov[1].iov_base = (char *)smb + 4; 732 iov[1].iov_base = (char *)smb + 4;
733 733
734 rc = cifs_call_async(server, &rqst, NULL, cifs_echo_callback, 734 rc = cifs_call_async(server, &rqst, NULL, cifs_echo_callback, NULL,
735 server, CIFS_ASYNC_OP | CIFS_ECHO_OP); 735 server, CIFS_ASYNC_OP | CIFS_ECHO_OP);
736 if (rc) 736 if (rc)
737 cifs_dbg(FYI, "Echo request failed: %d\n", rc); 737 cifs_dbg(FYI, "Echo request failed: %d\n", rc);
@@ -1654,7 +1654,7 @@ cifs_async_readv(struct cifs_readdata *rdata)
1654 1654
1655 kref_get(&rdata->refcount); 1655 kref_get(&rdata->refcount);
1656 rc = cifs_call_async(tcon->ses->server, &rqst, cifs_readv_receive, 1656 rc = cifs_call_async(tcon->ses->server, &rqst, cifs_readv_receive,
1657 cifs_readv_callback, rdata, 0); 1657 cifs_readv_callback, NULL, rdata, 0);
1658 1658
1659 if (rc == 0) 1659 if (rc == 0)
1660 cifs_stats_inc(&tcon->stats.cifs_stats.num_reads); 1660 cifs_stats_inc(&tcon->stats.cifs_stats.num_reads);
@@ -2168,7 +2168,7 @@ cifs_async_writev(struct cifs_writedata *wdata,
2168 2168
2169 kref_get(&wdata->refcount); 2169 kref_get(&wdata->refcount);
2170 rc = cifs_call_async(tcon->ses->server, &rqst, NULL, 2170 rc = cifs_call_async(tcon->ses->server, &rqst, NULL,
2171 cifs_writev_callback, wdata, 0); 2171 cifs_writev_callback, NULL, wdata, 0);
2172 2172
2173 if (rc == 0) 2173 if (rc == 0)
2174 cifs_stats_inc(&tcon->stats.cifs_stats.num_writes); 2174 cifs_stats_inc(&tcon->stats.cifs_stats.num_writes);
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index b088c5027111..12dee856d4d9 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -2144,8 +2144,8 @@ SMB2_echo(struct TCP_Server_Info *server)
2144 iov[1].iov_len = get_rfc1002_length(req); 2144 iov[1].iov_len = get_rfc1002_length(req);
2145 iov[1].iov_base = (char *)req + 4; 2145 iov[1].iov_base = (char *)req + 4;
2146 2146
2147 rc = cifs_call_async(server, &rqst, NULL, smb2_echo_callback, server, 2147 rc = cifs_call_async(server, &rqst, NULL, smb2_echo_callback, NULL,
2148 CIFS_ECHO_OP); 2148 server, CIFS_ECHO_OP);
2149 if (rc) 2149 if (rc)
2150 cifs_dbg(FYI, "Echo request failed: %d\n", rc); 2150 cifs_dbg(FYI, "Echo request failed: %d\n", rc);
2151 2151
@@ -2384,7 +2384,7 @@ smb2_async_readv(struct cifs_readdata *rdata)
2384 kref_get(&rdata->refcount); 2384 kref_get(&rdata->refcount);
2385 rc = cifs_call_async(io_parms.tcon->ses->server, &rqst, 2385 rc = cifs_call_async(io_parms.tcon->ses->server, &rqst,
2386 cifs_readv_receive, smb2_readv_callback, 2386 cifs_readv_receive, smb2_readv_callback,
2387 rdata, flags); 2387 NULL, rdata, flags);
2388 if (rc) { 2388 if (rc) {
2389 kref_put(&rdata->refcount, cifs_readdata_release); 2389 kref_put(&rdata->refcount, cifs_readdata_release);
2390 cifs_stats_fail_inc(io_parms.tcon, SMB2_READ_HE); 2390 cifs_stats_fail_inc(io_parms.tcon, SMB2_READ_HE);
@@ -2595,8 +2595,8 @@ smb2_async_writev(struct cifs_writedata *wdata,
2595 } 2595 }
2596 2596
2597 kref_get(&wdata->refcount); 2597 kref_get(&wdata->refcount);
2598 rc = cifs_call_async(server, &rqst, NULL, smb2_writev_callback, wdata, 2598 rc = cifs_call_async(server, &rqst, NULL, smb2_writev_callback, NULL,
2599 flags); 2599 wdata, flags);
2600 2600
2601 if (rc) { 2601 if (rc) {
2602 kref_put(&wdata->refcount, release); 2602 kref_put(&wdata->refcount, release);
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 3e5791aae0f6..526f0533cb4e 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -504,8 +504,8 @@ cifs_setup_async_request(struct TCP_Server_Info *server, struct smb_rqst *rqst)
504 */ 504 */
505int 505int
506cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst, 506cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
507 mid_receive_t *receive, mid_callback_t *callback, void *cbdata, 507 mid_receive_t *receive, mid_callback_t *callback,
508 const int flags) 508 mid_handle_t *handle, void *cbdata, const int flags)
509{ 509{
510 int rc, timeout, optype; 510 int rc, timeout, optype;
511 struct mid_q_entry *mid; 511 struct mid_q_entry *mid;
@@ -532,6 +532,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
532 mid->receive = receive; 532 mid->receive = receive;
533 mid->callback = callback; 533 mid->callback = callback;
534 mid->callback_data = cbdata; 534 mid->callback_data = cbdata;
535 mid->handle = handle;
535 mid->mid_state = MID_REQUEST_SUBMITTED; 536 mid->mid_state = MID_REQUEST_SUBMITTED;
536 537
537 /* put it on the pending_mid_q */ 538 /* put it on the pending_mid_q */