aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/cifs/cifsproto.h5
-rw-r--r--fs/cifs/transport.c58
2 files changed, 62 insertions, 1 deletions
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 95d5dbbb4c7a..7f2988bb8929 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -61,6 +61,11 @@ extern char *cifs_compose_mount_options(const char *sb_mountdata,
61 const char *fullpath, const struct dfs_info3_param *ref, 61 const char *fullpath, const struct dfs_info3_param *ref,
62 char **devname); 62 char **devname);
63/* extern void renew_parental_timestamps(struct dentry *direntry);*/ 63/* extern void renew_parental_timestamps(struct dentry *direntry);*/
64extern struct mid_q_entry *AllocMidQEntry(const struct smb_hdr *smb_buffer,
65 struct TCP_Server_Info *server);
66extern int cifs_call_async(struct TCP_Server_Info *server,
67 struct smb_hdr *in_buf, mid_callback_t *callback,
68 void *cbdata);
64extern int SendReceive(const unsigned int /* xid */ , struct cifsSesInfo *, 69extern int SendReceive(const unsigned int /* xid */ , struct cifsSesInfo *,
65 struct smb_hdr * /* input */ , 70 struct smb_hdr * /* input */ ,
66 struct smb_hdr * /* out */ , 71 struct smb_hdr * /* out */ ,
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index d77b6154cf22..166b65a3763e 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -42,7 +42,7 @@ wake_up_task(struct mid_q_entry *mid)
42 wake_up_process(mid->callback_data); 42 wake_up_process(mid->callback_data);
43} 43}
44 44
45static struct mid_q_entry * 45struct mid_q_entry *
46AllocMidQEntry(const struct smb_hdr *smb_buffer, struct TCP_Server_Info *server) 46AllocMidQEntry(const struct smb_hdr *smb_buffer, struct TCP_Server_Info *server)
47{ 47{
48 struct mid_q_entry *temp; 48 struct mid_q_entry *temp;
@@ -345,6 +345,62 @@ wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ)
345 345
346 346
347/* 347/*
348 * Send a SMB request and set the callback function in the mid to handle
349 * the result. Caller is responsible for dealing with timeouts.
350 */
351int
352cifs_call_async(struct TCP_Server_Info *server, struct smb_hdr *in_buf,
353 mid_callback_t *callback, void *cbdata)
354{
355 int rc;
356 struct mid_q_entry *mid;
357
358 rc = wait_for_free_request(server, CIFS_ASYNC_OP);
359 if (rc)
360 return rc;
361
362 mutex_lock(&server->srv_mutex);
363 mid = AllocMidQEntry(in_buf, server);
364 if (mid == NULL) {
365 mutex_unlock(&server->srv_mutex);
366 return -ENOMEM;
367 }
368
369 /* put it on the pending_mid_q */
370 spin_lock(&GlobalMid_Lock);
371 list_add_tail(&mid->qhead, &server->pending_mid_q);
372 spin_unlock(&GlobalMid_Lock);
373
374 rc = cifs_sign_smb(in_buf, server, &mid->sequence_number);
375 if (rc) {
376 mutex_unlock(&server->srv_mutex);
377 goto out_err;
378 }
379
380 mid->callback = callback;
381 mid->callback_data = cbdata;
382 mid->midState = MID_REQUEST_SUBMITTED;
383#ifdef CONFIG_CIFS_STATS2
384 atomic_inc(&server->inSend);
385#endif
386 rc = smb_send(server, in_buf, in_buf->smb_buf_length);
387#ifdef CONFIG_CIFS_STATS2
388 atomic_dec(&server->inSend);
389 mid->when_sent = jiffies;
390#endif
391 mutex_unlock(&server->srv_mutex);
392 if (rc)
393 goto out_err;
394
395 return rc;
396out_err:
397 delete_mid(mid);
398 atomic_dec(&server->inFlight);
399 wake_up(&server->request_q);
400 return rc;
401}
402
403/*
348 * 404 *
349 * Send an SMB Request. No response info (other than return code) 405 * Send an SMB Request. No response info (other than return code)
350 * needs to be parsed. 406 * needs to be parsed.