forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/fs/cifs/transport.c
....@@ -33,6 +33,7 @@
3333 #include <linux/uaccess.h>
3434 #include <asm/processor.h>
3535 #include <linux/mempool.h>
36
+#include <linux/sched/signal.h>
3637 #include "cifspdu.h"
3738 #include "cifsglob.h"
3839 #include "cifsproto.h"
....@@ -75,6 +76,8 @@
7576 * The default is for the mid to be synchronous, so the
7677 * default callback just wakes up the current task.
7778 */
79
+ get_task_struct(current);
80
+ temp->creator = current;
7881 temp->callback = cifs_wake_up_task;
7982 temp->callback_data = current;
8083
....@@ -85,10 +88,81 @@
8588
8689 static void _cifs_mid_q_entry_release(struct kref *refcount)
8790 {
88
- struct mid_q_entry *mid = container_of(refcount, struct mid_q_entry,
89
- refcount);
91
+ struct mid_q_entry *midEntry =
92
+ container_of(refcount, struct mid_q_entry, refcount);
93
+#ifdef CONFIG_CIFS_STATS2
94
+ __le16 command = midEntry->server->vals->lock_cmd;
95
+ __u16 smb_cmd = le16_to_cpu(midEntry->command);
96
+ unsigned long now;
97
+ unsigned long roundtrip_time;
98
+#endif
99
+ struct TCP_Server_Info *server = midEntry->server;
90100
91
- mempool_free(mid, cifs_mid_poolp);
101
+ if (midEntry->resp_buf && (midEntry->mid_flags & MID_WAIT_CANCELLED) &&
102
+ midEntry->mid_state == MID_RESPONSE_RECEIVED &&
103
+ server->ops->handle_cancelled_mid)
104
+ server->ops->handle_cancelled_mid(midEntry, server);
105
+
106
+ midEntry->mid_state = MID_FREE;
107
+ atomic_dec(&midCount);
108
+ if (midEntry->large_buf)
109
+ cifs_buf_release(midEntry->resp_buf);
110
+ else
111
+ cifs_small_buf_release(midEntry->resp_buf);
112
+#ifdef CONFIG_CIFS_STATS2
113
+ now = jiffies;
114
+ if (now < midEntry->when_alloc)
115
+ cifs_server_dbg(VFS, "Invalid mid allocation time\n");
116
+ roundtrip_time = now - midEntry->when_alloc;
117
+
118
+ if (smb_cmd < NUMBER_OF_SMB2_COMMANDS) {
119
+ if (atomic_read(&server->num_cmds[smb_cmd]) == 0) {
120
+ server->slowest_cmd[smb_cmd] = roundtrip_time;
121
+ server->fastest_cmd[smb_cmd] = roundtrip_time;
122
+ } else {
123
+ if (server->slowest_cmd[smb_cmd] < roundtrip_time)
124
+ server->slowest_cmd[smb_cmd] = roundtrip_time;
125
+ else if (server->fastest_cmd[smb_cmd] > roundtrip_time)
126
+ server->fastest_cmd[smb_cmd] = roundtrip_time;
127
+ }
128
+ cifs_stats_inc(&server->num_cmds[smb_cmd]);
129
+ server->time_per_cmd[smb_cmd] += roundtrip_time;
130
+ }
131
+ /*
132
+ * commands taking longer than one second (default) can be indications
133
+ * that something is wrong, unless it is quite a slow link or a very
134
+ * busy server. Note that this calc is unlikely or impossible to wrap
135
+ * as long as slow_rsp_threshold is not set way above recommended max
136
+ * value (32767 ie 9 hours) and is generally harmless even if wrong
137
+ * since only affects debug counters - so leaving the calc as simple
138
+ * comparison rather than doing multiple conversions and overflow
139
+ * checks
140
+ */
141
+ if ((slow_rsp_threshold != 0) &&
142
+ time_after(now, midEntry->when_alloc + (slow_rsp_threshold * HZ)) &&
143
+ (midEntry->command != command)) {
144
+ /*
145
+ * smb2slowcmd[NUMBER_OF_SMB2_COMMANDS] counts by command
146
+ * NB: le16_to_cpu returns unsigned so can not be negative below
147
+ */
148
+ if (smb_cmd < NUMBER_OF_SMB2_COMMANDS)
149
+ cifs_stats_inc(&server->smb2slowcmd[smb_cmd]);
150
+
151
+ trace_smb3_slow_rsp(smb_cmd, midEntry->mid, midEntry->pid,
152
+ midEntry->when_sent, midEntry->when_received);
153
+ if (cifsFYI & CIFS_TIMER) {
154
+ pr_debug("slow rsp: cmd %d mid %llu",
155
+ midEntry->command, midEntry->mid);
156
+ cifs_info("A: 0x%lx S: 0x%lx R: 0x%lx\n",
157
+ now - midEntry->when_alloc,
158
+ now - midEntry->when_sent,
159
+ now - midEntry->when_received);
160
+ }
161
+ }
162
+#endif
163
+ put_task_struct(midEntry->creator);
164
+
165
+ mempool_free(midEntry, cifs_mid_poolp);
92166 }
93167
94168 void cifs_mid_q_entry_release(struct mid_q_entry *midEntry)
....@@ -98,43 +172,8 @@
98172 spin_unlock(&GlobalMid_Lock);
99173 }
100174
101
-void
102
-DeleteMidQEntry(struct mid_q_entry *midEntry)
175
+void DeleteMidQEntry(struct mid_q_entry *midEntry)
103176 {
104
-#ifdef CONFIG_CIFS_STATS2
105
- __le16 command = midEntry->server->vals->lock_cmd;
106
- unsigned long now;
107
-#endif
108
- midEntry->mid_state = MID_FREE;
109
- atomic_dec(&midCount);
110
- if (midEntry->large_buf)
111
- cifs_buf_release(midEntry->resp_buf);
112
- else
113
- cifs_small_buf_release(midEntry->resp_buf);
114
-#ifdef CONFIG_CIFS_STATS2
115
- now = jiffies;
116
- /* commands taking longer than one second are indications that
117
- something is wrong, unless it is quite a slow link or server */
118
- if (time_after(now, midEntry->when_alloc + HZ) &&
119
- (midEntry->command != command)) {
120
- /* smb2slowcmd[NUMBER_OF_SMB2_COMMANDS] counts by command */
121
- if ((le16_to_cpu(midEntry->command) < NUMBER_OF_SMB2_COMMANDS) &&
122
- (le16_to_cpu(midEntry->command) >= 0))
123
- cifs_stats_inc(&midEntry->server->smb2slowcmd[le16_to_cpu(midEntry->command)]);
124
-
125
- trace_smb3_slow_rsp(le16_to_cpu(midEntry->command),
126
- midEntry->mid, midEntry->pid,
127
- midEntry->when_sent, midEntry->when_received);
128
- if (cifsFYI & CIFS_TIMER) {
129
- pr_debug(" CIFS slow rsp: cmd %d mid %llu",
130
- midEntry->command, midEntry->mid);
131
- pr_info(" A: 0x%lx S: 0x%lx R: 0x%lx\n",
132
- now - midEntry->when_alloc,
133
- now - midEntry->when_sent,
134
- now - midEntry->when_received);
135
- }
136
- }
137
-#endif
138177 cifs_mid_q_entry_release(midEntry);
139178 }
140179
....@@ -142,8 +181,10 @@
142181 cifs_delete_mid(struct mid_q_entry *mid)
143182 {
144183 spin_lock(&GlobalMid_Lock);
145
- list_del_init(&mid->qhead);
146
- mid->mid_flags |= MID_DELETED;
184
+ if (!(mid->mid_flags & MID_DELETED)) {
185
+ list_del_init(&mid->qhead);
186
+ mid->mid_flags |= MID_DELETED;
187
+ }
147188 spin_unlock(&GlobalMid_Lock);
148189
149190 DeleteMidQEntry(mid);
....@@ -168,10 +209,6 @@
168209
169210 *sent = 0;
170211
171
- smb_msg->msg_name = (struct sockaddr *) &server->dstaddr;
172
- smb_msg->msg_namelen = sizeof(struct sockaddr);
173
- smb_msg->msg_control = NULL;
174
- smb_msg->msg_controllen = 0;
175212 if (server->noblocksnd)
176213 smb_msg->msg_flags = MSG_DONTWAIT + MSG_NOSIGNAL;
177214 else
....@@ -201,7 +238,7 @@
201238 retries++;
202239 if (retries >= 14 ||
203240 (!server->noblocksnd && (retries > 2))) {
204
- cifs_dbg(VFS, "sends on sock %p stuck for 15 seconds\n",
241
+ cifs_server_dbg(VFS, "sends on sock %p stuck for 15 seconds\n",
205242 ssocket);
206243 return -EAGAIN;
207244 }
....@@ -215,7 +252,7 @@
215252 if (rc == 0) {
216253 /* should never happen, letting socket clear before
217254 retrying is our only obvious option here */
218
- cifs_dbg(VFS, "tcp sent no data\n");
255
+ cifs_server_dbg(VFS, "tcp sent no data\n");
219256 msleep(500);
220257 continue;
221258 }
....@@ -280,10 +317,10 @@
280317 int n_vec;
281318 unsigned int send_length = 0;
282319 unsigned int i, j;
320
+ sigset_t mask, oldmask;
283321 size_t total_len = 0, sent, size;
284322 struct socket *ssocket = server->ssocket;
285
- struct msghdr smb_msg;
286
- int val = 1;
323
+ struct msghdr smb_msg = {};
287324 __be32 rfc1002_marker;
288325
289326 if (cifs_rdma_enabled(server)) {
....@@ -293,16 +330,31 @@
293330 rc = smbd_send(server, num_rqst, rqst);
294331 goto smbd_done;
295332 }
333
+
296334 if (ssocket == NULL)
297
- return -ENOTSOCK;
335
+ return -EAGAIN;
336
+
337
+ if (fatal_signal_pending(current)) {
338
+ cifs_dbg(FYI, "signal pending before send request\n");
339
+ return -ERESTARTSYS;
340
+ }
298341
299342 /* cork the socket */
300
- kernel_setsockopt(ssocket, SOL_TCP, TCP_CORK,
301
- (char *)&val, sizeof(val));
343
+ tcp_sock_set_cork(ssocket->sk, true);
302344
303345 for (j = 0; j < num_rqst; j++)
304346 send_length += smb_rqst_len(server, &rqst[j]);
305347 rfc1002_marker = cpu_to_be32(send_length);
348
+
349
+ /*
350
+ * We should not allow signals to interrupt the network send because
351
+ * any partial send will cause session reconnects thus increasing
352
+ * latency of system calls and overload a server with unnecessary
353
+ * requests.
354
+ */
355
+
356
+ sigfillset(&mask);
357
+ sigprocmask(SIG_BLOCK, &mask, &oldmask);
306358
307359 /* Generate a rfc1002 marker for SMB2+ */
308360 if (server->vals->header_preamble_size == 0) {
....@@ -310,11 +362,10 @@
310362 .iov_base = &rfc1002_marker,
311363 .iov_len = 4
312364 };
313
- iov_iter_kvec(&smb_msg.msg_iter, WRITE | ITER_KVEC, &hiov,
314
- 1, 4);
365
+ iov_iter_kvec(&smb_msg.msg_iter, WRITE, &hiov, 1, 4);
315366 rc = smb_send_kvec(server, &smb_msg, &sent);
316367 if (rc < 0)
317
- goto uncork;
368
+ goto unmask;
318369
319370 total_len += sent;
320371 send_length += 4;
....@@ -332,12 +383,11 @@
332383 size += iov[i].iov_len;
333384 }
334385
335
- iov_iter_kvec(&smb_msg.msg_iter, WRITE | ITER_KVEC,
336
- iov, n_vec, size);
386
+ iov_iter_kvec(&smb_msg.msg_iter, WRITE, iov, n_vec, size);
337387
338388 rc = smb_send_kvec(server, &smb_msg, &sent);
339389 if (rc < 0)
340
- goto uncork;
390
+ goto unmask;
341391
342392 total_len += sent;
343393
....@@ -349,7 +399,7 @@
349399 rqst_page_get_length(&rqst[j], i, &bvec.bv_len,
350400 &bvec.bv_offset);
351401
352
- iov_iter_bvec(&smb_msg.msg_iter, WRITE | ITER_BVEC,
402
+ iov_iter_bvec(&smb_msg.msg_iter, WRITE,
353403 &bvec, 1, bvec.bv_len);
354404 rc = smb_send_kvec(server, &smb_msg, &sent);
355405 if (rc < 0)
....@@ -359,11 +409,27 @@
359409 }
360410 }
361411
362
-uncork:
412
+unmask:
413
+ sigprocmask(SIG_SETMASK, &oldmask, NULL);
414
+
415
+ /*
416
+ * If signal is pending but we have already sent the whole packet to
417
+ * the server we need to return success status to allow a corresponding
418
+ * mid entry to be kept in the pending requests queue thus allowing
419
+ * to handle responses from the server by the client.
420
+ *
421
+ * If only part of the packet has been sent there is no need to hide
422
+ * interrupt because the session will be reconnected anyway, so there
423
+ * won't be any response from the server to handle.
424
+ */
425
+
426
+ if (signal_pending(current) && (total_len != send_length)) {
427
+ cifs_dbg(FYI, "signal is pending after attempt to send\n");
428
+ rc = -ERESTARTSYS;
429
+ }
430
+
363431 /* uncork it */
364
- val = 0;
365
- kernel_setsockopt(ssocket, SOL_TCP, TCP_CORK,
366
- (char *)&val, sizeof(val));
432
+ tcp_sock_set_cork(ssocket->sk, false);
367433
368434 if ((total_len > 0) && (total_len != send_length)) {
369435 cifs_dbg(FYI, "partial send (wanted=%u sent=%zu): terminating session\n",
....@@ -379,7 +445,7 @@
379445 }
380446 smbd_done:
381447 if (rc < 0 && rc != -EINTR)
382
- cifs_dbg(VFS, "Error %d sending data on socket to server\n",
448
+ cifs_server_dbg(VFS, "Error %d sending data on socket to server\n",
383449 rc);
384450 else if (rc > 0)
385451 rc = 0;
....@@ -403,8 +469,7 @@
403469 return -ENOMEM;
404470
405471 if (!server->ops->init_transform_rq) {
406
- cifs_dbg(VFS, "Encryption requested but transform callback "
407
- "is missing\n");
472
+ cifs_server_dbg(VFS, "Encryption requested but transform callback is missing\n");
408473 return -EIO;
409474 }
410475
....@@ -450,29 +515,57 @@
450515 }
451516
452517 static int
453
-wait_for_free_credits(struct TCP_Server_Info *server, const int timeout,
454
- int *credits)
518
+wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits,
519
+ const int timeout, const int flags,
520
+ unsigned int *instance)
455521 {
456
- int rc;
522
+ long rc;
523
+ int *credits;
524
+ int optype;
525
+ long int t;
526
+
527
+ if (timeout < 0)
528
+ t = MAX_JIFFY_OFFSET;
529
+ else
530
+ t = msecs_to_jiffies(timeout);
531
+
532
+ optype = flags & CIFS_OP_MASK;
533
+
534
+ *instance = 0;
535
+
536
+ credits = server->ops->get_credits_field(server, optype);
537
+ /* Since an echo is already inflight, no need to wait to send another */
538
+ if (*credits <= 0 && optype == CIFS_ECHO_OP)
539
+ return -EAGAIN;
457540
458541 spin_lock(&server->req_lock);
459
- if (timeout == CIFS_ASYNC_OP) {
542
+ if ((flags & CIFS_TIMEOUT_MASK) == CIFS_NON_BLOCKING) {
460543 /* oplock breaks must not be held up */
461544 server->in_flight++;
545
+ if (server->in_flight > server->max_in_flight)
546
+ server->max_in_flight = server->in_flight;
462547 *credits -= 1;
548
+ *instance = server->reconnect_instance;
463549 spin_unlock(&server->req_lock);
464550 return 0;
465551 }
466552
467553 while (1) {
468
- if (*credits <= 0) {
554
+ if (*credits < num_credits) {
469555 spin_unlock(&server->req_lock);
470556 cifs_num_waiters_inc(server);
471
- rc = wait_event_killable(server->request_q,
472
- has_credits(server, credits));
557
+ rc = wait_event_killable_timeout(server->request_q,
558
+ has_credits(server, credits, num_credits), t);
473559 cifs_num_waiters_dec(server);
474
- if (rc)
475
- return rc;
560
+ if (!rc) {
561
+ trace_smb3_credit_timeout(server->CurrentMid,
562
+ server->hostname, num_credits, 0);
563
+ cifs_server_dbg(VFS, "wait timed out after %d ms\n",
564
+ timeout);
565
+ return -ENOTSUPP;
566
+ }
567
+ if (rc == -ERESTARTSYS)
568
+ return -ERESTARTSYS;
476569 spin_lock(&server->req_lock);
477570 } else {
478571 if (server->tcpStatus == CifsExiting) {
....@@ -481,14 +574,56 @@
481574 }
482575
483576 /*
577
+ * For normal commands, reserve the last MAX_COMPOUND
578
+ * credits to compound requests.
579
+ * Otherwise these compounds could be permanently
580
+ * starved for credits by single-credit requests.
581
+ *
582
+ * To prevent spinning CPU, block this thread until
583
+ * there are >MAX_COMPOUND credits available.
584
+ * But only do this is we already have a lot of
585
+ * credits in flight to avoid triggering this check
586
+ * for servers that are slow to hand out credits on
587
+ * new sessions.
588
+ */
589
+ if (!optype && num_credits == 1 &&
590
+ server->in_flight > 2 * MAX_COMPOUND &&
591
+ *credits <= MAX_COMPOUND) {
592
+ spin_unlock(&server->req_lock);
593
+ cifs_num_waiters_inc(server);
594
+ rc = wait_event_killable_timeout(
595
+ server->request_q,
596
+ has_credits(server, credits,
597
+ MAX_COMPOUND + 1),
598
+ t);
599
+ cifs_num_waiters_dec(server);
600
+ if (!rc) {
601
+ trace_smb3_credit_timeout(
602
+ server->CurrentMid,
603
+ server->hostname, num_credits,
604
+ 0);
605
+ cifs_server_dbg(VFS, "wait timed out after %d ms\n",
606
+ timeout);
607
+ return -ENOTSUPP;
608
+ }
609
+ if (rc == -ERESTARTSYS)
610
+ return -ERESTARTSYS;
611
+ spin_lock(&server->req_lock);
612
+ continue;
613
+ }
614
+
615
+ /*
484616 * Can not count locking commands against total
485617 * as they are allowed to block on server.
486618 */
487619
488620 /* update # of requests on the wire to server */
489
- if (timeout != CIFS_BLOCKING_OP) {
490
- *credits -= 1;
491
- server->in_flight++;
621
+ if ((flags & CIFS_TIMEOUT_MASK) != CIFS_BLOCKING_OP) {
622
+ *credits -= num_credits;
623
+ server->in_flight += num_credits;
624
+ if (server->in_flight > server->max_in_flight)
625
+ server->max_in_flight = server->in_flight;
626
+ *instance = server->reconnect_instance;
492627 }
493628 spin_unlock(&server->req_lock);
494629 break;
....@@ -498,24 +633,57 @@
498633 }
499634
500635 static int
501
-wait_for_free_request(struct TCP_Server_Info *server, const int timeout,
502
- const int optype)
636
+wait_for_free_request(struct TCP_Server_Info *server, const int flags,
637
+ unsigned int *instance)
503638 {
504
- int *val;
639
+ return wait_for_free_credits(server, 1, -1, flags,
640
+ instance);
641
+}
505642
506
- val = server->ops->get_credits_field(server, optype);
507
- /* Since an echo is already inflight, no need to wait to send another */
508
- if (*val <= 0 && optype == CIFS_ECHO_OP)
509
- return -EAGAIN;
510
- return wait_for_free_credits(server, timeout, val);
643
+static int
644
+wait_for_compound_request(struct TCP_Server_Info *server, int num,
645
+ const int flags, unsigned int *instance)
646
+{
647
+ int *credits;
648
+
649
+ credits = server->ops->get_credits_field(server, flags & CIFS_OP_MASK);
650
+
651
+ spin_lock(&server->req_lock);
652
+ if (*credits < num) {
653
+ /*
654
+ * If the server is tight on resources or just gives us less
655
+ * credits for other reasons (e.g. requests are coming out of
656
+ * order and the server delays granting more credits until it
657
+ * processes a missing mid) and we exhausted most available
658
+ * credits there may be situations when we try to send
659
+ * a compound request but we don't have enough credits. At this
660
+ * point the client needs to decide if it should wait for
661
+ * additional credits or fail the request. If at least one
662
+ * request is in flight there is a high probability that the
663
+ * server will return enough credits to satisfy this compound
664
+ * request.
665
+ *
666
+ * Return immediately if no requests in flight since we will be
667
+ * stuck on waiting for credits.
668
+ */
669
+ if (server->in_flight == 0) {
670
+ spin_unlock(&server->req_lock);
671
+ return -ENOTSUPP;
672
+ }
673
+ }
674
+ spin_unlock(&server->req_lock);
675
+
676
+ return wait_for_free_credits(server, num, 60000, flags,
677
+ instance);
511678 }
512679
513680 int
514681 cifs_wait_mtu_credits(struct TCP_Server_Info *server, unsigned int size,
515
- unsigned int *num, unsigned int *credits)
682
+ unsigned int *num, struct cifs_credits *credits)
516683 {
517684 *num = size;
518
- *credits = 0;
685
+ credits->value = 0;
686
+ credits->instance = server->reconnect_instance;
519687 return 0;
520688 }
521689
....@@ -602,27 +770,43 @@
602770 int
603771 cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
604772 mid_receive_t *receive, mid_callback_t *callback,
605
- mid_handle_t *handle, void *cbdata, const int flags)
773
+ mid_handle_t *handle, void *cbdata, const int flags,
774
+ const struct cifs_credits *exist_credits)
606775 {
607
- int rc, timeout, optype;
776
+ int rc;
608777 struct mid_q_entry *mid;
609
- unsigned int credits = 0;
778
+ struct cifs_credits credits = { .value = 0, .instance = 0 };
779
+ unsigned int instance;
780
+ int optype;
610781
611
- timeout = flags & CIFS_TIMEOUT_MASK;
612782 optype = flags & CIFS_OP_MASK;
613783
614784 if ((flags & CIFS_HAS_CREDITS) == 0) {
615
- rc = wait_for_free_request(server, timeout, optype);
785
+ rc = wait_for_free_request(server, flags, &instance);
616786 if (rc)
617787 return rc;
618
- credits = 1;
619
- }
788
+ credits.value = 1;
789
+ credits.instance = instance;
790
+ } else
791
+ instance = exist_credits->instance;
620792
621793 mutex_lock(&server->srv_mutex);
794
+
795
+ /*
796
+ * We can't use credits obtained from the previous session to send this
797
+ * request. Check if there were reconnects after we obtained credits and
798
+ * return -EAGAIN in such cases to let callers handle it.
799
+ */
800
+ if (instance != server->reconnect_instance) {
801
+ mutex_unlock(&server->srv_mutex);
802
+ add_credits_and_wake_if(server, &credits, optype);
803
+ return -EAGAIN;
804
+ }
805
+
622806 mid = server->ops->setup_async_request(server, rqst);
623807 if (IS_ERR(mid)) {
624808 mutex_unlock(&server->srv_mutex);
625
- add_credits_and_wake_if(server, credits, optype);
809
+ add_credits_and_wake_if(server, &credits, optype);
626810 return PTR_ERR(mid);
627811 }
628812
....@@ -657,7 +841,7 @@
657841 if (rc == 0)
658842 return 0;
659843
660
- add_credits_and_wake_if(server, credits, optype);
844
+ add_credits_and_wake_if(server, &credits, optype);
661845 return rc;
662846 }
663847
....@@ -681,7 +865,7 @@
681865
682866 iov[0].iov_base = in_buf;
683867 iov[0].iov_len = get_rfc1002_length(in_buf) + 4;
684
- flags |= CIFS_NO_RESP;
868
+ flags |= CIFS_NO_RSP_BUF;
685869 rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov);
686870 cifs_dbg(NOISY, "SendRcvNoRsp flags %d rc %d\n", flags, rc);
687871
....@@ -711,8 +895,11 @@
711895 rc = -EHOSTDOWN;
712896 break;
713897 default:
714
- list_del_init(&mid->qhead);
715
- cifs_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n",
898
+ if (!(mid->mid_flags & MID_DELETED)) {
899
+ list_del_init(&mid->qhead);
900
+ mid->mid_flags |= MID_DELETED;
901
+ }
902
+ cifs_server_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n",
716903 __func__, mid->mid, mid->mid_state);
717904 rc = -EIO;
718905 }
....@@ -753,16 +940,17 @@
753940 rc = cifs_verify_signature(&rqst, server,
754941 mid->sequence_number);
755942 if (rc)
756
- cifs_dbg(VFS, "SMB signature verification returned error = %d\n",
943
+ cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
757944 rc);
758945 }
759946
760947 /* BB special case reconnect tid and uid here? */
761
- return map_smb_to_linux_error(mid->resp_buf, log_error);
948
+ return map_and_check_smb_error(mid, log_error);
762949 }
763950
764951 struct mid_q_entry *
765
-cifs_setup_request(struct cifs_ses *ses, struct smb_rqst *rqst)
952
+cifs_setup_request(struct cifs_ses *ses, struct TCP_Server_Info *ignored,
953
+ struct smb_rqst *rqst)
766954 {
767955 int rc;
768956 struct smb_hdr *hdr = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
....@@ -784,61 +972,101 @@
784972 }
785973
786974 static void
787
-cifs_noop_callback(struct mid_q_entry *mid)
975
+cifs_compound_callback(struct mid_q_entry *mid)
788976 {
977
+ struct TCP_Server_Info *server = mid->server;
978
+ struct cifs_credits credits;
979
+
980
+ credits.value = server->ops->get_credits(mid);
981
+ credits.instance = server->reconnect_instance;
982
+
983
+ add_credits(server, &credits, mid->optype);
984
+}
985
+
986
+static void
987
+cifs_compound_last_callback(struct mid_q_entry *mid)
988
+{
989
+ cifs_compound_callback(mid);
990
+ cifs_wake_up_task(mid);
991
+}
992
+
993
+static void
994
+cifs_cancelled_callback(struct mid_q_entry *mid)
995
+{
996
+ cifs_compound_callback(mid);
997
+ DeleteMidQEntry(mid);
998
+}
999
+
1000
+/*
1001
+ * Return a channel (master if none) of @ses that can be used to send
1002
+ * regular requests.
1003
+ *
1004
+ * If we are currently binding a new channel (negprot/sess.setup),
1005
+ * return the new incomplete channel.
1006
+ */
1007
+struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses)
1008
+{
1009
+ uint index = 0;
1010
+
1011
+ if (!ses)
1012
+ return NULL;
1013
+
1014
+ if (!ses->binding) {
1015
+ /* round robin */
1016
+ if (ses->chan_count > 1) {
1017
+ index = (uint)atomic_inc_return(&ses->chan_seq);
1018
+ index %= ses->chan_count;
1019
+ }
1020
+ return ses->chans[index].server;
1021
+ } else {
1022
+ return cifs_ses_server(ses);
1023
+ }
7891024 }
7901025
7911026 int
7921027 compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
1028
+ struct TCP_Server_Info *server,
7931029 const int flags, const int num_rqst, struct smb_rqst *rqst,
7941030 int *resp_buf_type, struct kvec *resp_iov)
7951031 {
796
- int i, j, rc = 0;
797
- int timeout, optype;
1032
+ int i, j, optype, rc = 0;
7981033 struct mid_q_entry *midQ[MAX_COMPOUND];
7991034 bool cancelled_mid[MAX_COMPOUND] = {false};
800
- unsigned int credits[MAX_COMPOUND] = {0};
1035
+ struct cifs_credits credits[MAX_COMPOUND] = {
1036
+ { .value = 0, .instance = 0 }
1037
+ };
1038
+ unsigned int instance;
8011039 char *buf;
8021040
803
- timeout = flags & CIFS_TIMEOUT_MASK;
8041041 optype = flags & CIFS_OP_MASK;
8051042
8061043 for (i = 0; i < num_rqst; i++)
8071044 resp_buf_type[i] = CIFS_NO_BUFFER; /* no response buf yet */
8081045
809
- if ((ses == NULL) || (ses->server == NULL)) {
1046
+ if (!ses || !ses->server || !server) {
8101047 cifs_dbg(VFS, "Null session\n");
8111048 return -EIO;
8121049 }
8131050
814
- if (ses->server->tcpStatus == CifsExiting)
1051
+ if (server->tcpStatus == CifsExiting)
8151052 return -ENOENT;
8161053
8171054 /*
818
- * Ensure we obtain 1 credit per request in the compound chain.
819
- * It can be optimized further by waiting for all the credits
820
- * at once but this can wait long enough if we don't have enough
821
- * credits due to some heavy operations in progress or the server
822
- * not granting us much, so a fallback to the current approach is
823
- * needed anyway.
1055
+ * Wait for all the requests to become available.
1056
+ * This approach still leaves the possibility to be stuck waiting for
1057
+ * credits if the server doesn't grant credits to the outstanding
1058
+ * requests and if the client is completely idle, not generating any
1059
+ * other requests.
1060
+ * This can be handled by the eventual session reconnect.
8241061 */
1062
+ rc = wait_for_compound_request(server, num_rqst, flags,
1063
+ &instance);
1064
+ if (rc)
1065
+ return rc;
1066
+
8251067 for (i = 0; i < num_rqst; i++) {
826
- rc = wait_for_free_request(ses->server, timeout, optype);
827
- if (rc) {
828
- /*
829
- * We haven't sent an SMB packet to the server yet but
830
- * we already obtained credits for i requests in the
831
- * compound chain - need to return those credits back
832
- * for future use. Note that we need to call add_credits
833
- * multiple times to match the way we obtained credits
834
- * in the first place and to account for in flight
835
- * requests correctly.
836
- */
837
- for (j = 0; j < i; j++)
838
- add_credits(ses->server, 1, optype);
839
- return rc;
840
- }
841
- credits[i] = 1;
1068
+ credits[i].value = 1;
1069
+ credits[i].instance = instance;
8421070 }
8431071
8441072 /*
....@@ -847,86 +1075,116 @@
8471075 * of smb data.
8481076 */
8491077
850
- mutex_lock(&ses->server->srv_mutex);
1078
+ mutex_lock(&server->srv_mutex);
1079
+
1080
+ /*
1081
+ * All the parts of the compound chain belong obtained credits from the
1082
+ * same session. We can not use credits obtained from the previous
1083
+ * session to send this request. Check if there were reconnects after
1084
+ * we obtained credits and return -EAGAIN in such cases to let callers
1085
+ * handle it.
1086
+ */
1087
+ if (instance != server->reconnect_instance) {
1088
+ mutex_unlock(&server->srv_mutex);
1089
+ for (j = 0; j < num_rqst; j++)
1090
+ add_credits(server, &credits[j], optype);
1091
+ return -EAGAIN;
1092
+ }
8511093
8521094 for (i = 0; i < num_rqst; i++) {
853
- midQ[i] = ses->server->ops->setup_request(ses, &rqst[i]);
1095
+ midQ[i] = server->ops->setup_request(ses, server, &rqst[i]);
8541096 if (IS_ERR(midQ[i])) {
855
- revert_current_mid(ses->server, i);
1097
+ revert_current_mid(server, i);
8561098 for (j = 0; j < i; j++)
8571099 cifs_delete_mid(midQ[j]);
858
- mutex_unlock(&ses->server->srv_mutex);
1100
+ mutex_unlock(&server->srv_mutex);
8591101
8601102 /* Update # of requests on wire to server */
8611103 for (j = 0; j < num_rqst; j++)
862
- add_credits(ses->server, credits[j], optype);
1104
+ add_credits(server, &credits[j], optype);
8631105 return PTR_ERR(midQ[i]);
8641106 }
8651107
8661108 midQ[i]->mid_state = MID_REQUEST_SUBMITTED;
1109
+ midQ[i]->optype = optype;
8671110 /*
868
- * We don't invoke the callback compounds unless it is the last
869
- * request.
1111
+ * Invoke callback for every part of the compound chain
1112
+ * to calculate credits properly. Wake up this thread only when
1113
+ * the last element is received.
8701114 */
8711115 if (i < num_rqst - 1)
872
- midQ[i]->callback = cifs_noop_callback;
1116
+ midQ[i]->callback = cifs_compound_callback;
1117
+ else
1118
+ midQ[i]->callback = cifs_compound_last_callback;
8731119 }
874
- cifs_in_send_inc(ses->server);
875
- rc = smb_send_rqst(ses->server, num_rqst, rqst, flags);
876
- cifs_in_send_dec(ses->server);
1120
+ cifs_in_send_inc(server);
1121
+ rc = smb_send_rqst(server, num_rqst, rqst, flags);
1122
+ cifs_in_send_dec(server);
8771123
8781124 for (i = 0; i < num_rqst; i++)
8791125 cifs_save_when_sent(midQ[i]);
8801126
8811127 if (rc < 0) {
882
- revert_current_mid(ses->server, num_rqst);
883
- ses->server->sequence_number -= 2;
1128
+ revert_current_mid(server, num_rqst);
1129
+ server->sequence_number -= 2;
8841130 }
8851131
886
- mutex_unlock(&ses->server->srv_mutex);
1132
+ mutex_unlock(&server->srv_mutex);
8871133
888
- if (rc < 0)
1134
+ /*
1135
+ * If sending failed for some reason or it is an oplock break that we
1136
+ * will not receive a response to - return credits back
1137
+ */
1138
+ if (rc < 0 || (flags & CIFS_NO_SRV_RSP)) {
1139
+ for (i = 0; i < num_rqst; i++)
1140
+ add_credits(server, &credits[i], optype);
8891141 goto out;
1142
+ }
1143
+
1144
+ /*
1145
+ * At this point the request is passed to the network stack - we assume
1146
+ * that any credits taken from the server structure on the client have
1147
+ * been spent and we can't return them back. Once we receive responses
1148
+ * we will collect credits granted by the server in the mid callbacks
1149
+ * and add those credits to the server structure.
1150
+ */
8901151
8911152 /*
8921153 * Compounding is never used during session establish.
8931154 */
8941155 if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP)) {
895
- mutex_lock(&ses->server->srv_mutex);
1156
+ mutex_lock(&server->srv_mutex);
8961157 smb311_update_preauth_hash(ses, rqst[0].rq_iov,
8971158 rqst[0].rq_nvec);
898
- mutex_unlock(&ses->server->srv_mutex);
1159
+ mutex_unlock(&server->srv_mutex);
8991160 }
9001161
901
- if (timeout == CIFS_ASYNC_OP)
902
- goto out;
903
-
9041162 for (i = 0; i < num_rqst; i++) {
905
- rc = wait_for_response(ses->server, midQ[i]);
906
- if (rc != 0) {
907
- cifs_dbg(FYI, "Cancelling wait for mid %llu\n",
908
- midQ[i]->mid);
909
- send_cancel(ses->server, &rqst[i], midQ[i]);
1163
+ rc = wait_for_response(server, midQ[i]);
1164
+ if (rc != 0)
1165
+ break;
1166
+ }
1167
+ if (rc != 0) {
1168
+ for (; i < num_rqst; i++) {
1169
+ cifs_server_dbg(FYI, "Cancelling wait for mid %llu cmd: %d\n",
1170
+ midQ[i]->mid, le16_to_cpu(midQ[i]->command));
1171
+ send_cancel(server, &rqst[i], midQ[i]);
9101172 spin_lock(&GlobalMid_Lock);
1173
+ midQ[i]->mid_flags |= MID_WAIT_CANCELLED;
9111174 if (midQ[i]->mid_state == MID_REQUEST_SUBMITTED) {
912
- midQ[i]->mid_flags |= MID_WAIT_CANCELLED;
913
- midQ[i]->callback = DeleteMidQEntry;
1175
+ midQ[i]->callback = cifs_cancelled_callback;
9141176 cancelled_mid[i] = true;
1177
+ credits[i].value = 0;
9151178 }
9161179 spin_unlock(&GlobalMid_Lock);
9171180 }
9181181 }
9191182
920
- for (i = 0; i < num_rqst; i++)
921
- if (!cancelled_mid[i] && midQ[i]->resp_buf
922
- && (midQ[i]->mid_state == MID_RESPONSE_RECEIVED))
923
- credits[i] = ses->server->ops->get_credits(midQ[i]);
924
-
9251183 for (i = 0; i < num_rqst; i++) {
9261184 if (rc < 0)
9271185 goto out;
9281186
929
- rc = cifs_sync_mid_result(midQ[i], ses->server);
1187
+ rc = cifs_sync_mid_result(midQ[i], server);
9301188 if (rc != 0) {
9311189 /* mark this mid as cancelled to not free it below */
9321190 cancelled_mid[i] = true;
....@@ -943,18 +1201,18 @@
9431201 buf = (char *)midQ[i]->resp_buf;
9441202 resp_iov[i].iov_base = buf;
9451203 resp_iov[i].iov_len = midQ[i]->resp_buf_size +
946
- ses->server->vals->header_preamble_size;
1204
+ server->vals->header_preamble_size;
9471205
9481206 if (midQ[i]->large_buf)
9491207 resp_buf_type[i] = CIFS_LARGE_BUFFER;
9501208 else
9511209 resp_buf_type[i] = CIFS_SMALL_BUFFER;
9521210
953
- rc = ses->server->ops->check_receive(midQ[i], ses->server,
1211
+ rc = server->ops->check_receive(midQ[i], server,
9541212 flags & CIFS_LOG_ERROR);
9551213
9561214 /* mark it so buf will not be freed by cifs_delete_mid */
957
- if ((flags & CIFS_NO_RESP) == 0)
1215
+ if ((flags & CIFS_NO_RSP_BUF) == 0)
9581216 midQ[i]->resp_buf = NULL;
9591217
9601218 }
....@@ -967,9 +1225,9 @@
9671225 .iov_base = resp_iov[0].iov_base,
9681226 .iov_len = resp_iov[0].iov_len
9691227 };
970
- mutex_lock(&ses->server->srv_mutex);
1228
+ mutex_lock(&server->srv_mutex);
9711229 smb311_update_preauth_hash(ses, &iov, 1);
972
- mutex_unlock(&ses->server->srv_mutex);
1230
+ mutex_unlock(&server->srv_mutex);
9731231 }
9741232
9751233 out:
....@@ -982,7 +1240,6 @@
9821240 for (i = 0; i < num_rqst; i++) {
9831241 if (!cancelled_mid[i])
9841242 cifs_delete_mid(midQ[i]);
985
- add_credits(ses->server, credits[i], optype);
9861243 }
9871244
9881245 return rc;
....@@ -990,11 +1247,12 @@
9901247
9911248 int
9921249 cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
1250
+ struct TCP_Server_Info *server,
9931251 struct smb_rqst *rqst, int *resp_buf_type, const int flags,
9941252 struct kvec *resp_iov)
9951253 {
996
- return compound_send_recv(xid, ses, flags, 1, rqst, resp_buf_type,
997
- resp_iov);
1254
+ return compound_send_recv(xid, ses, server, flags, 1,
1255
+ rqst, resp_buf_type, resp_iov);
9981256 }
9991257
10001258 int
....@@ -1029,7 +1287,8 @@
10291287 rqst.rq_iov = new_iov;
10301288 rqst.rq_nvec = n_vec + 1;
10311289
1032
- rc = cifs_send_recv(xid, ses, &rqst, resp_buf_type, flags, resp_iov);
1290
+ rc = cifs_send_recv(xid, ses, ses->server,
1291
+ &rqst, resp_buf_type, flags, resp_iov);
10331292 if (n_vec + 1 > CIFS_MAX_IOV_SIZE)
10341293 kfree(new_iov);
10351294 return rc;
....@@ -1038,24 +1297,27 @@
10381297 int
10391298 SendReceive(const unsigned int xid, struct cifs_ses *ses,
10401299 struct smb_hdr *in_buf, struct smb_hdr *out_buf,
1041
- int *pbytes_returned, const int timeout)
1300
+ int *pbytes_returned, const int flags)
10421301 {
10431302 int rc = 0;
10441303 struct mid_q_entry *midQ;
10451304 unsigned int len = be32_to_cpu(in_buf->smb_buf_length);
10461305 struct kvec iov = { .iov_base = in_buf, .iov_len = len };
10471306 struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
1307
+ struct cifs_credits credits = { .value = 1, .instance = 0 };
1308
+ struct TCP_Server_Info *server;
10481309
10491310 if (ses == NULL) {
10501311 cifs_dbg(VFS, "Null smb session\n");
10511312 return -EIO;
10521313 }
1053
- if (ses->server == NULL) {
1314
+ server = ses->server;
1315
+ if (server == NULL) {
10541316 cifs_dbg(VFS, "Null tcp session\n");
10551317 return -EIO;
10561318 }
10571319
1058
- if (ses->server->tcpStatus == CifsExiting)
1320
+ if (server->tcpStatus == CifsExiting)
10591321 return -ENOENT;
10601322
10611323 /* Ensure that we do not send more than 50 overlapping requests
....@@ -1063,12 +1325,12 @@
10631325 use ses->maxReq */
10641326
10651327 if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
1066
- cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
1067
- len);
1328
+ cifs_server_dbg(VFS, "Invalid length, greater than maximum frame, %d\n",
1329
+ len);
10681330 return -EIO;
10691331 }
10701332
1071
- rc = wait_for_free_request(ses->server, timeout, 0);
1333
+ rc = wait_for_free_request(server, flags, &credits.instance);
10721334 if (rc)
10731335 return rc;
10741336
....@@ -1076,73 +1338,70 @@
10761338 and avoid races inside tcp sendmsg code that could cause corruption
10771339 of smb data */
10781340
1079
- mutex_lock(&ses->server->srv_mutex);
1341
+ mutex_lock(&server->srv_mutex);
10801342
10811343 rc = allocate_mid(ses, in_buf, &midQ);
10821344 if (rc) {
1083
- mutex_unlock(&ses->server->srv_mutex);
1345
+ mutex_unlock(&server->srv_mutex);
10841346 /* Update # of requests on wire to server */
1085
- add_credits(ses->server, 1, 0);
1347
+ add_credits(server, &credits, 0);
10861348 return rc;
10871349 }
10881350
1089
- rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number);
1351
+ rc = cifs_sign_smb(in_buf, server, &midQ->sequence_number);
10901352 if (rc) {
1091
- mutex_unlock(&ses->server->srv_mutex);
1353
+ mutex_unlock(&server->srv_mutex);
10921354 goto out;
10931355 }
10941356
10951357 midQ->mid_state = MID_REQUEST_SUBMITTED;
10961358
1097
- cifs_in_send_inc(ses->server);
1098
- rc = smb_send(ses->server, in_buf, len);
1099
- cifs_in_send_dec(ses->server);
1359
+ cifs_in_send_inc(server);
1360
+ rc = smb_send(server, in_buf, len);
1361
+ cifs_in_send_dec(server);
11001362 cifs_save_when_sent(midQ);
11011363
11021364 if (rc < 0)
1103
- ses->server->sequence_number -= 2;
1365
+ server->sequence_number -= 2;
11041366
1105
- mutex_unlock(&ses->server->srv_mutex);
1367
+ mutex_unlock(&server->srv_mutex);
11061368
11071369 if (rc < 0)
11081370 goto out;
11091371
1110
- if (timeout == CIFS_ASYNC_OP)
1111
- goto out;
1112
-
1113
- rc = wait_for_response(ses->server, midQ);
1372
+ rc = wait_for_response(server, midQ);
11141373 if (rc != 0) {
1115
- send_cancel(ses->server, &rqst, midQ);
1374
+ send_cancel(server, &rqst, midQ);
11161375 spin_lock(&GlobalMid_Lock);
11171376 if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
11181377 /* no longer considered to be "in-flight" */
11191378 midQ->callback = DeleteMidQEntry;
11201379 spin_unlock(&GlobalMid_Lock);
1121
- add_credits(ses->server, 1, 0);
1380
+ add_credits(server, &credits, 0);
11221381 return rc;
11231382 }
11241383 spin_unlock(&GlobalMid_Lock);
11251384 }
11261385
1127
- rc = cifs_sync_mid_result(midQ, ses->server);
1386
+ rc = cifs_sync_mid_result(midQ, server);
11281387 if (rc != 0) {
1129
- add_credits(ses->server, 1, 0);
1388
+ add_credits(server, &credits, 0);
11301389 return rc;
11311390 }
11321391
11331392 if (!midQ->resp_buf || !out_buf ||
11341393 midQ->mid_state != MID_RESPONSE_RECEIVED) {
11351394 rc = -EIO;
1136
- cifs_dbg(VFS, "Bad MID state?\n");
1395
+ cifs_server_dbg(VFS, "Bad MID state?\n");
11371396 goto out;
11381397 }
11391398
11401399 *pbytes_returned = get_rfc1002_length(midQ->resp_buf);
11411400 memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4);
1142
- rc = cifs_check_receive(midQ, ses->server, 0);
1401
+ rc = cifs_check_receive(midQ, server, 0);
11431402 out:
11441403 cifs_delete_mid(midQ);
1145
- add_credits(ses->server, 1, 0);
1404
+ add_credits(server, &credits, 0);
11461405
11471406 return rc;
11481407 }
....@@ -1184,19 +1443,22 @@
11841443 unsigned int len = be32_to_cpu(in_buf->smb_buf_length);
11851444 struct kvec iov = { .iov_base = in_buf, .iov_len = len };
11861445 struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
1446
+ unsigned int instance;
1447
+ struct TCP_Server_Info *server;
11871448
11881449 if (tcon == NULL || tcon->ses == NULL) {
11891450 cifs_dbg(VFS, "Null smb session\n");
11901451 return -EIO;
11911452 }
11921453 ses = tcon->ses;
1454
+ server = ses->server;
11931455
1194
- if (ses->server == NULL) {
1456
+ if (server == NULL) {
11951457 cifs_dbg(VFS, "Null tcp session\n");
11961458 return -EIO;
11971459 }
11981460
1199
- if (ses->server->tcpStatus == CifsExiting)
1461
+ if (server->tcpStatus == CifsExiting)
12001462 return -ENOENT;
12011463
12021464 /* Ensure that we do not send more than 50 overlapping requests
....@@ -1204,12 +1466,12 @@
12041466 use ses->maxReq */
12051467
12061468 if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
1207
- cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
1208
- len);
1469
+ cifs_tcon_dbg(VFS, "Invalid length, greater than maximum frame, %d\n",
1470
+ len);
12091471 return -EIO;
12101472 }
12111473
1212
- rc = wait_for_free_request(ses->server, CIFS_BLOCKING_OP, 0);
1474
+ rc = wait_for_free_request(server, CIFS_BLOCKING_OP, &instance);
12131475 if (rc)
12141476 return rc;
12151477
....@@ -1217,31 +1479,31 @@
12171479 and avoid races inside tcp sendmsg code that could cause corruption
12181480 of smb data */
12191481
1220
- mutex_lock(&ses->server->srv_mutex);
1482
+ mutex_lock(&server->srv_mutex);
12211483
12221484 rc = allocate_mid(ses, in_buf, &midQ);
12231485 if (rc) {
1224
- mutex_unlock(&ses->server->srv_mutex);
1486
+ mutex_unlock(&server->srv_mutex);
12251487 return rc;
12261488 }
12271489
1228
- rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number);
1490
+ rc = cifs_sign_smb(in_buf, server, &midQ->sequence_number);
12291491 if (rc) {
12301492 cifs_delete_mid(midQ);
1231
- mutex_unlock(&ses->server->srv_mutex);
1493
+ mutex_unlock(&server->srv_mutex);
12321494 return rc;
12331495 }
12341496
12351497 midQ->mid_state = MID_REQUEST_SUBMITTED;
1236
- cifs_in_send_inc(ses->server);
1237
- rc = smb_send(ses->server, in_buf, len);
1238
- cifs_in_send_dec(ses->server);
1498
+ cifs_in_send_inc(server);
1499
+ rc = smb_send(server, in_buf, len);
1500
+ cifs_in_send_dec(server);
12391501 cifs_save_when_sent(midQ);
12401502
12411503 if (rc < 0)
1242
- ses->server->sequence_number -= 2;
1504
+ server->sequence_number -= 2;
12431505
1244
- mutex_unlock(&ses->server->srv_mutex);
1506
+ mutex_unlock(&server->srv_mutex);
12451507
12461508 if (rc < 0) {
12471509 cifs_delete_mid(midQ);
....@@ -1249,21 +1511,21 @@
12491511 }
12501512
12511513 /* Wait for a reply - allow signals to interrupt. */
1252
- rc = wait_event_interruptible(ses->server->response_q,
1514
+ rc = wait_event_interruptible(server->response_q,
12531515 (!(midQ->mid_state == MID_REQUEST_SUBMITTED)) ||
1254
- ((ses->server->tcpStatus != CifsGood) &&
1255
- (ses->server->tcpStatus != CifsNew)));
1516
+ ((server->tcpStatus != CifsGood) &&
1517
+ (server->tcpStatus != CifsNew)));
12561518
12571519 /* Were we interrupted by a signal ? */
12581520 if ((rc == -ERESTARTSYS) &&
12591521 (midQ->mid_state == MID_REQUEST_SUBMITTED) &&
1260
- ((ses->server->tcpStatus == CifsGood) ||
1261
- (ses->server->tcpStatus == CifsNew))) {
1522
+ ((server->tcpStatus == CifsGood) ||
1523
+ (server->tcpStatus == CifsNew))) {
12621524
12631525 if (in_buf->Command == SMB_COM_TRANSACTION2) {
12641526 /* POSIX lock. We send a NT_CANCEL SMB to cause the
12651527 blocking lock to return. */
1266
- rc = send_cancel(ses->server, &rqst, midQ);
1528
+ rc = send_cancel(server, &rqst, midQ);
12671529 if (rc) {
12681530 cifs_delete_mid(midQ);
12691531 return rc;
....@@ -1282,9 +1544,9 @@
12821544 }
12831545 }
12841546
1285
- rc = wait_for_response(ses->server, midQ);
1547
+ rc = wait_for_response(server, midQ);
12861548 if (rc) {
1287
- send_cancel(ses->server, &rqst, midQ);
1549
+ send_cancel(server, &rqst, midQ);
12881550 spin_lock(&GlobalMid_Lock);
12891551 if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
12901552 /* no longer considered to be "in-flight" */
....@@ -1299,20 +1561,20 @@
12991561 rstart = 1;
13001562 }
13011563
1302
- rc = cifs_sync_mid_result(midQ, ses->server);
1564
+ rc = cifs_sync_mid_result(midQ, server);
13031565 if (rc != 0)
13041566 return rc;
13051567
13061568 /* rcvd frame is ok */
13071569 if (out_buf == NULL || midQ->mid_state != MID_RESPONSE_RECEIVED) {
13081570 rc = -EIO;
1309
- cifs_dbg(VFS, "Bad MID state?\n");
1571
+ cifs_tcon_dbg(VFS, "Bad MID state?\n");
13101572 goto out;
13111573 }
13121574
13131575 *pbytes_returned = get_rfc1002_length(midQ->resp_buf);
13141576 memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4);
1315
- rc = cifs_check_receive(midQ, ses->server, 0);
1577
+ rc = cifs_check_receive(midQ, server, 0);
13161578 out:
13171579 cifs_delete_mid(midQ);
13181580 if (rstart && rc == -EACCES)