[PATCH v4 3/7] smb: client: sync retrans on remount
From: rajasimandalos
Date: Tue Jun 16 2026 - 01:55:56 EST
From: Rajasi Mandal <rajasimandal@xxxxxxxxxxxxx>
The retrans mount option controls how many times the client retries
sending a request before giving up. Although remount already stored
the new value in cifs_sb->ctx, it was never propagated to
server->retrans, so the running connection kept using the old count.
Introduce smb3_sync_server_opts() to push ctx options that live on
TCP_Server_Info into the live server struct after a successful
remount. For now it handles retrans; subsequent patches will extend
it to other server-level knobs.
The previous patch in this series ("smb: client: sync runtime state
into ctx on reconfigure") duplicates the existing context on remount,
so a bare 'mount -o remount' carries the old retrans value forward and
the parser only overwrites it when the user explicitly passes
retrans=N. No special-casing for the bare-remount /proc/mounts replay
is therefore needed; in particular, an explicit retrans=0 from the
user now correctly resets the value to the compile-time default.
Writes to server->retrans are unsynchronized to match the existing
convention: every other reader of the field (smb2ops.c retry path,
cifs_show_options(), the original cifs_get_tcp_session() writer) does
not take server->srv_lock, and match_server() only reads it under
srv_lock as part of the larger match function.
Note that retrans lives on TCP_Server_Info and is therefore shared
across all mounts to the same server; reconfiguring one mount updates
the value seen by every other mount sharing the connection. This is
consistent with the existing semantics: cifs_show_options() already
reads server->retrans for /proc/mounts on every mount, and the
runtime retry path always uses the server's value rather than any
per-mount copy.
Signed-off-by: Rajasi Mandal <rajasimandal@xxxxxxxxxxxxx>
Reviewed-by: Meetakshi Setiya <msetiya@xxxxxxxxxxxxx>
---
fs/smb/client/fs_context.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index d5a7d4dd402b..bfbea0648f6a 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -1278,6 +1278,24 @@ static void smb3_sync_ses_chan_max(struct cifs_ses *ses, size_t max_channels)
spin_unlock(&ses->chan_lock);
}
+/*
+ * Synchronize server-level options that are stored on TCP_Server_Info
+ * at mount time. These fields are consulted at runtime (retry logic)
+ * so remount needs to update the live server struct in addition to
+ * cifs_sb->ctx. Note these live on TCP_Server_Info and are therefore
+ * shared across all mounts to the same server; reconfiguring one mount
+ * updates the value seen by every other mount sharing the connection,
+ * matching how cifs_show_options() and the runtime retry path already
+ * read them unsynchronized from the server struct.
+ */
+static void smb3_sync_server_opts(struct cifs_sb_info *cifs_sb)
+{
+ struct TCP_Server_Info *server = cifs_sb_master_tcon(cifs_sb)->ses->server;
+ struct smb3_fs_context *ctx = cifs_sb->ctx;
+
+ server->retrans = ctx->retrans;
+}
+
static int smb3_reconfigure(struct fs_context *fc)
{
struct smb3_fs_context *ctx = smb3_fc2context(fc);
@@ -1447,6 +1465,8 @@ static int smb3_reconfigure(struct fs_context *fc)
if (!rc)
rc = dfs_cache_remount_fs(cifs_sb);
#endif
+ if (!rc)
+ smb3_sync_server_opts(cifs_sb);
return rc;
--
2.43.0