From: "zhangjian (CG)" <zhangjian496@huawei.com>
To: <stfrench@microsoft.com>, <smfrench@gmail.com>,
<longli@microsoft.com>, <wangzhaolong1@huawei.com>,
<metze@samba.org>, <dhowells@redhat.com>, <pc@manguebit.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-cifs@vger.kernel.org>
Subject: [PATCH] smb: client: fix first failure in negotiation after server reboot
Date: Fri, 13 Jun 2025 18:44:20 +0800 [thread overview]
Message-ID: <a4435153-eb55-4160-9b46-aa937cffa575@huawei.com> (raw)
In-Reply-To: <32686cd5-f149-4ea4-a13f-8b1fbb2cca44@huawei.com>
After fabc4ed200f9, server_unresponsive add a condition to check whether
client need to reconnect depending on server->lstrp. When client failed
to reconnect in 180s, client will abort connection and update server->lstrp
for the last time. In the following scene, server->lstrp is too
old, which may cause failure for the first negotiation.
client | server
-------------------------------------------------------+------------------
mount to cifs server |
ls |
| reboot
stuck for 180s and return EHOSTDOWN |
abort connection and update server->lstrp |
| sleep 21s
| service smb restart
ls |
smb_negotiate |
server_unresponsive cause reconnect [in cifsd] |
( tcpStatus == CifsInNegotiate && |
jiffies > server->lstrp + 20s ) |
cifs_sync_mid_result return EAGAIN |
smb_negotiate return EHOSTDOWN |
ls failed |
The condition (tcpStatus == CifsInNegotiate && jiffies > server->lstrp + 20s)
expect client stay in CifsInNegotiate state for more than 20s. So we update
server->lstrp before last switching into CifsInNegotiate state to avoid
this failure.
Fixes: fabc4ed200f9 ("smb: client: fix hang in wait_for_response() for
negproto")
Signed-off-by: zhangjian <zhangjian496@huawei.com>
---
fs/smb/client/connect.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index 28bc33496..f9aef60f1 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -4193,6 +4193,7 @@ cifs_negotiate_protocol(const unsigned int xid, struct cifs_ses *ses,
return 0;
}
+ server->lstrp = jiffies;
server->tcpStatus = CifsInNegotiate;
spin_unlock(&server->srv_lock);
--
2.33.0
next prev parent reply other threads:[~2025-06-13 10:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-13 10:24 [PATCH] smb: client: fix first failure in negotiation after server reboot zhangjian (CG)
2025-06-13 10:44 ` zhangjian (CG) [this message]
[not found] ` <CAH2r5mshSVCms8hwJepT25jyYmF-qEKFp3mDdwYG1e7nXfs_2g@mail.gmail.com>
[not found] ` <TYPP153MB14907291155DA3320C8F6A909471A@TYPP153MB1490.APCP153.PROD.OUTLOOK.COM>
[not found] ` <186d442d-69db-4a52-b65b-f67370547c45@huawei.com>
2025-06-16 2:15 ` [EXTERNAL] " zhangjian (CG)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a4435153-eb55-4160-9b46-aa937cffa575@huawei.com \
--to=zhangjian496@huawei.com \
--cc=dhowells@redhat.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=metze@samba.org \
--cc=pc@manguebit.org \
--cc=smfrench@gmail.com \
--cc=stfrench@microsoft.com \
--cc=wangzhaolong1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox