Skip to content

Commit 764da2f

Browse files
Wang ZhaolongSteve French
authored andcommitted
smb: client: Update IO sizes after reconnection
When a SMB connection is reset and reconnected, the negotiated IO parameters (rsize/wsize) can become out of sync with the server's current capabilities. This can lead to suboptimal performance or even IO failures if the server's limits have changed. This patch implements automatic IO size renegotiation: 1. Adds cifs_renegotiate_iosize() function to update all superblocks associated with a tree connection 2. Updates each mount's rsize/wsize based on current server capabilities 3. Calls this function after successful tree connection reconnection With this change, all mount points will automatically maintain optimal and reliable IO parameters after network disruptions, using the bidirectional mapping added in previous patches. This completes the series improving connection resilience by keeping mount parameters synchronized with server capabilities. Signed-off-by: Wang Zhaolong <wangzhaolong1@huawei.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 287906b commit 764da2f

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

fs/smb/client/smb2pdu.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#endif
4444
#include "cached_dir.h"
4545
#include "compress.h"
46+
#include "fs_context.h"
4647

4748
/*
4849
* The following table defines the expected "StructureSize" of SMB2 requests
@@ -4089,6 +4090,24 @@ smb2_echo_callback(struct mid_q_entry *mid)
40894090
add_credits(server, &credits, CIFS_ECHO_OP);
40904091
}
40914092

4093+
static void cifs_renegotiate_iosize(struct TCP_Server_Info *server,
4094+
struct cifs_tcon *tcon)
4095+
{
4096+
struct cifs_sb_info *cifs_sb;
4097+
4098+
if (server == NULL || tcon == NULL)
4099+
return;
4100+
4101+
spin_lock(&tcon->sb_list_lock);
4102+
list_for_each_entry(cifs_sb, &tcon->cifs_sb_list, tcon_sb_link) {
4103+
cifs_sb->ctx->rsize =
4104+
server->ops->negotiate_rsize(tcon, cifs_sb->ctx);
4105+
cifs_sb->ctx->wsize =
4106+
server->ops->negotiate_wsize(tcon, cifs_sb->ctx);
4107+
}
4108+
spin_unlock(&tcon->sb_list_lock);
4109+
}
4110+
40924111
void smb2_reconnect_server(struct work_struct *work)
40934112
{
40944113
struct TCP_Server_Info *server = container_of(work,
@@ -4174,9 +4193,10 @@ void smb2_reconnect_server(struct work_struct *work)
41744193

41754194
list_for_each_entry_safe(tcon, tcon2, &tmp_list, rlist) {
41764195
rc = smb2_reconnect(SMB2_INTERNAL_CMD, tcon, server, true);
4177-
if (!rc)
4196+
if (!rc) {
4197+
cifs_renegotiate_iosize(server, tcon);
41784198
cifs_reopen_persistent_handles(tcon);
4179-
else
4199+
} else
41804200
resched = true;
41814201
list_del_init(&tcon->rlist);
41824202
if (tcon->ipc)

0 commit comments

Comments
 (0)