From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=144.76.82.148 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796391262; b=XnqCTWiLccLMs2W+0t+69FPmx9xEwiYmaAJxwxd0y+t00Rr2ueHCMkPQVl81xFmY1wJX uddWlimSgD/ty4RDSDHmWOzeat1lMNPUpWqaYOOpGaTa+XtA629NTGFjP5m3Pw094/bWx RcH/d9A2F4x8krXOXKBTWz2u8qdpk84TN5zdQ6F9sxoZF/hF/rLktu5V8Q8gQkXN/z4vq dn4fqvBW02LrOhYKtKx5Uhbwg50lYs0LZIVl7xSdT044QkrjDJg3jvoC9/mPACryw2aak faERm4/thL/lUbgOCw4pyL3IlX27qS5eBFu5NlDdPyFUpoIFafipI1Vwb9LNImH4Cbg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796391262; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=+mTtYHAv+UomztwX1senA8aNJbZGWD3mvRz2y4wrz38=; b=rRLn84Ikdfcez3rYCQVYf6F0AVMgLi2uP2zEraCzOcAU1sX15qwgu80FrU1TA2do79DN MI5XihDriH/b4UliF8wO7XtluQ/vhDHEtT2Wlqq/OPZUZl+M8oxq8o13Npq1DNAj9taBi DSfnZqjMLk9eatwffNCiQRpuONb3E14jsw/Duqf/nxdmwrTAA5NWbzi7ZiOMN4IwkOEC0 VgtnubYnAecYy79k7Eab3doMnSjcF+Wu5oTF80dYx1GMNwg8Cjs/zwZ4KbRSxrE73GXux TJNet3c/DFlp93sb0mtUoY+59jEhbu+Wt7M5gk0uCK1/CJy2T6hvcs+sOmRAq7MNEBg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=samba.org; spf=pass smtp.mailfrom=samba.org; dkim=pass header.d=samba.org header.i=@samba.org header.a=rsa-sha256 header.s=42 header.b=voy9O3KB; arc=none smtp.remote-ip=144.76.82.148 Received: from hr2.samba.org (hr2.samba.org [144.76.82.148]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BAC2606A32F; Fri, 4 Dec 2026 13:34:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5BAC2606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=samba.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samba.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (3072-bit key) header.d=samba.org header.i=@samba.org header.a=rsa-sha256 header.s=42 header.b=voy9O3KB DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=samba.org; s=42; h=Message-ID:Date:Cc:To:From; bh=+mTtYHAv+UomztwX1senA8aNJbZGWD3mvRz2y4wrz38=; b=voy9O3KBg5iyOC/ASE1JEUDCQ9 e/y2TFaiu69fjtXP4guLlgggDQR7JXNccdZ7kqtSCmTdIf2aEJZF4uXPFf6jlw9e1FHVzrEW7mQOX BsLzA5MPhRJ2HcbL+gkoEXKCnGs0dFeH7uB7adXCyS5J9KCFOpJmFFMhkqvZJ3+7eH+EmK5hpSinY +15wNTuJyg9Pt5KgmLnWmL94qDw26QaJMND2US7GgeMpTmKcyeaEmoosArwkGR8Tc2C4igvfp9aMP j0zFE52V016c5TgesFxrZ65Qdnb3OFoLkbHSYOKjBx5LzxgRzvHX83FXDR1Z+2uTfzIlmZfhpDG/2 hjw/N0OaRo6Z52t68NlcuWfld8uxa6XZ0DGMU9qkXZQ5QBNWhtg3EUXqSfX9q9fWyJIJVaeu5SL9j FHYMQad27Dn73Me/da5zNjlBR8Zh1S+PRR7elHjB+4jmIPAtr2pC6C/KlC9SQK//MxMVSX1Z9iM+u VjrXh/HSN8SB6vVsjIbdyK0x; Received: from [127.0.0.2] (localhost [127.0.0.1]) by hr2.samba.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__ECDSA_SECP256R1_SHA256__CHACHA20_POLY1305:256) (Exim) id 1xZTQW-00000000IAW-1XUS; Fri, 04 Dec 2026 13:34:16 +0000 From: Stefan Metzmacher To: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Cc: metze@samba.org, stable@vger.kernel.org, Paulo Alcantara , Namjae Jeon , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Bharath SM , linux-kernel@vger.kernel.org Subject: [PATCH v2 06/12] smb: client: stop waiting between reconnect attempts once the server exits Date: Fri, 4 Dec 2026 14:33:31 +0100 Message-ID: <725faa96858348a800bd58616385309f0cd67dd3.1796391093.git.metze@samba.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, in the new helper cifs_reconnect_wait_before_retry() used by both loops, 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 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c index 97b06d24dfa5..a9531b487e82 100644 --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -393,6 +393,22 @@ static bool cifs_tcp_ses_needs_reconnect(struct TCP_Server_Info *server, int num return true; } +/* + * Wait before the next reconnect attempt, but stop waiting once the + * server is exiting, cifs_put_tcp_session() wakes up response_q after + * setting CifsExiting. + * + * It's not interruptible on purpose, as cifs_reconnect() is also called + * from user processes and a pending signal would remove the delay + * between the attempts. + */ +static void cifs_reconnect_wait_before_retry(struct TCP_Server_Info *server) +{ + wait_event_timeout(server->response_q, + READ_ONCE(server->tcpStatus) != CifsNeedReconnect, + 3 * HZ); +} + /* * cifs tcp session reconnection * @@ -446,7 +462,7 @@ 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); + cifs_reconnect_wait_before_retry(server); } else { atomic_inc(&tcpSesReconnectCount); set_credits(server, 1); @@ -579,7 +595,7 @@ 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); + cifs_reconnect_wait_before_retry(server); continue; } /* @@ -1789,6 +1805,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