4 * Copyright (C) International Business Machines Corp., 2002,2005
5 * Author(s): Steve French (sfrench@us.ibm.com)
6 * Jeremy Allison (jra@samba.org) 2006.
8 * This library is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published
10 * by the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
16 * the GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <linux/list.h>
25 #include <linux/wait.h>
26 #include <linux/net.h>
27 #include <linux/delay.h>
28 #include <asm/uaccess.h>
29 #include <asm/processor.h>
30 #include <linux/mempool.h>
33 #include "cifsproto.h"
34 #include "cifs_debug.h"
36 extern mempool_t *cifs_mid_poolp;
37 extern kmem_cache_t *cifs_oplock_cachep;
39 static struct mid_q_entry *
40 AllocMidQEntry(struct smb_hdr *smb_buffer, struct cifsSesInfo *ses)
42 struct mid_q_entry *temp;
45 cERROR(1, ("Null session passed in to AllocMidQEntry"));
48 if (ses->server == NULL) {
49 cERROR(1, ("Null TCP session in AllocMidQEntry"));
53 temp = (struct mid_q_entry *) mempool_alloc(cifs_mid_poolp,
54 SLAB_KERNEL | SLAB_NOFS);
58 memset(temp, 0, sizeof (struct mid_q_entry));
59 temp->mid = smb_buffer->Mid; /* always LE */
60 temp->pid = current->pid;
61 temp->command = smb_buffer->Command;
62 cFYI(1, ("For smb_command %d", temp->command));
63 /* do_gettimeofday(&temp->when_sent);*/ /* easier to use jiffies */
64 /* when mid allocated can be before when sent */
65 temp->when_alloc = jiffies;
70 spin_lock(&GlobalMid_Lock);
71 list_add_tail(&temp->qhead, &ses->server->pending_mid_q);
72 atomic_inc(&midCount);
73 temp->midState = MID_REQUEST_ALLOCATED;
74 spin_unlock(&GlobalMid_Lock);
79 DeleteMidQEntry(struct mid_q_entry *midEntry)
81 #ifdef CONFIG_CIFS_STATS2
84 spin_lock(&GlobalMid_Lock);
85 midEntry->midState = MID_FREE;
86 list_del(&midEntry->qhead);
87 atomic_dec(&midCount);
88 spin_unlock(&GlobalMid_Lock);
89 if(midEntry->largeBuf)
90 cifs_buf_release(midEntry->resp_buf);
92 cifs_small_buf_release(midEntry->resp_buf);
93 #ifdef CONFIG_CIFS_STATS2
95 /* commands taking longer than one second are indications that
96 something is wrong, unless it is quite a slow link or server */
97 if((now - midEntry->when_alloc) > HZ) {
98 if((cifsFYI & CIFS_TIMER) &&
99 (midEntry->command != SMB_COM_LOCKING_ANDX)) {
100 printk(KERN_DEBUG " CIFS slow rsp: cmd %d mid %d",
101 midEntry->command, midEntry->mid);
102 printk(" A: 0x%lx S: 0x%lx R: 0x%lx\n",
103 now - midEntry->when_alloc,
104 now - midEntry->when_sent,
105 now - midEntry->when_received);
109 mempool_free(midEntry, cifs_mid_poolp);
112 struct oplock_q_entry *
113 AllocOplockQEntry(struct inode * pinode, __u16 fid, struct cifsTconInfo * tcon)
115 struct oplock_q_entry *temp;
116 if ((pinode== NULL) || (tcon == NULL)) {
117 cERROR(1, ("Null parms passed to AllocOplockQEntry"));
120 temp = (struct oplock_q_entry *) kmem_cache_alloc(cifs_oplock_cachep,
125 temp->pinode = pinode;
128 spin_lock(&GlobalMid_Lock);
129 list_add_tail(&temp->qhead, &GlobalOplock_Q);
130 spin_unlock(&GlobalMid_Lock);
136 void DeleteOplockQEntry(struct oplock_q_entry * oplockEntry)
138 spin_lock(&GlobalMid_Lock);
139 /* should we check if list empty first? */
140 list_del(&oplockEntry->qhead);
141 spin_unlock(&GlobalMid_Lock);
142 kmem_cache_free(cifs_oplock_cachep, oplockEntry);
146 smb_send(struct socket *ssocket, struct smb_hdr *smb_buffer,
147 unsigned int smb_buf_length, struct sockaddr *sin)
151 struct msghdr smb_msg;
153 unsigned len = smb_buf_length + 4;
156 return -ENOTSOCK; /* BB eventually add reconnect code here */
157 iov.iov_base = smb_buffer;
160 smb_msg.msg_name = sin;
161 smb_msg.msg_namelen = sizeof (struct sockaddr);
162 smb_msg.msg_control = NULL;
163 smb_msg.msg_controllen = 0;
164 smb_msg.msg_flags = MSG_DONTWAIT + MSG_NOSIGNAL; /* BB add more flags?*/
166 /* smb header is converted in header_assemble. bcc and rest of SMB word
167 area, and byte area if necessary, is converted to littleendian in
168 cifssmb.c and RFC1001 len is converted to bigendian in smb_send
169 Flags2 is converted in SendReceive */
171 smb_buffer->smb_buf_length = cpu_to_be32(smb_buffer->smb_buf_length);
172 cFYI(1, ("Sending smb of length %d", smb_buf_length));
173 dump_smb(smb_buffer, len);
176 rc = kernel_sendmsg(ssocket, &smb_msg, &iov, 1, len);
177 if ((rc == -ENOSPC) || (rc == -EAGAIN)) {
179 /* smaller timeout here than send2 since smaller size */
180 /* Although it may not be required, this also is smaller
184 ("sends on sock %p stuck for 7 seconds",
195 i = 0; /* reset i after each successful send */
202 cERROR(1,("Error %d sending data on socket to server", rc));
211 smb_send2(struct socket *ssocket, struct kvec *iov, int n_vec,
212 struct sockaddr *sin)
216 struct msghdr smb_msg;
217 struct smb_hdr *smb_buffer = iov[0].iov_base;
218 unsigned int len = iov[0].iov_len;
219 unsigned int total_len;
223 return -ENOTSOCK; /* BB eventually add reconnect code here */
225 smb_msg.msg_name = sin;
226 smb_msg.msg_namelen = sizeof (struct sockaddr);
227 smb_msg.msg_control = NULL;
228 smb_msg.msg_controllen = 0;
229 smb_msg.msg_flags = MSG_DONTWAIT + MSG_NOSIGNAL; /* BB add more flags?*/
231 /* smb header is converted in header_assemble. bcc and rest of SMB word
232 area, and byte area if necessary, is converted to littleendian in
233 cifssmb.c and RFC1001 len is converted to bigendian in smb_send
234 Flags2 is converted in SendReceive */
238 for (i = 0; i < n_vec; i++)
239 total_len += iov[i].iov_len;
241 smb_buffer->smb_buf_length = cpu_to_be32(smb_buffer->smb_buf_length);
242 cFYI(1, ("Sending smb: total_len %d", total_len));
243 dump_smb(smb_buffer, len);
246 rc = kernel_sendmsg(ssocket, &smb_msg, &iov[first_vec],
247 n_vec - first_vec, total_len);
248 if ((rc == -ENOSPC) || (rc == -EAGAIN)) {
252 ("sends on sock %p stuck for 15 seconds",
263 if (rc >= total_len) {
264 WARN_ON(rc > total_len);
268 /* should never happen, letting socket clear before
269 retrying is our only obvious option here */
270 cERROR(1,("tcp sent no data"));
275 /* the line below resets i */
276 for (i = first_vec; i < n_vec; i++) {
277 if (iov[i].iov_len) {
278 if (rc > iov[i].iov_len) {
279 rc -= iov[i].iov_len;
282 iov[i].iov_base += rc;
283 iov[i].iov_len -= rc;
289 i = 0; /* in case we get ENOSPC on the next send */
293 cERROR(1,("Error %d sending data on socket to server", rc));
301 SendReceive2(const unsigned int xid, struct cifsSesInfo *ses,
302 struct kvec *iov, int n_vec, int * pRespBufType /* ret */,
306 unsigned int receive_len;
307 unsigned long timeout;
308 struct mid_q_entry *midQ;
309 struct smb_hdr *in_buf = iov[0].iov_base;
311 *pRespBufType = CIFS_NO_BUFFER; /* no response buf yet */
313 if ((ses == NULL) || (ses->server == NULL)) {
314 cifs_small_buf_release(in_buf);
315 cERROR(1,("Null session"));
319 if(ses->server->tcpStatus == CifsExiting) {
320 cifs_small_buf_release(in_buf);
324 /* Ensure that we do not send more than 50 overlapping requests
325 to the same server. We may make this configurable later or
328 /* oplock breaks must not be held up */
329 atomic_inc(&ses->server->inFlight);
331 spin_lock(&GlobalMid_Lock);
333 if(atomic_read(&ses->server->inFlight) >=
335 spin_unlock(&GlobalMid_Lock);
336 #ifdef CONFIG_CIFS_STATS2
337 atomic_inc(&ses->server->num_waiters);
339 wait_event(ses->server->request_q,
340 atomic_read(&ses->server->inFlight)
342 #ifdef CONFIG_CIFS_STATS2
343 atomic_dec(&ses->server->num_waiters);
345 spin_lock(&GlobalMid_Lock);
347 if(ses->server->tcpStatus == CifsExiting) {
348 spin_unlock(&GlobalMid_Lock);
349 cifs_small_buf_release(in_buf);
353 /* can not count locking commands against total since
354 they are allowed to block on server */
357 /* update # of requests on the wire to server */
358 atomic_inc(&ses->server->inFlight);
360 spin_unlock(&GlobalMid_Lock);
365 /* make sure that we sign in the same order that we send on this socket
366 and avoid races inside tcp sendmsg code that could cause corruption
369 down(&ses->server->tcpSem);
371 if (ses->server->tcpStatus == CifsExiting) {
374 } else if (ses->server->tcpStatus == CifsNeedReconnect) {
375 cFYI(1,("tcp session dead - return to caller to retry"));
378 } else if (ses->status != CifsGood) {
379 /* check if SMB session is bad because we are setting it up */
380 if((in_buf->Command != SMB_COM_SESSION_SETUP_ANDX) &&
381 (in_buf->Command != SMB_COM_NEGOTIATE)) {
384 } /* else ok - we are setting up session */
386 midQ = AllocMidQEntry(in_buf, ses);
388 up(&ses->server->tcpSem);
389 cifs_small_buf_release(in_buf);
390 /* If not lock req, update # of requests on wire to server */
392 atomic_dec(&ses->server->inFlight);
393 wake_up(&ses->server->request_q);
398 rc = cifs_sign_smb2(iov, n_vec, ses->server, &midQ->sequence_number);
400 midQ->midState = MID_REQUEST_SUBMITTED;
401 #ifdef CONFIG_CIFS_STATS2
402 atomic_inc(&ses->server->inSend);
404 rc = smb_send2(ses->server->ssocket, iov, n_vec,
405 (struct sockaddr *) &(ses->server->addr.sockAddr));
406 #ifdef CONFIG_CIFS_STATS2
407 atomic_dec(&ses->server->inSend);
408 midQ->when_sent = jiffies;
411 DeleteMidQEntry(midQ);
412 up(&ses->server->tcpSem);
413 cifs_small_buf_release(in_buf);
414 /* If not lock req, update # of requests on wire to server */
416 atomic_dec(&ses->server->inFlight);
417 wake_up(&ses->server->request_q);
421 up(&ses->server->tcpSem);
422 cifs_small_buf_release(in_buf);
426 goto cifs_no_response_exit2;
427 else if (long_op == 2) /* writes past end of file can take loong time */
429 else if (long_op == 1)
430 timeout = 45 * HZ; /* should be greater than
431 servers oplock break timeout (about 43 seconds) */
432 else if (long_op > 2) {
433 timeout = MAX_SCHEDULE_TIMEOUT;
436 /* wait for 15 seconds or until woken up due to response arriving or
437 due to last connection to this server being unmounted */
438 if (signal_pending(current)) {
439 /* if signal pending do not hold up user for full smb timeout
440 but we still give response a change to complete */
444 /* No user interrupts in wait - wreaks havoc with performance */
445 if(timeout != MAX_SCHEDULE_TIMEOUT) {
446 unsigned long curr_timeout;
449 curr_timeout = timeout + jiffies;
450 wait_event(ses->server->response_q,
451 (!(midQ->midState & MID_REQUEST_SUBMITTED)) ||
452 time_after(jiffies, curr_timeout) ||
453 ((ses->server->tcpStatus != CifsGood) &&
454 (ses->server->tcpStatus != CifsNew)));
456 if (time_after(jiffies, curr_timeout) &&
457 (midQ->midState & MID_REQUEST_SUBMITTED) &&
458 ((ses->server->tcpStatus == CifsGood) ||
459 (ses->server->tcpStatus == CifsNew))) {
463 /* We timed out. Is the server still
465 spin_lock(&GlobalMid_Lock);
466 lrt = ses->server->lstrp;
467 spin_unlock(&GlobalMid_Lock);
469 /* Calculate 10 seconds past last receive time.
470 Although we prefer not to time out if the
471 server is still responding - we will time
472 out if the server takes more than 15 (or 45
473 or 180) seconds to respond to this request
474 and has not responded to any request from
475 other threads on the client within 10 seconds */
477 if (time_after(jiffies, lrt)) {
478 /* No replies for 10 seconds. */
479 cERROR(1,("server not responding"));
487 wait_event(ses->server->response_q,
488 (!(midQ->midState & MID_REQUEST_SUBMITTED)) ||
489 ((ses->server->tcpStatus != CifsGood) &&
490 (ses->server->tcpStatus != CifsNew)));
493 spin_lock(&GlobalMid_Lock);
494 if (midQ->resp_buf) {
495 spin_unlock(&GlobalMid_Lock);
496 receive_len = midQ->resp_buf->smb_buf_length;
498 cERROR(1,("No response to cmd %d mid %d",
499 midQ->command, midQ->mid));
500 if(midQ->midState == MID_REQUEST_SUBMITTED) {
501 if(ses->server->tcpStatus == CifsExiting)
504 ses->server->tcpStatus = CifsNeedReconnect;
505 midQ->midState = MID_RETRY_NEEDED;
509 if (rc != -EHOSTDOWN) {
510 if(midQ->midState == MID_RETRY_NEEDED) {
512 cFYI(1,("marking request for retry"));
517 spin_unlock(&GlobalMid_Lock);
518 DeleteMidQEntry(midQ);
519 /* If not lock req, update # of requests on wire to server */
521 atomic_dec(&ses->server->inFlight);
522 wake_up(&ses->server->request_q);
527 if (receive_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) {
528 cERROR(1, ("Frame too large received. Length: %d Xid: %d",
531 } else { /* rcvd frame is ok */
532 if (midQ->resp_buf &&
533 (midQ->midState == MID_RESPONSE_RECEIVED)) {
535 iov[0].iov_base = (char *)midQ->resp_buf;
537 *pRespBufType = CIFS_LARGE_BUFFER;
539 *pRespBufType = CIFS_SMALL_BUFFER;
540 iov[0].iov_len = receive_len + 4;
542 dump_smb(midQ->resp_buf, 80);
543 /* convert the length into a more usable form */
544 if((receive_len > 24) &&
545 (ses->server->secMode & (SECMODE_SIGN_REQUIRED |
546 SECMODE_SIGN_ENABLED))) {
547 rc = cifs_verify_signature(midQ->resp_buf,
548 ses->server->mac_signing_key,
549 midQ->sequence_number+1);
551 cERROR(1,("Unexpected SMB signature"));
552 /* BB FIXME add code to kill session */
556 /* BB special case reconnect tid and uid here? */
557 /* BB special case Errbadpassword and pwdexpired here */
558 rc = map_smb_to_linux_error(midQ->resp_buf);
560 /* convert ByteCount if necessary */
562 sizeof (struct smb_hdr) -
563 4 /* do not count RFC1001 header */ +
564 (2 * midQ->resp_buf->WordCount) + 2 /* bcc */ )
565 BCC(midQ->resp_buf) =
566 le16_to_cpu(BCC_LE(midQ->resp_buf));
567 midQ->resp_buf = NULL; /* mark it so will not be freed
568 by DeleteMidQEntry */
571 cFYI(1,("Bad MID state?"));
574 cifs_no_response_exit2:
575 DeleteMidQEntry(midQ);
578 atomic_dec(&ses->server->inFlight);
579 wake_up(&ses->server->request_q);
585 up(&ses->server->tcpSem);
586 cifs_small_buf_release(in_buf);
587 /* If not lock req, update # of requests on wire to server */
589 atomic_dec(&ses->server->inFlight);
590 wake_up(&ses->server->request_q);
597 SendReceive(const unsigned int xid, struct cifsSesInfo *ses,
598 struct smb_hdr *in_buf, struct smb_hdr *out_buf,
599 int *pbytes_returned, const int long_op)
602 unsigned int receive_len;
603 unsigned long timeout;
604 struct mid_q_entry *midQ;
607 cERROR(1,("Null smb session"));
610 if(ses->server == NULL) {
611 cERROR(1,("Null tcp session"));
615 if(ses->server->tcpStatus == CifsExiting)
618 /* Ensure that we do not send more than 50 overlapping requests
619 to the same server. We may make this configurable later or
622 /* oplock breaks must not be held up */
623 atomic_inc(&ses->server->inFlight);
625 spin_lock(&GlobalMid_Lock);
627 if(atomic_read(&ses->server->inFlight) >=
629 spin_unlock(&GlobalMid_Lock);
630 #ifdef CONFIG_CIFS_STATS2
631 atomic_inc(&ses->server->num_waiters);
633 wait_event(ses->server->request_q,
634 atomic_read(&ses->server->inFlight)
636 #ifdef CONFIG_CIFS_STATS2
637 atomic_dec(&ses->server->num_waiters);
639 spin_lock(&GlobalMid_Lock);
641 if(ses->server->tcpStatus == CifsExiting) {
642 spin_unlock(&GlobalMid_Lock);
646 /* can not count locking commands against total since
647 they are allowed to block on server */
650 /* update # of requests on the wire to server */
651 atomic_inc(&ses->server->inFlight);
653 spin_unlock(&GlobalMid_Lock);
658 /* make sure that we sign in the same order that we send on this socket
659 and avoid races inside tcp sendmsg code that could cause corruption
662 down(&ses->server->tcpSem);
664 if (ses->server->tcpStatus == CifsExiting) {
667 } else if (ses->server->tcpStatus == CifsNeedReconnect) {
668 cFYI(1,("tcp session dead - return to caller to retry"));
671 } else if (ses->status != CifsGood) {
672 /* check if SMB session is bad because we are setting it up */
673 if((in_buf->Command != SMB_COM_SESSION_SETUP_ANDX) &&
674 (in_buf->Command != SMB_COM_NEGOTIATE)) {
677 } /* else ok - we are setting up session */
679 midQ = AllocMidQEntry(in_buf, ses);
681 up(&ses->server->tcpSem);
682 /* If not lock req, update # of requests on wire to server */
684 atomic_dec(&ses->server->inFlight);
685 wake_up(&ses->server->request_q);
690 if (in_buf->smb_buf_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
691 up(&ses->server->tcpSem);
692 cERROR(1, ("Illegal length, greater than maximum frame, %d",
693 in_buf->smb_buf_length));
694 DeleteMidQEntry(midQ);
695 /* If not lock req, update # of requests on wire to server */
697 atomic_dec(&ses->server->inFlight);
698 wake_up(&ses->server->request_q);
703 rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number);
705 midQ->midState = MID_REQUEST_SUBMITTED;
706 #ifdef CONFIG_CIFS_STATS2
707 atomic_inc(&ses->server->inSend);
709 rc = smb_send(ses->server->ssocket, in_buf, in_buf->smb_buf_length,
710 (struct sockaddr *) &(ses->server->addr.sockAddr));
711 #ifdef CONFIG_CIFS_STATS2
712 atomic_dec(&ses->server->inSend);
713 midQ->when_sent = jiffies;
716 DeleteMidQEntry(midQ);
717 up(&ses->server->tcpSem);
718 /* If not lock req, update # of requests on wire to server */
720 atomic_dec(&ses->server->inFlight);
721 wake_up(&ses->server->request_q);
725 up(&ses->server->tcpSem);
727 goto cifs_no_response_exit;
728 else if (long_op == 2) /* writes past end of file can take loong time */
730 else if (long_op == 1)
731 timeout = 45 * HZ; /* should be greater than
732 servers oplock break timeout (about 43 seconds) */
733 else if (long_op > 2) {
734 timeout = MAX_SCHEDULE_TIMEOUT;
737 /* wait for 15 seconds or until woken up due to response arriving or
738 due to last connection to this server being unmounted */
739 if (signal_pending(current)) {
740 /* if signal pending do not hold up user for full smb timeout
741 but we still give response a change to complete */
745 /* No user interrupts in wait - wreaks havoc with performance */
746 if(timeout != MAX_SCHEDULE_TIMEOUT) {
747 unsigned long curr_timeout;
750 curr_timeout = timeout + jiffies;
751 wait_event(ses->server->response_q,
752 (!(midQ->midState & MID_REQUEST_SUBMITTED)) ||
753 time_after(jiffies, curr_timeout) ||
754 ((ses->server->tcpStatus != CifsGood) &&
755 (ses->server->tcpStatus != CifsNew)));
757 if (time_after(jiffies, curr_timeout) &&
758 (midQ->midState & MID_REQUEST_SUBMITTED) &&
759 ((ses->server->tcpStatus == CifsGood) ||
760 (ses->server->tcpStatus == CifsNew))) {
764 /* We timed out. Is the server still
766 spin_lock(&GlobalMid_Lock);
767 lrt = ses->server->lstrp;
768 spin_unlock(&GlobalMid_Lock);
770 /* Calculate 10 seconds past last receive time*/
772 if (time_after(jiffies, lrt)) {
773 /* Server sent no reply in 10 seconds */
774 cERROR(1,("Server not responding"));
782 wait_event(ses->server->response_q,
783 (!(midQ->midState & MID_REQUEST_SUBMITTED)) ||
784 ((ses->server->tcpStatus != CifsGood) &&
785 (ses->server->tcpStatus != CifsNew)));
788 spin_lock(&GlobalMid_Lock);
789 if (midQ->resp_buf) {
790 spin_unlock(&GlobalMid_Lock);
791 receive_len = midQ->resp_buf->smb_buf_length;
793 cERROR(1,("No response for cmd %d mid %d",
794 midQ->command, midQ->mid));
795 if(midQ->midState == MID_REQUEST_SUBMITTED) {
796 if(ses->server->tcpStatus == CifsExiting)
799 ses->server->tcpStatus = CifsNeedReconnect;
800 midQ->midState = MID_RETRY_NEEDED;
804 if (rc != -EHOSTDOWN) {
805 if(midQ->midState == MID_RETRY_NEEDED) {
807 cFYI(1,("marking request for retry"));
812 spin_unlock(&GlobalMid_Lock);
813 DeleteMidQEntry(midQ);
814 /* If not lock req, update # of requests on wire to server */
816 atomic_dec(&ses->server->inFlight);
817 wake_up(&ses->server->request_q);
822 if (receive_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) {
823 cERROR(1, ("Frame too large received. Length: %d Xid: %d",
826 } else { /* rcvd frame is ok */
828 if (midQ->resp_buf && out_buf
829 && (midQ->midState == MID_RESPONSE_RECEIVED)) {
830 out_buf->smb_buf_length = receive_len;
831 memcpy((char *)out_buf + 4,
832 (char *)midQ->resp_buf + 4,
835 dump_smb(out_buf, 92);
836 /* convert the length into a more usable form */
837 if((receive_len > 24) &&
838 (ses->server->secMode & (SECMODE_SIGN_REQUIRED |
839 SECMODE_SIGN_ENABLED))) {
840 rc = cifs_verify_signature(out_buf,
841 ses->server->mac_signing_key,
842 midQ->sequence_number+1);
844 cERROR(1,("Unexpected SMB signature"));
845 /* BB FIXME add code to kill session */
849 *pbytes_returned = out_buf->smb_buf_length;
851 /* BB special case reconnect tid and uid here? */
852 rc = map_smb_to_linux_error(out_buf);
854 /* convert ByteCount if necessary */
856 sizeof (struct smb_hdr) -
857 4 /* do not count RFC1001 header */ +
858 (2 * out_buf->WordCount) + 2 /* bcc */ )
859 BCC(out_buf) = le16_to_cpu(BCC_LE(out_buf));
862 cERROR(1,("Bad MID state?"));
865 cifs_no_response_exit:
866 DeleteMidQEntry(midQ);
869 atomic_dec(&ses->server->inFlight);
870 wake_up(&ses->server->request_q);
876 up(&ses->server->tcpSem);
877 /* If not lock req, update # of requests on wire to server */
879 atomic_dec(&ses->server->inFlight);
880 wake_up(&ses->server->request_q);