cifs_reconnect() and the DFS reconnect loop used msleep(3000) between failed reconnect attempts. Once cifs_put_tcp_session() marks the server as CifsExiting, e.g. during umount, the loop still slept the full 3 seconds before noticing it. The SIGKILL sent to cifsd doesn't interrupt msleep() either. Use wait_event_timeout() on server->response_q instead, so the wait ends as soon as tcpStatus isn't CifsNeedReconnect anymore, and wake up response_q in cifs_put_tcp_session() after setting CifsExiting. It's not interruptible on purpose, as cifs_reconnect() is also called from user processes and a pending signal would otherwise remove the delay between the attempts. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Cc: Paulo Alcantara Cc: Namjae Jeon Cc: Ronnie Sahlberg Cc: Shyam Prasad N Cc: Tom Talpey Cc: Bharath SM Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Stefan Metzmacher --- fs/smb/client/connect.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 064b70bf1fdf..fa2bfab5e77b 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -446,7 +446,13 @@ static int __cifs_reconnect(struct TCP_Server_Info *server, /* If was asked to reconnect only once, do not try it more times */ if (once) break; - msleep(3000); + /* + * Wait before the next try, but stop + * waiting once the server is exiting. + */ + wait_event_timeout(server->response_q, + server->tcpStatus != CifsNeedReconnect, + 3 * HZ); } else { atomic_inc(&tcpSesReconnectCount); set_credits(server, 1); @@ -579,7 +585,13 @@ static int reconnect_dfs_server(struct TCP_Server_Info *server) /* Failed to reconnect socket */ cifs_server_unlock(server); cifs_dbg(FYI, "%s: reconnect error %d\n", __func__, rc); - msleep(3000); + /* + * Wait before the next try, but stop + * waiting once the server is exiting. + */ + wait_event_timeout(server->response_q, + server->tcpStatus != CifsNeedReconnect, + 3 * HZ); continue; } /* @@ -1769,6 +1781,8 @@ cifs_put_tcp_session(struct TCP_Server_Info *server, int from_reconnect) spin_lock(&server->srv_lock); server->tcpStatus = CifsExiting; spin_unlock(&server->srv_lock); + /* stop a reconnect waiting before its next try */ + wake_up_all(&server->response_q); task = xchg(&server->tsk, NULL); if (task) -- 2.43.0