4 * Copyright (C) International Business Machines Corp., 2002,2008
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/gfp.h>
26 #include <linux/wait.h>
27 #include <linux/net.h>
28 #include <linux/delay.h>
29 #include <linux/freezer.h>
30 #include <asm/uaccess.h>
31 #include <asm/processor.h>
32 #include <linux/mempool.h>
35 #include "cifsproto.h"
36 #include "cifs_debug.h"
39 cifs_wake_up_task(struct mid_q_entry *mid)
41 wake_up_process(mid->callback_data);
45 AllocMidQEntry(const struct smb_hdr *smb_buffer, struct TCP_Server_Info *server)
47 struct mid_q_entry *temp;
50 cERROR(1, "Null TCP session in AllocMidQEntry");
54 temp = mempool_alloc(cifs_mid_poolp, GFP_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 = cpu_to_le16(smb_buffer->Command);
62 cFYI(1, "For smb_command %d", smb_buffer->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;
66 temp->server = server;
69 * The default is for the mid to be synchronous, so the
70 * default callback just wakes up the current task.
72 temp->callback = cifs_wake_up_task;
73 temp->callback_data = current;
76 atomic_inc(&midCount);
77 temp->mid_state = MID_REQUEST_ALLOCATED;
82 DeleteMidQEntry(struct mid_q_entry *midEntry)
84 #ifdef CONFIG_CIFS_STATS2
85 __le16 command = midEntry->server->vals->lock_cmd;
88 midEntry->mid_state = MID_FREE;
89 atomic_dec(&midCount);
90 if (midEntry->large_buf)
91 cifs_buf_release(midEntry->resp_buf);
93 cifs_small_buf_release(midEntry->resp_buf);
94 #ifdef CONFIG_CIFS_STATS2
96 /* commands taking longer than one second are indications that
97 something is wrong, unless it is quite a slow link or server */
98 if ((now - midEntry->when_alloc) > HZ) {
99 if ((cifsFYI & CIFS_TIMER) && (midEntry->command != command)) {
100 printk(KERN_DEBUG " CIFS slow rsp: cmd %d mid %llu",
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);
113 delete_mid(struct mid_q_entry *mid)
115 spin_lock(&GlobalMid_Lock);
116 list_del(&mid->qhead);
117 spin_unlock(&GlobalMid_Lock);
119 DeleteMidQEntry(mid);
123 smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec)
127 struct msghdr smb_msg;
128 unsigned int len = iov[0].iov_len;
129 unsigned int total_len;
131 unsigned int smb_buf_length = get_rfc1002_length(iov[0].iov_base);
132 struct socket *ssocket = server->ssocket;
135 return -ENOTSOCK; /* BB eventually add reconnect code here */
137 smb_msg.msg_name = (struct sockaddr *) &server->dstaddr;
138 smb_msg.msg_namelen = sizeof(struct sockaddr);
139 smb_msg.msg_control = NULL;
140 smb_msg.msg_controllen = 0;
141 if (server->noblocksnd)
142 smb_msg.msg_flags = MSG_DONTWAIT + MSG_NOSIGNAL;
144 smb_msg.msg_flags = MSG_NOSIGNAL;
147 for (i = 0; i < n_vec; i++)
148 total_len += iov[i].iov_len;
150 cFYI(1, "Sending smb: total_len %d", total_len);
151 dump_smb(iov[0].iov_base, len);
155 rc = kernel_sendmsg(ssocket, &smb_msg, &iov[first_vec],
156 n_vec - first_vec, total_len);
157 if ((rc == -ENOSPC) || (rc == -EAGAIN)) {
160 * If blocking send we try 3 times, since each can block
161 * for 5 seconds. For nonblocking we have to try more
162 * but wait increasing amounts of time allowing time for
163 * socket to clear. The overall time we wait in either
164 * case to send on the socket is about 15 seconds.
165 * Similarly we wait for 15 seconds for a response from
166 * the server in SendReceive[2] for the server to send
167 * a response back for most types of requests (except
168 * SMB Write past end of file which can be slow, and
169 * blocking lock operations). NFS waits slightly longer
170 * than CIFS, but this can make it take longer for
171 * nonresponsive servers to be detected and 15 seconds
172 * is more than enough time for modern networks to
173 * send a packet. In most cases if we fail to send
174 * after the retries we will kill the socket and
175 * reconnect which may clear the network problem.
177 if ((i >= 14) || (!server->noblocksnd && (i > 2))) {
178 cERROR(1, "sends on sock %p stuck for 15 seconds",
189 if (rc == total_len) {
192 } else if (rc > total_len) {
193 cERROR(1, "sent %d requested %d", rc, total_len);
197 /* should never happen, letting socket clear before
198 retrying is our only obvious option here */
199 cERROR(1, "tcp sent no data");
204 /* the line below resets i */
205 for (i = first_vec; i < n_vec; i++) {
206 if (iov[i].iov_len) {
207 if (rc > iov[i].iov_len) {
208 rc -= iov[i].iov_len;
211 iov[i].iov_base += rc;
212 iov[i].iov_len -= rc;
218 i = 0; /* in case we get ENOSPC on the next send */
221 if ((total_len > 0) && (total_len != smb_buf_length + 4)) {
222 cFYI(1, "partial send (%d remaining), terminating session",
224 /* If we have only sent part of an SMB then the next SMB
225 could be taken as the remainder of this one. We need
226 to kill the socket so the server throws away the partial
228 server->tcpStatus = CifsNeedReconnect;
231 if (rc < 0 && rc != -EINTR)
232 cERROR(1, "Error %d sending data on socket to server", rc);
240 smb_send(struct TCP_Server_Info *server, struct smb_hdr *smb_buffer,
241 unsigned int smb_buf_length)
245 iov.iov_base = smb_buffer;
246 iov.iov_len = smb_buf_length + 4;
248 return smb_sendv(server, &iov, 1);
252 wait_for_free_credits(struct TCP_Server_Info *server, const int timeout,
257 spin_lock(&server->req_lock);
258 if (timeout == CIFS_ASYNC_OP) {
259 /* oplock breaks must not be held up */
262 spin_unlock(&server->req_lock);
268 spin_unlock(&server->req_lock);
269 cifs_num_waiters_inc(server);
270 rc = wait_event_killable(server->request_q,
271 has_credits(server, credits));
272 cifs_num_waiters_dec(server);
275 spin_lock(&server->req_lock);
277 if (server->tcpStatus == CifsExiting) {
278 spin_unlock(&server->req_lock);
283 * Can not count locking commands against total
284 * as they are allowed to block on server.
287 /* update # of requests on the wire to server */
288 if (timeout != CIFS_BLOCKING_OP) {
292 spin_unlock(&server->req_lock);
300 wait_for_free_request(struct TCP_Server_Info *server, const int timeout,
303 return wait_for_free_credits(server, timeout,
304 server->ops->get_credits_field(server, optype));
307 static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,
308 struct mid_q_entry **ppmidQ)
310 if (ses->server->tcpStatus == CifsExiting) {
314 if (ses->server->tcpStatus == CifsNeedReconnect) {
315 cFYI(1, "tcp session dead - return to caller to retry");
319 if (ses->status != CifsGood) {
320 /* check if SMB session is bad because we are setting it up */
321 if ((in_buf->Command != SMB_COM_SESSION_SETUP_ANDX) &&
322 (in_buf->Command != SMB_COM_NEGOTIATE))
324 /* else ok - we are setting up session */
326 *ppmidQ = AllocMidQEntry(in_buf, ses->server);
329 spin_lock(&GlobalMid_Lock);
330 list_add_tail(&(*ppmidQ)->qhead, &ses->server->pending_mid_q);
331 spin_unlock(&GlobalMid_Lock);
336 wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ)
340 error = wait_event_freezekillable(server->response_q,
341 midQ->mid_state != MID_REQUEST_SUBMITTED);
349 cifs_setup_async_request(struct TCP_Server_Info *server, struct kvec *iov,
350 unsigned int nvec, struct mid_q_entry **ret_mid)
353 struct smb_hdr *hdr = (struct smb_hdr *)iov[0].iov_base;
354 struct mid_q_entry *mid;
356 /* enable signing if server requires it */
357 if (server->sec_mode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
358 hdr->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
360 mid = AllocMidQEntry(hdr, server);
364 rc = cifs_sign_smbv(iov, nvec, server, &mid->sequence_number);
366 DeleteMidQEntry(mid);
375 * Send a SMB request and set the callback function in the mid to handle
376 * the result. Caller is responsible for dealing with timeouts.
379 cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov,
380 unsigned int nvec, mid_receive_t *receive,
381 mid_callback_t *callback, void *cbdata, const int flags)
383 int rc, timeout, optype;
384 struct mid_q_entry *mid;
386 timeout = flags & CIFS_TIMEOUT_MASK;
387 optype = flags & CIFS_OP_MASK;
389 rc = wait_for_free_request(server, timeout, optype);
393 mutex_lock(&server->srv_mutex);
394 rc = server->ops->setup_async_request(server, iov, nvec, &mid);
396 mutex_unlock(&server->srv_mutex);
397 add_credits(server, 1, optype);
398 wake_up(&server->request_q);
402 mid->receive = receive;
403 mid->callback = callback;
404 mid->callback_data = cbdata;
405 mid->mid_state = MID_REQUEST_SUBMITTED;
407 /* put it on the pending_mid_q */
408 spin_lock(&GlobalMid_Lock);
409 list_add_tail(&mid->qhead, &server->pending_mid_q);
410 spin_unlock(&GlobalMid_Lock);
413 cifs_in_send_inc(server);
414 rc = smb_sendv(server, iov, nvec);
415 cifs_in_send_dec(server);
416 cifs_save_when_sent(mid);
417 mutex_unlock(&server->srv_mutex);
423 add_credits(server, 1, optype);
424 wake_up(&server->request_q);
430 * Send an SMB Request. No response info (other than return code)
431 * needs to be parsed.
433 * flags indicate the type of request buffer and how long to wait
434 * and whether to log NT STATUS code (error) before mapping it to POSIX error
438 SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
439 char *in_buf, int flags)
445 iov[0].iov_base = in_buf;
446 iov[0].iov_len = get_rfc1002_length(in_buf) + 4;
447 flags |= CIFS_NO_RESP;
448 rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags);
449 cFYI(DBG2, "SendRcvNoRsp flags %d rc %d", flags, rc);
455 cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server)
459 cFYI(1, "%s: cmd=%d mid=%llu state=%d", __func__,
460 le16_to_cpu(mid->command), mid->mid, mid->mid_state);
462 spin_lock(&GlobalMid_Lock);
463 switch (mid->mid_state) {
464 case MID_RESPONSE_RECEIVED:
465 spin_unlock(&GlobalMid_Lock);
467 case MID_RETRY_NEEDED:
470 case MID_RESPONSE_MALFORMED:
477 list_del_init(&mid->qhead);
478 cERROR(1, "%s: invalid mid state mid=%llu state=%d", __func__,
479 mid->mid, mid->mid_state);
482 spin_unlock(&GlobalMid_Lock);
484 DeleteMidQEntry(mid);
489 send_cancel(struct TCP_Server_Info *server, void *buf, struct mid_q_entry *mid)
491 return server->ops->send_cancel ?
492 server->ops->send_cancel(server, buf, mid) : 0;
496 cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
499 unsigned int len = get_rfc1002_length(mid->resp_buf) + 4;
501 dump_smb(mid->resp_buf, min_t(u32, 92, len));
503 /* convert the length into a more usable form */
504 if (server->sec_mode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) {
507 iov.iov_base = mid->resp_buf;
509 /* FIXME: add code to kill session */
510 if (cifs_verify_signature(&iov, 1, server,
511 mid->sequence_number + 1) != 0)
512 cERROR(1, "Unexpected SMB signature");
515 /* BB special case reconnect tid and uid here? */
516 return map_smb_to_linux_error(mid->resp_buf, log_error);
520 cifs_setup_request(struct cifs_ses *ses, struct kvec *iov,
521 unsigned int nvec, struct mid_q_entry **ret_mid)
524 struct smb_hdr *hdr = (struct smb_hdr *)iov[0].iov_base;
525 struct mid_q_entry *mid;
527 rc = allocate_mid(ses, hdr, &mid);
530 rc = cifs_sign_smbv(iov, nvec, ses->server, &mid->sequence_number);
538 SendReceive2(const unsigned int xid, struct cifs_ses *ses,
539 struct kvec *iov, int n_vec, int *resp_buf_type /* ret */,
544 struct mid_q_entry *midQ;
545 char *buf = iov[0].iov_base;
546 unsigned int credits = 1;
548 timeout = flags & CIFS_TIMEOUT_MASK;
549 optype = flags & CIFS_OP_MASK;
551 *resp_buf_type = CIFS_NO_BUFFER; /* no response buf yet */
553 if ((ses == NULL) || (ses->server == NULL)) {
554 cifs_small_buf_release(buf);
555 cERROR(1, "Null session");
559 if (ses->server->tcpStatus == CifsExiting) {
560 cifs_small_buf_release(buf);
565 * Ensure that we do not send more than 50 overlapping requests
566 * to the same server. We may make this configurable later or
570 rc = wait_for_free_request(ses->server, timeout, optype);
572 cifs_small_buf_release(buf);
577 * Make sure that we sign in the same order that we send on this socket
578 * and avoid races inside tcp sendmsg code that could cause corruption
582 mutex_lock(&ses->server->srv_mutex);
584 rc = ses->server->ops->setup_request(ses, iov, n_vec, &midQ);
586 mutex_unlock(&ses->server->srv_mutex);
587 cifs_small_buf_release(buf);
588 /* Update # of requests on wire to server */
589 add_credits(ses->server, 1, optype);
593 midQ->mid_state = MID_REQUEST_SUBMITTED;
594 cifs_in_send_inc(ses->server);
595 rc = smb_sendv(ses->server, iov, n_vec);
596 cifs_in_send_dec(ses->server);
597 cifs_save_when_sent(midQ);
599 mutex_unlock(&ses->server->srv_mutex);
602 cifs_small_buf_release(buf);
606 if (timeout == CIFS_ASYNC_OP) {
607 cifs_small_buf_release(buf);
611 rc = wait_for_response(ses->server, midQ);
613 send_cancel(ses->server, buf, midQ);
614 spin_lock(&GlobalMid_Lock);
615 if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
616 midQ->callback = DeleteMidQEntry;
617 spin_unlock(&GlobalMid_Lock);
618 cifs_small_buf_release(buf);
619 add_credits(ses->server, 1, optype);
622 spin_unlock(&GlobalMid_Lock);
625 cifs_small_buf_release(buf);
627 rc = cifs_sync_mid_result(midQ, ses->server);
629 add_credits(ses->server, 1, optype);
633 if (!midQ->resp_buf || midQ->mid_state != MID_RESPONSE_RECEIVED) {
635 cFYI(1, "Bad MID state?");
639 buf = (char *)midQ->resp_buf;
640 iov[0].iov_base = buf;
641 iov[0].iov_len = get_rfc1002_length(buf) + 4;
643 *resp_buf_type = CIFS_LARGE_BUFFER;
645 *resp_buf_type = CIFS_SMALL_BUFFER;
647 credits = ses->server->ops->get_credits(midQ);
649 rc = ses->server->ops->check_receive(midQ, ses->server,
650 flags & CIFS_LOG_ERROR);
652 /* mark it so buf will not be freed by delete_mid */
653 if ((flags & CIFS_NO_RESP) == 0)
654 midQ->resp_buf = NULL;
657 add_credits(ses->server, credits, optype);
663 SendReceive(const unsigned int xid, struct cifs_ses *ses,
664 struct smb_hdr *in_buf, struct smb_hdr *out_buf,
665 int *pbytes_returned, const int timeout)
668 struct mid_q_entry *midQ;
671 cERROR(1, "Null smb session");
674 if (ses->server == NULL) {
675 cERROR(1, "Null tcp session");
679 if (ses->server->tcpStatus == CifsExiting)
682 /* Ensure that we do not send more than 50 overlapping requests
683 to the same server. We may make this configurable later or
686 if (be32_to_cpu(in_buf->smb_buf_length) > CIFSMaxBufSize +
687 MAX_CIFS_HDR_SIZE - 4) {
688 cERROR(1, "Illegal length, greater than maximum frame, %d",
689 be32_to_cpu(in_buf->smb_buf_length));
693 rc = wait_for_free_request(ses->server, timeout, 0);
697 /* make sure that we sign in the same order that we send on this socket
698 and avoid races inside tcp sendmsg code that could cause corruption
701 mutex_lock(&ses->server->srv_mutex);
703 rc = allocate_mid(ses, in_buf, &midQ);
705 mutex_unlock(&ses->server->srv_mutex);
706 /* Update # of requests on wire to server */
707 add_credits(ses->server, 1, 0);
711 rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number);
713 mutex_unlock(&ses->server->srv_mutex);
717 midQ->mid_state = MID_REQUEST_SUBMITTED;
719 cifs_in_send_inc(ses->server);
720 rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
721 cifs_in_send_dec(ses->server);
722 cifs_save_when_sent(midQ);
723 mutex_unlock(&ses->server->srv_mutex);
728 if (timeout == CIFS_ASYNC_OP)
731 rc = wait_for_response(ses->server, midQ);
733 send_cancel(ses->server, in_buf, midQ);
734 spin_lock(&GlobalMid_Lock);
735 if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
736 /* no longer considered to be "in-flight" */
737 midQ->callback = DeleteMidQEntry;
738 spin_unlock(&GlobalMid_Lock);
739 add_credits(ses->server, 1, 0);
742 spin_unlock(&GlobalMid_Lock);
745 rc = cifs_sync_mid_result(midQ, ses->server);
747 add_credits(ses->server, 1, 0);
751 if (!midQ->resp_buf || !out_buf ||
752 midQ->mid_state != MID_RESPONSE_RECEIVED) {
754 cERROR(1, "Bad MID state?");
758 *pbytes_returned = get_rfc1002_length(midQ->resp_buf);
759 memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4);
760 rc = cifs_check_receive(midQ, ses->server, 0);
763 add_credits(ses->server, 1, 0);
768 /* We send a LOCKINGX_CANCEL_LOCK to cause the Windows
769 blocking lock to return. */
772 send_lock_cancel(const unsigned int xid, struct cifs_tcon *tcon,
773 struct smb_hdr *in_buf,
774 struct smb_hdr *out_buf)
777 struct cifs_ses *ses = tcon->ses;
778 LOCK_REQ *pSMB = (LOCK_REQ *)in_buf;
780 /* We just modify the current in_buf to change
781 the type of lock from LOCKING_ANDX_SHARED_LOCK
782 or LOCKING_ANDX_EXCLUSIVE_LOCK to
783 LOCKING_ANDX_CANCEL_LOCK. */
785 pSMB->LockType = LOCKING_ANDX_CANCEL_LOCK|LOCKING_ANDX_LARGE_FILES;
787 pSMB->hdr.Mid = get_next_mid(ses->server);
789 return SendReceive(xid, ses, in_buf, out_buf,
794 SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
795 struct smb_hdr *in_buf, struct smb_hdr *out_buf,
796 int *pbytes_returned)
800 struct mid_q_entry *midQ;
801 struct cifs_ses *ses;
803 if (tcon == NULL || tcon->ses == NULL) {
804 cERROR(1, "Null smb session");
809 if (ses->server == NULL) {
810 cERROR(1, "Null tcp session");
814 if (ses->server->tcpStatus == CifsExiting)
817 /* Ensure that we do not send more than 50 overlapping requests
818 to the same server. We may make this configurable later or
821 if (be32_to_cpu(in_buf->smb_buf_length) > CIFSMaxBufSize +
822 MAX_CIFS_HDR_SIZE - 4) {
823 cERROR(1, "Illegal length, greater than maximum frame, %d",
824 be32_to_cpu(in_buf->smb_buf_length));
828 rc = wait_for_free_request(ses->server, CIFS_BLOCKING_OP, 0);
832 /* make sure that we sign in the same order that we send on this socket
833 and avoid races inside tcp sendmsg code that could cause corruption
836 mutex_lock(&ses->server->srv_mutex);
838 rc = allocate_mid(ses, in_buf, &midQ);
840 mutex_unlock(&ses->server->srv_mutex);
844 rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number);
847 mutex_unlock(&ses->server->srv_mutex);
851 midQ->mid_state = MID_REQUEST_SUBMITTED;
852 cifs_in_send_inc(ses->server);
853 rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length));
854 cifs_in_send_dec(ses->server);
855 cifs_save_when_sent(midQ);
856 mutex_unlock(&ses->server->srv_mutex);
863 /* Wait for a reply - allow signals to interrupt. */
864 rc = wait_event_interruptible(ses->server->response_q,
865 (!(midQ->mid_state == MID_REQUEST_SUBMITTED)) ||
866 ((ses->server->tcpStatus != CifsGood) &&
867 (ses->server->tcpStatus != CifsNew)));
869 /* Were we interrupted by a signal ? */
870 if ((rc == -ERESTARTSYS) &&
871 (midQ->mid_state == MID_REQUEST_SUBMITTED) &&
872 ((ses->server->tcpStatus == CifsGood) ||
873 (ses->server->tcpStatus == CifsNew))) {
875 if (in_buf->Command == SMB_COM_TRANSACTION2) {
876 /* POSIX lock. We send a NT_CANCEL SMB to cause the
877 blocking lock to return. */
878 rc = send_cancel(ses->server, in_buf, midQ);
884 /* Windows lock. We send a LOCKINGX_CANCEL_LOCK
885 to cause the blocking lock to return. */
887 rc = send_lock_cancel(xid, tcon, in_buf, out_buf);
889 /* If we get -ENOLCK back the lock may have
890 already been removed. Don't exit in this case. */
891 if (rc && rc != -ENOLCK) {
897 rc = wait_for_response(ses->server, midQ);
899 send_cancel(ses->server, in_buf, midQ);
900 spin_lock(&GlobalMid_Lock);
901 if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
902 /* no longer considered to be "in-flight" */
903 midQ->callback = DeleteMidQEntry;
904 spin_unlock(&GlobalMid_Lock);
907 spin_unlock(&GlobalMid_Lock);
910 /* We got the response - restart system call. */
914 rc = cifs_sync_mid_result(midQ, ses->server);
918 /* rcvd frame is ok */
919 if (out_buf == NULL || midQ->mid_state != MID_RESPONSE_RECEIVED) {
921 cERROR(1, "Bad MID state?");
925 *pbytes_returned = get_rfc1002_length(midQ->resp_buf);
926 memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4);
927 rc = cifs_check_receive(midQ, ses->server, 0);
930 if (rstart && rc == -EACCES)