aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLong Li <longli@microsoft.com>2019-05-14 00:01:28 -0400
committerSteve French <stfrench@microsoft.com>2019-05-14 17:48:55 -0400
commit1d2a4f57cebdab1d496b976a1e6ea998dc9b03c8 (patch)
treed70c32ee5ccab2c2e3ceebca8232771d441fed42
parent14e25977f98887f1f99c3ce7537a7674aab3cbdd (diff)
cifs:smbd When reconnecting to server, call smbd_destroy() after all MIDs have been called
commit 214bab448476 ("cifs: Call MID callback before destroying transport") assumes that the MID callback should not take srv_mutex, this may not always be true. SMB Direct requires the MID callback completed before calling transport so all pending memory registration can be freed. So restore the original calling sequence so TCP transport will use the same code, but moving smbd_destroy() after all MID has been called. fixes: 214bab448476 ("cifs: Call MID callback before destroying transport") Signed-off-by: Long Li <longli@microsoft.com> Signed-off-by: Steve French <stfrench@microsoft.com> Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
-rw-r--r--fs/cifs/connect.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 084756cfdaee..0b3ac8b76d18 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -528,6 +528,21 @@ cifs_reconnect(struct TCP_Server_Info *server)
528 /* do not want to be sending data on a socket we are freeing */ 528 /* do not want to be sending data on a socket we are freeing */
529 cifs_dbg(FYI, "%s: tearing down socket\n", __func__); 529 cifs_dbg(FYI, "%s: tearing down socket\n", __func__);
530 mutex_lock(&server->srv_mutex); 530 mutex_lock(&server->srv_mutex);
531 if (server->ssocket) {
532 cifs_dbg(FYI, "State: 0x%x Flags: 0x%lx\n",
533 server->ssocket->state, server->ssocket->flags);
534 kernel_sock_shutdown(server->ssocket, SHUT_WR);
535 cifs_dbg(FYI, "Post shutdown state: 0x%x Flags: 0x%lx\n",
536 server->ssocket->state, server->ssocket->flags);
537 sock_release(server->ssocket);
538 server->ssocket = NULL;
539 }
540 server->sequence_number = 0;
541 server->session_estab = false;
542 kfree(server->session_key.response);
543 server->session_key.response = NULL;
544 server->session_key.len = 0;
545 server->lstrp = jiffies;
531 546
532 /* mark submitted MIDs for retry and issue callback */ 547 /* mark submitted MIDs for retry and issue callback */
533 INIT_LIST_HEAD(&retry_list); 548 INIT_LIST_HEAD(&retry_list);
@@ -540,6 +555,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
540 list_move(&mid_entry->qhead, &retry_list); 555 list_move(&mid_entry->qhead, &retry_list);
541 } 556 }
542 spin_unlock(&GlobalMid_Lock); 557 spin_unlock(&GlobalMid_Lock);
558 mutex_unlock(&server->srv_mutex);
543 559
544 cifs_dbg(FYI, "%s: issuing mid callbacks\n", __func__); 560 cifs_dbg(FYI, "%s: issuing mid callbacks\n", __func__);
545 list_for_each_safe(tmp, tmp2, &retry_list) { 561 list_for_each_safe(tmp, tmp2, &retry_list) {
@@ -548,24 +564,11 @@ cifs_reconnect(struct TCP_Server_Info *server)
548 mid_entry->callback(mid_entry); 564 mid_entry->callback(mid_entry);
549 } 565 }
550 566
551 if (server->ssocket) { 567 if (cifs_rdma_enabled(server)) {
552 cifs_dbg(FYI, "State: 0x%x Flags: 0x%lx\n", 568 mutex_lock(&server->srv_mutex);
553 server->ssocket->state, server->ssocket->flags);
554 kernel_sock_shutdown(server->ssocket, SHUT_WR);
555 cifs_dbg(FYI, "Post shutdown state: 0x%x Flags: 0x%lx\n",
556 server->ssocket->state, server->ssocket->flags);
557 sock_release(server->ssocket);
558 server->ssocket = NULL;
559 } else if (cifs_rdma_enabled(server))
560 smbd_destroy(server); 569 smbd_destroy(server);
561 server->sequence_number = 0; 570 mutex_unlock(&server->srv_mutex);
562 server->session_estab = false; 571 }
563 kfree(server->session_key.response);
564 server->session_key.response = NULL;
565 server->session_key.len = 0;
566 server->lstrp = jiffies;
567
568 mutex_unlock(&server->srv_mutex);
569 572
570 do { 573 do {
571 try_to_freeze(); 574 try_to_freeze();