Skip to content

Commit

Permalink
CIFS: Add mid handle callback
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
piastry authored and smfrench committed Feb 1, 2017
1 parent 9bb17e0 commit 9b7c18a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
8 changes: 8 additions & 0 deletions fs/cifs/cifsglob.h
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,13 @@ typedef int (mid_receive_t)(struct TCP_Server_Info *server,
*/
typedef void (mid_callback_t)(struct mid_q_entry *mid);

/*
* This is the protopyte for mid handle function. This is called once the mid
* has been recognized after decryption of the message.
*/
typedef int (mid_handle_t)(struct TCP_Server_Info *server,
struct mid_q_entry *mid);

/* one of these for every pending CIFS request to the server */
struct mid_q_entry {
struct list_head qhead; /* mids waiting on reply from this server */
Expand All @@ -1326,6 +1333,7 @@ struct mid_q_entry {
#endif
mid_receive_t *receive; /* call receive callback */
mid_callback_t *callback; /* call completion callback */
mid_handle_t *handle; /* call handle mid callback */
void *callback_data; /* general purpose pointer for callback */
void *resp_buf; /* pointer to received SMB header */
int mid_state; /* wish this were enum but can not pass to wait_event */
Expand Down
2 changes: 1 addition & 1 deletion fs/cifs/cifsproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ extern void cifs_wake_up_task(struct mid_q_entry *mid);
extern int cifs_call_async(struct TCP_Server_Info *server,
struct smb_rqst *rqst,
mid_receive_t *receive, mid_callback_t *callback,
void *cbdata, const int flags);
mid_handle_t *handle, void *cbdata, const int flags);
extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
struct smb_rqst *rqst, int *resp_buf_type,
const int flags, struct kvec *resp_iov);
Expand Down
6 changes: 3 additions & 3 deletions fs/cifs/cifssmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ CIFSSMBEcho(struct TCP_Server_Info *server)
iov[1].iov_len = get_rfc1002_length(smb);
iov[1].iov_base = (char *)smb + 4;

rc = cifs_call_async(server, &rqst, NULL, cifs_echo_callback,
rc = cifs_call_async(server, &rqst, NULL, cifs_echo_callback, NULL,
server, CIFS_ASYNC_OP | CIFS_ECHO_OP);
if (rc)
cifs_dbg(FYI, "Echo request failed: %d\n", rc);
Expand Down Expand Up @@ -1654,7 +1654,7 @@ cifs_async_readv(struct cifs_readdata *rdata)

kref_get(&rdata->refcount);
rc = cifs_call_async(tcon->ses->server, &rqst, cifs_readv_receive,
cifs_readv_callback, rdata, 0);
cifs_readv_callback, NULL, rdata, 0);

if (rc == 0)
cifs_stats_inc(&tcon->stats.cifs_stats.num_reads);
Expand Down Expand Up @@ -2168,7 +2168,7 @@ cifs_async_writev(struct cifs_writedata *wdata,

kref_get(&wdata->refcount);
rc = cifs_call_async(tcon->ses->server, &rqst, NULL,
cifs_writev_callback, wdata, 0);
cifs_writev_callback, NULL, wdata, 0);

if (rc == 0)
cifs_stats_inc(&tcon->stats.cifs_stats.num_writes);
Expand Down
10 changes: 5 additions & 5 deletions fs/cifs/smb2pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2144,8 +2144,8 @@ SMB2_echo(struct TCP_Server_Info *server)
iov[1].iov_len = get_rfc1002_length(req);
iov[1].iov_base = (char *)req + 4;

rc = cifs_call_async(server, &rqst, NULL, smb2_echo_callback, server,
CIFS_ECHO_OP);
rc = cifs_call_async(server, &rqst, NULL, smb2_echo_callback, NULL,
server, CIFS_ECHO_OP);
if (rc)
cifs_dbg(FYI, "Echo request failed: %d\n", rc);

Expand Down Expand Up @@ -2384,7 +2384,7 @@ smb2_async_readv(struct cifs_readdata *rdata)
kref_get(&rdata->refcount);
rc = cifs_call_async(io_parms.tcon->ses->server, &rqst,
cifs_readv_receive, smb2_readv_callback,
rdata, flags);
NULL, rdata, flags);
if (rc) {
kref_put(&rdata->refcount, cifs_readdata_release);
cifs_stats_fail_inc(io_parms.tcon, SMB2_READ_HE);
Expand Down Expand Up @@ -2595,8 +2595,8 @@ smb2_async_writev(struct cifs_writedata *wdata,
}

kref_get(&wdata->refcount);
rc = cifs_call_async(server, &rqst, NULL, smb2_writev_callback, wdata,
flags);
rc = cifs_call_async(server, &rqst, NULL, smb2_writev_callback, NULL,
wdata, flags);

if (rc) {
kref_put(&wdata->refcount, release);
Expand Down
5 changes: 3 additions & 2 deletions fs/cifs/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,8 @@ cifs_setup_async_request(struct TCP_Server_Info *server, struct smb_rqst *rqst)
*/
int
cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
mid_receive_t *receive, mid_callback_t *callback, void *cbdata,
const int flags)
mid_receive_t *receive, mid_callback_t *callback,
mid_handle_t *handle, void *cbdata, const int flags)
{
int rc, timeout, optype;
struct mid_q_entry *mid;
Expand All @@ -532,6 +532,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
mid->receive = receive;
mid->callback = callback;
mid->callback_data = cbdata;
mid->handle = handle;
mid->mid_state = MID_REQUEST_SUBMITTED;

/* put it on the pending_mid_q */
Expand Down

0 comments on commit 9b7c18a

Please sign in to comment.