smb: client: rename server mid_lock to mid_queue_lock

This is step 1/4 of a patch series to fix mid_q_entry memory leaks
caused by race conditions in callback execution.

The current mid_lock name is somewhat ambiguous about what it protects.
To prepare for splitting this lock into separate, more granular locks,
this patch renames mid_lock to mid_queue_lock to clearly indicate its
specific responsibility for protecting the pending_mid_q list and
related queue operations.

No functional changes are made in this patch - it only prepares the
codebase for the lock splitting that follows.

- mid_queue_lock for queue operations
- mid_counter_lock for mid counter operations
- per-mid locks for individual mid state management

Signed-off-by: Wang Zhaolong <wangzhaolong@huaweicloud.com>
Acked-by: Enzo Matsumiya <ematsumiya@suse.de>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Wang Zhaolong 2025-08-04 21:40:03 +08:00 committed by Steve French
parent 5b432ae5df
commit f3ba7c9b04
7 changed files with 54 additions and 54 deletions

View File

@ -60,7 +60,7 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
return; return;
cifs_dbg(VFS, "Dump pending requests:\n"); cifs_dbg(VFS, "Dump pending requests:\n");
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
list_for_each_entry(mid_entry, &server->pending_mid_q, qhead) { list_for_each_entry(mid_entry, &server->pending_mid_q, qhead) {
cifs_dbg(VFS, "State: %d Cmd: %d Pid: %d Cbdata: %p Mid %llu\n", cifs_dbg(VFS, "State: %d Cmd: %d Pid: %d Cbdata: %p Mid %llu\n",
mid_entry->mid_state, mid_entry->mid_state,
@ -83,7 +83,7 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
mid_entry->resp_buf, 62); mid_entry->resp_buf, 62);
} }
} }
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
#endif /* CONFIG_CIFS_DEBUG2 */ #endif /* CONFIG_CIFS_DEBUG2 */
} }
@ -672,7 +672,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
seq_printf(m, "\n\tServer ConnectionId: 0x%llx", seq_printf(m, "\n\tServer ConnectionId: 0x%llx",
chan_server->conn_id); chan_server->conn_id);
spin_lock(&chan_server->mid_lock); spin_lock(&chan_server->mid_queue_lock);
list_for_each_entry(mid_entry, &chan_server->pending_mid_q, qhead) { list_for_each_entry(mid_entry, &chan_server->pending_mid_q, qhead) {
seq_printf(m, "\n\t\tState: %d com: %d pid: %d cbdata: %p mid %llu", seq_printf(m, "\n\t\tState: %d com: %d pid: %d cbdata: %p mid %llu",
mid_entry->mid_state, mid_entry->mid_state,
@ -681,7 +681,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
mid_entry->callback_data, mid_entry->callback_data,
mid_entry->mid); mid_entry->mid);
} }
spin_unlock(&chan_server->mid_lock); spin_unlock(&chan_server->mid_queue_lock);
} }
spin_unlock(&ses->chan_lock); spin_unlock(&ses->chan_lock);
seq_puts(m, "\n--\n"); seq_puts(m, "\n--\n");

View File

@ -732,7 +732,7 @@ struct TCP_Server_Info {
#endif #endif
wait_queue_head_t response_q; wait_queue_head_t response_q;
wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/ wait_queue_head_t request_q; /* if more than maxmpx to srvr must block*/
spinlock_t mid_lock; /* protect mid queue and it's entries */ spinlock_t mid_queue_lock; /* protect mid queue */
struct list_head pending_mid_q; struct list_head pending_mid_q;
bool noblocksnd; /* use blocking sendmsg */ bool noblocksnd; /* use blocking sendmsg */
bool noautotune; /* do not autotune send buf sizes */ bool noautotune; /* do not autotune send buf sizes */
@ -2007,7 +2007,7 @@ require use of the stronger protocol */
* GlobalCurrentXid * GlobalCurrentXid
* GlobalTotalActiveXid * GlobalTotalActiveXid
* TCP_Server_Info->srv_lock (anything in struct not protected by another lock and can change) * TCP_Server_Info->srv_lock (anything in struct not protected by another lock and can change)
* TCP_Server_Info->mid_lock TCP_Server_Info->pending_mid_q cifs_get_tcp_session * TCP_Server_Info->mid_queue_lock TCP_Server_Info->pending_mid_q cifs_get_tcp_session
* ->CurrentMid * ->CurrentMid
* (any changes in mid_q_entry fields) * (any changes in mid_q_entry fields)
* TCP_Server_Info->req_lock TCP_Server_Info->in_flight cifs_get_tcp_session * TCP_Server_Info->req_lock TCP_Server_Info->in_flight cifs_get_tcp_session

View File

@ -321,7 +321,7 @@ cifs_abort_connection(struct TCP_Server_Info *server)
/* mark submitted MIDs for retry and issue callback */ /* mark submitted MIDs for retry and issue callback */
INIT_LIST_HEAD(&retry_list); INIT_LIST_HEAD(&retry_list);
cifs_dbg(FYI, "%s: moving mids to private list\n", __func__); cifs_dbg(FYI, "%s: moving mids to private list\n", __func__);
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
list_for_each_entry_safe(mid, nmid, &server->pending_mid_q, qhead) { list_for_each_entry_safe(mid, nmid, &server->pending_mid_q, qhead) {
kref_get(&mid->refcount); kref_get(&mid->refcount);
if (mid->mid_state == MID_REQUEST_SUBMITTED) if (mid->mid_state == MID_REQUEST_SUBMITTED)
@ -329,7 +329,7 @@ cifs_abort_connection(struct TCP_Server_Info *server)
list_move(&mid->qhead, &retry_list); list_move(&mid->qhead, &retry_list);
mid->mid_flags |= MID_DELETED; mid->mid_flags |= MID_DELETED;
} }
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
cifs_server_unlock(server); cifs_server_unlock(server);
cifs_dbg(FYI, "%s: issuing mid callbacks\n", __func__); cifs_dbg(FYI, "%s: issuing mid callbacks\n", __func__);
@ -884,13 +884,13 @@ is_smb_response(struct TCP_Server_Info *server, unsigned char type)
* server there should be exactly one pending mid * server there should be exactly one pending mid
* corresponding to SMB1/SMB2 Negotiate packet. * corresponding to SMB1/SMB2 Negotiate packet.
*/ */
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
list_for_each_entry_safe(mid, nmid, &server->pending_mid_q, qhead) { list_for_each_entry_safe(mid, nmid, &server->pending_mid_q, qhead) {
kref_get(&mid->refcount); kref_get(&mid->refcount);
list_move(&mid->qhead, &dispose_list); list_move(&mid->qhead, &dispose_list);
mid->mid_flags |= MID_DELETED; mid->mid_flags |= MID_DELETED;
} }
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
/* Now try to reconnect once with NetBIOS session. */ /* Now try to reconnect once with NetBIOS session. */
server->with_rfc1001 = true; server->with_rfc1001 = true;
@ -957,7 +957,7 @@ dequeue_mid(struct mid_q_entry *mid, bool malformed)
#ifdef CONFIG_CIFS_STATS2 #ifdef CONFIG_CIFS_STATS2
mid->when_received = jiffies; mid->when_received = jiffies;
#endif #endif
spin_lock(&mid->server->mid_lock); spin_lock(&mid->server->mid_queue_lock);
if (!malformed) if (!malformed)
mid->mid_state = MID_RESPONSE_RECEIVED; mid->mid_state = MID_RESPONSE_RECEIVED;
else else
@ -967,12 +967,12 @@ dequeue_mid(struct mid_q_entry *mid, bool malformed)
* function has finished processing it is a bug. * function has finished processing it is a bug.
*/ */
if (mid->mid_flags & MID_DELETED) { if (mid->mid_flags & MID_DELETED) {
spin_unlock(&mid->server->mid_lock); spin_unlock(&mid->server->mid_queue_lock);
pr_warn_once("trying to dequeue a deleted mid\n"); pr_warn_once("trying to dequeue a deleted mid\n");
} else { } else {
list_del_init(&mid->qhead); list_del_init(&mid->qhead);
mid->mid_flags |= MID_DELETED; mid->mid_flags |= MID_DELETED;
spin_unlock(&mid->server->mid_lock); spin_unlock(&mid->server->mid_queue_lock);
} }
} }
@ -1101,7 +1101,7 @@ clean_demultiplex_info(struct TCP_Server_Info *server)
struct list_head *tmp, *tmp2; struct list_head *tmp, *tmp2;
LIST_HEAD(dispose_list); LIST_HEAD(dispose_list);
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
list_for_each_safe(tmp, tmp2, &server->pending_mid_q) { list_for_each_safe(tmp, tmp2, &server->pending_mid_q) {
mid_entry = list_entry(tmp, struct mid_q_entry, qhead); mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
cifs_dbg(FYI, "Clearing mid %llu\n", mid_entry->mid); cifs_dbg(FYI, "Clearing mid %llu\n", mid_entry->mid);
@ -1110,7 +1110,7 @@ clean_demultiplex_info(struct TCP_Server_Info *server)
list_move(&mid_entry->qhead, &dispose_list); list_move(&mid_entry->qhead, &dispose_list);
mid_entry->mid_flags |= MID_DELETED; mid_entry->mid_flags |= MID_DELETED;
} }
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
/* now walk dispose list and issue callbacks */ /* now walk dispose list and issue callbacks */
list_for_each_safe(tmp, tmp2, &dispose_list) { list_for_each_safe(tmp, tmp2, &dispose_list) {
@ -1822,7 +1822,7 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx,
tcp_ses->compression.requested = ctx->compress; tcp_ses->compression.requested = ctx->compress;
spin_lock_init(&tcp_ses->req_lock); spin_lock_init(&tcp_ses->req_lock);
spin_lock_init(&tcp_ses->srv_lock); spin_lock_init(&tcp_ses->srv_lock);
spin_lock_init(&tcp_ses->mid_lock); spin_lock_init(&tcp_ses->mid_queue_lock);
INIT_LIST_HEAD(&tcp_ses->tcp_ses_list); INIT_LIST_HEAD(&tcp_ses->tcp_ses_list);
INIT_LIST_HEAD(&tcp_ses->smb_ses_list); INIT_LIST_HEAD(&tcp_ses->smb_ses_list);
INIT_DELAYED_WORK(&tcp_ses->echo, cifs_echo_request); INIT_DELAYED_WORK(&tcp_ses->echo, cifs_echo_request);

View File

@ -95,17 +95,17 @@ cifs_find_mid(struct TCP_Server_Info *server, char *buffer)
struct smb_hdr *buf = (struct smb_hdr *)buffer; struct smb_hdr *buf = (struct smb_hdr *)buffer;
struct mid_q_entry *mid; struct mid_q_entry *mid;
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
list_for_each_entry(mid, &server->pending_mid_q, qhead) { list_for_each_entry(mid, &server->pending_mid_q, qhead) {
if (compare_mid(mid->mid, buf) && if (compare_mid(mid->mid, buf) &&
mid->mid_state == MID_REQUEST_SUBMITTED && mid->mid_state == MID_REQUEST_SUBMITTED &&
le16_to_cpu(mid->command) == buf->Command) { le16_to_cpu(mid->command) == buf->Command) {
kref_get(&mid->refcount); kref_get(&mid->refcount);
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
return mid; return mid;
} }
} }
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
return NULL; return NULL;
} }
@ -169,7 +169,7 @@ cifs_get_next_mid(struct TCP_Server_Info *server)
__u16 last_mid, cur_mid; __u16 last_mid, cur_mid;
bool collision, reconnect = false; bool collision, reconnect = false;
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
/* mid is 16 bit only for CIFS/SMB */ /* mid is 16 bit only for CIFS/SMB */
cur_mid = (__u16)((server->CurrentMid) & 0xffff); cur_mid = (__u16)((server->CurrentMid) & 0xffff);
@ -228,7 +228,7 @@ cifs_get_next_mid(struct TCP_Server_Info *server)
} }
cur_mid++; cur_mid++;
} }
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
if (reconnect) { if (reconnect) {
cifs_signal_cifsd_for_reconnect(server, false); cifs_signal_cifsd_for_reconnect(server, false);

View File

@ -374,19 +374,19 @@ smb2_get_next_mid(struct TCP_Server_Info *server)
{ {
__u64 mid; __u64 mid;
/* for SMB2 we need the current value */ /* for SMB2 we need the current value */
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
mid = server->CurrentMid++; mid = server->CurrentMid++;
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
return mid; return mid;
} }
static void static void
smb2_revert_current_mid(struct TCP_Server_Info *server, const unsigned int val) smb2_revert_current_mid(struct TCP_Server_Info *server, const unsigned int val)
{ {
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
if (server->CurrentMid >= val) if (server->CurrentMid >= val)
server->CurrentMid -= val; server->CurrentMid -= val;
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
} }
static struct mid_q_entry * static struct mid_q_entry *
@ -401,7 +401,7 @@ __smb2_find_mid(struct TCP_Server_Info *server, char *buf, bool dequeue)
return NULL; return NULL;
} }
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
list_for_each_entry(mid, &server->pending_mid_q, qhead) { list_for_each_entry(mid, &server->pending_mid_q, qhead) {
if ((mid->mid == wire_mid) && if ((mid->mid == wire_mid) &&
(mid->mid_state == MID_REQUEST_SUBMITTED) && (mid->mid_state == MID_REQUEST_SUBMITTED) &&
@ -411,11 +411,11 @@ __smb2_find_mid(struct TCP_Server_Info *server, char *buf, bool dequeue)
list_del_init(&mid->qhead); list_del_init(&mid->qhead);
mid->mid_flags |= MID_DELETED; mid->mid_flags |= MID_DELETED;
} }
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
return mid; return mid;
} }
} }
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
return NULL; return NULL;
} }
@ -460,9 +460,9 @@ smb2_negotiate(const unsigned int xid,
{ {
int rc; int rc;
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
server->CurrentMid = 0; server->CurrentMid = 0;
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
rc = SMB2_negotiate(xid, ses, server); rc = SMB2_negotiate(xid, ses, server);
return rc; return rc;
} }
@ -4809,18 +4809,18 @@ static void smb2_decrypt_offload(struct work_struct *work)
} else { } else {
spin_lock(&dw->server->srv_lock); spin_lock(&dw->server->srv_lock);
if (dw->server->tcpStatus == CifsNeedReconnect) { if (dw->server->tcpStatus == CifsNeedReconnect) {
spin_lock(&dw->server->mid_lock); spin_lock(&dw->server->mid_queue_lock);
mid->mid_state = MID_RETRY_NEEDED; mid->mid_state = MID_RETRY_NEEDED;
spin_unlock(&dw->server->mid_lock); spin_unlock(&dw->server->mid_queue_lock);
spin_unlock(&dw->server->srv_lock); spin_unlock(&dw->server->srv_lock);
mid->callback(mid); mid->callback(mid);
} else { } else {
spin_lock(&dw->server->mid_lock); spin_lock(&dw->server->mid_queue_lock);
mid->mid_state = MID_REQUEST_SUBMITTED; mid->mid_state = MID_REQUEST_SUBMITTED;
mid->mid_flags &= ~(MID_DELETED); mid->mid_flags &= ~(MID_DELETED);
list_add_tail(&mid->qhead, list_add_tail(&mid->qhead,
&dw->server->pending_mid_q); &dw->server->pending_mid_q);
spin_unlock(&dw->server->mid_lock); spin_unlock(&dw->server->mid_queue_lock);
spin_unlock(&dw->server->srv_lock); spin_unlock(&dw->server->srv_lock);
} }
} }

View File

@ -840,9 +840,9 @@ smb2_get_mid_entry(struct cifs_ses *ses, struct TCP_Server_Info *server,
*mid = smb2_mid_entry_alloc(shdr, server); *mid = smb2_mid_entry_alloc(shdr, server);
if (*mid == NULL) if (*mid == NULL)
return -ENOMEM; return -ENOMEM;
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
list_add_tail(&(*mid)->qhead, &server->pending_mid_q); list_add_tail(&(*mid)->qhead, &server->pending_mid_q);
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
return 0; return 0;
} }

View File

@ -160,12 +160,12 @@ void __release_mid(struct kref *refcount)
void void
delete_mid(struct mid_q_entry *mid) delete_mid(struct mid_q_entry *mid)
{ {
spin_lock(&mid->server->mid_lock); spin_lock(&mid->server->mid_queue_lock);
if (!(mid->mid_flags & MID_DELETED)) { if (!(mid->mid_flags & MID_DELETED)) {
list_del_init(&mid->qhead); list_del_init(&mid->qhead);
mid->mid_flags |= MID_DELETED; mid->mid_flags |= MID_DELETED;
} }
spin_unlock(&mid->server->mid_lock); spin_unlock(&mid->server->mid_queue_lock);
release_mid(mid); release_mid(mid);
} }
@ -716,9 +716,9 @@ static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,
*ppmidQ = alloc_mid(in_buf, ses->server); *ppmidQ = alloc_mid(in_buf, ses->server);
if (*ppmidQ == NULL) if (*ppmidQ == NULL)
return -ENOMEM; return -ENOMEM;
spin_lock(&ses->server->mid_lock); spin_lock(&ses->server->mid_queue_lock);
list_add_tail(&(*ppmidQ)->qhead, &ses->server->pending_mid_q); list_add_tail(&(*ppmidQ)->qhead, &ses->server->pending_mid_q);
spin_unlock(&ses->server->mid_lock); spin_unlock(&ses->server->mid_queue_lock);
return 0; return 0;
} }
@ -819,9 +819,9 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
mid->mid_state = MID_REQUEST_SUBMITTED; mid->mid_state = MID_REQUEST_SUBMITTED;
/* put it on the pending_mid_q */ /* put it on the pending_mid_q */
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
list_add_tail(&mid->qhead, &server->pending_mid_q); list_add_tail(&mid->qhead, &server->pending_mid_q);
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
/* /*
* Need to store the time in mid before calling I/O. For call_async, * Need to store the time in mid before calling I/O. For call_async,
@ -880,10 +880,10 @@ cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server)
cifs_dbg(FYI, "%s: cmd=%d mid=%llu state=%d\n", cifs_dbg(FYI, "%s: cmd=%d mid=%llu state=%d\n",
__func__, le16_to_cpu(mid->command), mid->mid, mid->mid_state); __func__, le16_to_cpu(mid->command), mid->mid, mid->mid_state);
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
switch (mid->mid_state) { switch (mid->mid_state) {
case MID_RESPONSE_READY: case MID_RESPONSE_READY:
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
return rc; return rc;
case MID_RETRY_NEEDED: case MID_RETRY_NEEDED:
rc = -EAGAIN; rc = -EAGAIN;
@ -902,13 +902,13 @@ cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server)
list_del_init(&mid->qhead); list_del_init(&mid->qhead);
mid->mid_flags |= MID_DELETED; mid->mid_flags |= MID_DELETED;
} }
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
cifs_server_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n", cifs_server_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n",
__func__, mid->mid, mid->mid_state); __func__, mid->mid, mid->mid_state);
rc = -EIO; rc = -EIO;
goto sync_mid_done; goto sync_mid_done;
} }
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
sync_mid_done: sync_mid_done:
release_mid(mid); release_mid(mid);
@ -1213,7 +1213,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
cifs_server_dbg(FYI, "Cancelling wait for mid %llu cmd: %d\n", cifs_server_dbg(FYI, "Cancelling wait for mid %llu cmd: %d\n",
midQ[i]->mid, le16_to_cpu(midQ[i]->command)); midQ[i]->mid, le16_to_cpu(midQ[i]->command));
send_cancel(server, &rqst[i], midQ[i]); send_cancel(server, &rqst[i], midQ[i]);
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
midQ[i]->mid_flags |= MID_WAIT_CANCELLED; midQ[i]->mid_flags |= MID_WAIT_CANCELLED;
if (midQ[i]->mid_state == MID_REQUEST_SUBMITTED || if (midQ[i]->mid_state == MID_REQUEST_SUBMITTED ||
midQ[i]->mid_state == MID_RESPONSE_RECEIVED) { midQ[i]->mid_state == MID_RESPONSE_RECEIVED) {
@ -1221,7 +1221,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
cancelled_mid[i] = true; cancelled_mid[i] = true;
credits[i].value = 0; credits[i].value = 0;
} }
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
} }
} }
@ -1423,16 +1423,16 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
rc = wait_for_response(server, midQ); rc = wait_for_response(server, midQ);
if (rc != 0) { if (rc != 0) {
send_cancel(server, &rqst, midQ); send_cancel(server, &rqst, midQ);
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
if (midQ->mid_state == MID_REQUEST_SUBMITTED || if (midQ->mid_state == MID_REQUEST_SUBMITTED ||
midQ->mid_state == MID_RESPONSE_RECEIVED) { midQ->mid_state == MID_RESPONSE_RECEIVED) {
/* no longer considered to be "in-flight" */ /* no longer considered to be "in-flight" */
midQ->callback = release_mid; midQ->callback = release_mid;
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
add_credits(server, &credits, 0); add_credits(server, &credits, 0);
return rc; return rc;
} }
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
} }
rc = cifs_sync_mid_result(midQ, server); rc = cifs_sync_mid_result(midQ, server);
@ -1605,15 +1605,15 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
rc = wait_for_response(server, midQ); rc = wait_for_response(server, midQ);
if (rc) { if (rc) {
send_cancel(server, &rqst, midQ); send_cancel(server, &rqst, midQ);
spin_lock(&server->mid_lock); spin_lock(&server->mid_queue_lock);
if (midQ->mid_state == MID_REQUEST_SUBMITTED || if (midQ->mid_state == MID_REQUEST_SUBMITTED ||
midQ->mid_state == MID_RESPONSE_RECEIVED) { midQ->mid_state == MID_RESPONSE_RECEIVED) {
/* no longer considered to be "in-flight" */ /* no longer considered to be "in-flight" */
midQ->callback = release_mid; midQ->callback = release_mid;
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
return rc; return rc;
} }
spin_unlock(&server->mid_lock); spin_unlock(&server->mid_queue_lock);
} }
/* We got the response - restart system call. */ /* We got the response - restart system call. */