aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/transport.c')
-rw-r--r--fs/cifs/transport.c70
1 files changed, 30 insertions, 40 deletions
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index c1b9c4b10739..0cc9584f5889 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -26,6 +26,7 @@
26#include <linux/wait.h> 26#include <linux/wait.h>
27#include <linux/net.h> 27#include <linux/net.h>
28#include <linux/delay.h> 28#include <linux/delay.h>
29#include <linux/freezer.h>
29#include <asm/uaccess.h> 30#include <asm/uaccess.h>
30#include <asm/processor.h> 31#include <asm/processor.h>
31#include <linux/mempool.h> 32#include <linux/mempool.h>
@@ -266,15 +267,11 @@ static int wait_for_free_request(struct TCP_Server_Info *server,
266 while (1) { 267 while (1) {
267 if (atomic_read(&server->inFlight) >= cifs_max_pending) { 268 if (atomic_read(&server->inFlight) >= cifs_max_pending) {
268 spin_unlock(&GlobalMid_Lock); 269 spin_unlock(&GlobalMid_Lock);
269#ifdef CONFIG_CIFS_STATS2 270 cifs_num_waiters_inc(server);
270 atomic_inc(&server->num_waiters);
271#endif
272 wait_event(server->request_q, 271 wait_event(server->request_q,
273 atomic_read(&server->inFlight) 272 atomic_read(&server->inFlight)
274 < cifs_max_pending); 273 < cifs_max_pending);
275#ifdef CONFIG_CIFS_STATS2 274 cifs_num_waiters_dec(server);
276 atomic_dec(&server->num_waiters);
277#endif
278 spin_lock(&GlobalMid_Lock); 275 spin_lock(&GlobalMid_Lock);
279 } else { 276 } else {
280 if (server->tcpStatus == CifsExiting) { 277 if (server->tcpStatus == CifsExiting) {
@@ -328,7 +325,7 @@ wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ)
328{ 325{
329 int error; 326 int error;
330 327
331 error = wait_event_killable(server->response_q, 328 error = wait_event_freezekillable(server->response_q,
332 midQ->midState != MID_REQUEST_SUBMITTED); 329 midQ->midState != MID_REQUEST_SUBMITTED);
333 if (error < 0) 330 if (error < 0)
334 return -ERESTARTSYS; 331 return -ERESTARTSYS;
@@ -343,8 +340,8 @@ wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ)
343 */ 340 */
344int 341int
345cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov, 342cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov,
346 unsigned int nvec, mid_callback_t *callback, void *cbdata, 343 unsigned int nvec, mid_receive_t *receive,
347 bool ignore_pend) 344 mid_callback_t *callback, void *cbdata, bool ignore_pend)
348{ 345{
349 int rc; 346 int rc;
350 struct mid_q_entry *mid; 347 struct mid_q_entry *mid;
@@ -378,18 +375,17 @@ cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov,
378 goto out_err; 375 goto out_err;
379 } 376 }
380 377
378 mid->receive = receive;
381 mid->callback = callback; 379 mid->callback = callback;
382 mid->callback_data = cbdata; 380 mid->callback_data = cbdata;
383 mid->midState = MID_REQUEST_SUBMITTED; 381 mid->midState = MID_REQUEST_SUBMITTED;
384#ifdef CONFIG_CIFS_STATS2 382
385 atomic_inc(&server->inSend); 383 cifs_in_send_inc(server);
386#endif
387 rc = smb_sendv(server, iov, nvec); 384 rc = smb_sendv(server, iov, nvec);
388#ifdef CONFIG_CIFS_STATS2 385 cifs_in_send_dec(server);
389 atomic_dec(&server->inSend); 386 cifs_save_when_sent(mid);
390 mid->when_sent = jiffies;
391#endif
392 mutex_unlock(&server->srv_mutex); 387 mutex_unlock(&server->srv_mutex);
388
393 if (rc) 389 if (rc)
394 goto out_err; 390 goto out_err;
395 391
@@ -502,13 +498,18 @@ int
502cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, 498cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
503 bool log_error) 499 bool log_error)
504{ 500{
505 dump_smb(mid->resp_buf, 501 unsigned int len = be32_to_cpu(mid->resp_buf->smb_buf_length) + 4;
506 min_t(u32, 92, be32_to_cpu(mid->resp_buf->smb_buf_length))); 502
503 dump_smb(mid->resp_buf, min_t(u32, 92, len));
507 504
508 /* convert the length into a more usable form */ 505 /* convert the length into a more usable form */
509 if (server->sec_mode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) { 506 if (server->sec_mode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) {
507 struct kvec iov;
508
509 iov.iov_base = mid->resp_buf;
510 iov.iov_len = len;
510 /* FIXME: add code to kill session */ 511 /* FIXME: add code to kill session */
511 if (cifs_verify_signature(mid->resp_buf, server, 512 if (cifs_verify_signature(&iov, 1, server,
512 mid->sequence_number + 1) != 0) 513 mid->sequence_number + 1) != 0)
513 cERROR(1, "Unexpected SMB signature"); 514 cERROR(1, "Unexpected SMB signature");
514 } 515 }
@@ -575,14 +576,10 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
575 } 576 }
576 577
577 midQ->midState = MID_REQUEST_SUBMITTED; 578 midQ->midState = MID_REQUEST_SUBMITTED;
578#ifdef CONFIG_CIFS_STATS2 579 cifs_in_send_inc(ses->server);
579 atomic_inc(&ses->server->inSend);
580#endif
581 rc = smb_sendv(ses->server, iov, n_vec); 580 rc = smb_sendv(ses->server, iov, n_vec);
582#ifdef CONFIG_CIFS_STATS2 581 cifs_in_send_dec(ses->server);
583 atomic_dec(&ses->server->inSend); 582 cifs_save_when_sent(midQ);
584 midQ->when_sent = jiffies;
585#endif
586 583
587 mutex_unlock(&ses->server->srv_mutex); 584 mutex_unlock(&ses->server->srv_mutex);
588 585
@@ -703,14 +700,11 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
703 } 700 }
704 701
705 midQ->midState = MID_REQUEST_SUBMITTED; 702 midQ->midState = MID_REQUEST_SUBMITTED;
706#ifdef CONFIG_CIFS_STATS2 703
707 atomic_inc(&ses->server->inSend); 704 cifs_in_send_inc(ses->server);
708#endif
709 rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); 705 rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
710#ifdef CONFIG_CIFS_STATS2 706 cifs_in_send_dec(ses->server);
711 atomic_dec(&ses->server->inSend); 707 cifs_save_when_sent(midQ);
712 midQ->when_sent = jiffies;
713#endif
714 mutex_unlock(&ses->server->srv_mutex); 708 mutex_unlock(&ses->server->srv_mutex);
715 709
716 if (rc < 0) 710 if (rc < 0)
@@ -843,14 +837,10 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
843 } 837 }
844 838
845 midQ->midState = MID_REQUEST_SUBMITTED; 839 midQ->midState = MID_REQUEST_SUBMITTED;
846#ifdef CONFIG_CIFS_STATS2 840 cifs_in_send_inc(ses->server);
847 atomic_inc(&ses->server->inSend);
848#endif
849 rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); 841 rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
850#ifdef CONFIG_CIFS_STATS2 842 cifs_in_send_dec(ses->server);
851 atomic_dec(&ses->server->inSend); 843 cifs_save_when_sent(midQ);
852 midQ->when_sent = jiffies;
853#endif
854 mutex_unlock(&ses->server->srv_mutex); 844 mutex_unlock(&ses->server->srv_mutex);
855 845
856 if (rc < 0) { 846 if (rc < 0) {