mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 0/7] smb: client: make more mount options take effect on remount
@ 2026-06-16  5:53 rajasimandalos
  2026-06-16  5:53 ` [PATCH v4 1/7] smb: client: sync runtime state into ctx on reconfigure rajasimandalos
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: rajasimandalos @ 2026-06-16  5:53 UTC (permalink / raw)
  To: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM
  Cc: linux-cifs, linux-kernel, Meetakshi Setiya, Rajasi Mandal

From: Rajasi Mandal <rajasimandal@microsoft.com>

Several mount options are accepted by the remount (reconfigure) path but
silently have no effect: the new value is stored in cifs_sb->ctx but never
propagated to the live server/tcon structures, or the option is simply
ignored.  This is confusing -- the user passes an option on
'mount -o remount' and nothing changes, with no error.

This series makes the reconfigure path honest:

  - It first establishes a correct baseline for comparing old vs new
    options on remount by duplicating the live context (with runtime
    state synced in) instead of rebuilding from init defaults.

  - Options that are genuinely reconfigurable (retrans, rasize, nolease)
    are now applied to the running mount.

  - Options that are connection-tied and cannot take effect without
    tearing down the connection (seal, sign, vers, ip, srcaddr, rdma,
    cache=ro/singleclient, etc.) are now explicitly rejected with a clear
    error message instead of being silently dropped.

Patch 1 is preparatory plumbing (duplicate live ctx + sync runtime
state) that makes the simple != comparisons in the rejection checks
sound.  Patches 2 and 4 add the rejection checks.  Patches 3, 5 and 7
apply the reconfigurable options.  Patch 6 is a small no-functional-change
move of struct tcon_list so the nolease patch can reuse it.

Changes since v3:
  - nolease: moved tcon->no_lease out of the bitfield word into a plain
    bool, so propagating it on remount cannot race (via a bitfield
    read-modify-write) with the lockless need_reconnect/need_reopen_files
    writers on the reconnect/reopen paths.
  - srcaddr remount check now uses cifs_match_ipaddr() instead of a raw
    memcmp over sockaddr_storage, matching the adjacent ip check and
    avoiding port/padding fragility.

Rajasi Mandal (7):
  smb: client: sync runtime state into ctx on reconfigure
  smb: client: block non-reconfigurable option changes on remount
  smb: client: sync retrans on remount
  smb: client: block cache=ro and cache=singleclient on remount
  smb: client: apply rasize on remount
  smb: client: move struct tcon_list to cifsglob.h
  smb: client: allow nolease option to be reconfigured on remount

 fs/smb/client/cached_dir.c |  44 +++++
 fs/smb/client/cached_dir.h |   1 +
 fs/smb/client/cifs_swn.h   |  14 +-
 fs/smb/client/cifsglob.h   |   7 +-
 fs/smb/client/fs_context.c | 332 ++++++++++++++++++++++++++++++++++++-
 fs/smb/client/misc.c       |   5 -
 fs/smb/client/smb1ops.c    |   7 +-
 fs/smb/client/smb2pdu.c    |  11 +-
 fs/smb/client/trace.h      |   2 +
 9 files changed, 411 insertions(+), 12 deletions(-)


base-commit: 0eb17dea51eff940230b5e562df29ce457124d41
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v4 1/7] smb: client: sync runtime state into ctx on reconfigure
  2026-06-16  5:53 [PATCH v4 0/7] smb: client: make more mount options take effect on remount rajasimandalos
@ 2026-06-16  5:53 ` rajasimandalos
  2026-06-16  6:44   ` Meetakshi Setiya
  2026-06-16  5:53 ` [PATCH v4 2/7] smb: client: block non-reconfigurable option changes on remount rajasimandalos
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: rajasimandalos @ 2026-06-16  5:53 UTC (permalink / raw)
  To: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM
  Cc: linux-cifs, linux-kernel, Meetakshi Setiya, Rajasi Mandal,
	Meetakshi Setiya

From: Rajasi Mandal <rajasimandal@microsoft.com>

smb3_init_fs_context() builds a fresh context with init defaults on
every call, including reconfigure (remount).  Many fields displayed
by cifs_show_options() are sourced from tcon/server/ses rather than
from ctx, so the init defaults do not reflect the live mount and
cannot be used as a baseline for comparing new vs old options on
remount.

Detect FS_CONTEXT_FOR_RECONFIGURE in smb3_init_fs_context() and
duplicate the existing cifs_sb->ctx instead.  Before duplicating,
sync ctx with runtime state via a new helper
smb3_sync_ctx_from_runtime() so the baseline matches what
cifs_show_options() displays.  Add srv_lock / tc_lock around the
relevant runtime writers (SMB2_negotiate, SMB2_tcon,
reset_cifs_unix_caps, cifs_swn_set_server_dstaddr) so the helper
can read them without torn-read races.

Also preserve inherited multichannel/max_channels values in
smb3_handle_conflicting_options() during reconfigure when neither
option is explicitly specified, since the dup'd context already
carries them.

This is preparatory plumbing for a subsequent commit that compares
new_ctx against old_ctx in smb3_verify_reconfigure_ctx() to reject
non-reconfigurable option changes.

Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>
---
 fs/smb/client/cifs_swn.h   |  14 ++++-
 fs/smb/client/fs_context.c | 111 +++++++++++++++++++++++++++++++++++++
 fs/smb/client/smb1ops.c    |   7 ++-
 fs/smb/client/smb2pdu.c    |  11 +++-
 4 files changed, 139 insertions(+), 4 deletions(-)

diff --git a/fs/smb/client/cifs_swn.h b/fs/smb/client/cifs_swn.h
index 955d07b69450..caf0779d4d07 100644
--- a/fs/smb/client/cifs_swn.h
+++ b/fs/smb/client/cifs_swn.h
@@ -26,11 +26,21 @@ void cifs_swn_check(void);
 
 static inline bool cifs_swn_set_server_dstaddr(struct TCP_Server_Info *server)
 {
+	bool ret = false;
+
+	/*
+	 * srv_lock serializes the 128-byte sockaddr_storage write against
+	 * concurrent readers (e.g. cifs_show_address(), reconn_set_ipaddr_
+	 * from_hostname() snapshot, smb3_sync_ctx_from_runtime()) and other
+	 * writers like cifs_chan_update_iface() which already use srv_lock.
+	 */
+	spin_lock(&server->srv_lock);
 	if (server->use_swn_dstaddr) {
 		server->dstaddr = server->swn_dstaddr;
-		return true;
+		ret = true;
 	}
-	return false;
+	spin_unlock(&server->srv_lock);
+	return ret;
 }
 
 static inline void cifs_swn_reset_server_dstaddr(struct TCP_Server_Info *server)
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index 9addc74ce57e..576a78b6d0cb 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -926,6 +926,81 @@ static void smb3_fs_context_free(struct fs_context *fc)
 	smb3_cleanup_fs_context(ctx);
 }
 
+/*
+ * Sync cifs_sb->ctx with runtime state from tcon/server/ses so the
+ * baseline matches what cifs_show_options() displays.  Wide fields
+ * (dstaddr, ops/vals) are protected by the matching server/tcon lock;
+ * the remaining word-sized scalars rely on the same unsynchronized-read
+ * pattern already used by cifs_show_options().
+ */
+static int smb3_sync_ctx_from_runtime(struct cifs_sb_info *cifs_sb)
+{
+	struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
+	struct TCP_Server_Info *server = tcon->ses->server;
+	struct cifs_ses *ses = tcon->ses;
+	struct smb3_fs_context *ctx = cifs_sb->ctx;
+	const char *domain;
+	int unicode;
+
+	/*
+	 * Server fields that can drift from ctx after mount:
+	 *  - ops/vals: dialect renegotiation during reconnect (paired,
+	 *    so read under srv_lock to match the writer in SMB2_negotiate)
+	 *  - dstaddr: SWN witness failover updates server->dstaddr; the
+	 *    128-byte sockaddr_storage is not atomic, so srv_lock is
+	 *    required against torn reads
+	 *  - nosharesock: can be flipped to true post-mount by SMB2_tcon
+	 *    on STATUS_BAD_NETWORK_NAME with ISOLATED_TRANSPORT, so read
+	 *    under srv_lock to pair with that writer
+	 */
+	spin_lock(&server->srv_lock);
+	ctx->ops = server->ops;
+	ctx->vals = server->vals;
+	ctx->dstaddr = server->dstaddr;
+	ctx->nosharesock = server->nosharesock;
+	spin_unlock(&server->srv_lock);
+
+	/*
+	 * tcon->unix_ext can be flipped post-mount by reset_cifs_unix_caps()
+	 * on SMB1 reconnect (smb1_reconnect path). Read under tc_lock to pair
+	 * with that writer. tcon->posix_extensions is only ever set at
+	 * mount-time pre-publish, but read it under the same lock so the
+	 * derived linux_ext/no_linux_ext pair is consistent.
+	 */
+	spin_lock(&tcon->tc_lock);
+	if (tcon->posix_extensions || tcon->unix_ext) {
+		ctx->linux_ext = 1;
+		ctx->no_linux_ext = 0;
+	} else {
+		ctx->linux_ext = 0;
+		ctx->no_linux_ext = 1;
+	}
+	spin_unlock(&tcon->tc_lock);
+	ctx->seal	  = tcon->seal;
+	ctx->persistent	  = tcon->use_persistent;
+	ctx->nopersistent = !tcon->use_persistent;
+	ctx->resilient	  = tcon->use_resilient;
+	ctx->witness	  = tcon->use_witness;
+
+	/*
+	 * Session fields: domainName and unicode are effectively
+	 * write-once (set during session setup, never freed/replaced
+	 * while the session exists), so plain reads are safe.
+	 */
+	domain = ses->domainName;
+	unicode = ses->unicode;
+
+	if (domain && !ctx->domainname) {
+		ctx->domainname = kstrdup(domain, GFP_KERNEL);
+		if (!ctx->domainname)
+			return -ENOMEM;
+	}
+	if (unicode >= 0)
+		ctx->unicode = unicode;
+
+	return 0;
+}
+
 /*
  * Compare the old and new proposed context during reconfigure
  * and check if the changes are compatible.
@@ -1961,6 +2036,42 @@ int smb3_init_fs_context(struct fs_context *fc)
 	char *nodename = utsname()->nodename;
 	int i;
 
+	/*
+	 * For reconfigure (remount), duplicate the existing mount context
+	 * instead of building one from scratch with init defaults.
+	 *
+	 * VFS sets fc->root before calling init_fs_context for reconfigure,
+	 * so we can access the existing superblock's context.  We first sync
+	 * cifs_sb->ctx with runtime state (tcon/server/ses) so that ctx
+	 * matches what cifs_show_options() displays.  Then we dup old_ctx
+	 * into new_ctx.  The parser will overwrite only the options
+	 * explicitly passed on remount, so any difference between new_ctx
+	 * and old_ctx in smb3_verify_reconfigure_ctx() represents a real,
+	 * intentional change by the user.
+	 */
+	if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) {
+		struct cifs_sb_info *cifs_sb = CIFS_SB(fc->root->d_sb);
+		int rc;
+
+		rc = smb3_sync_ctx_from_runtime(cifs_sb);
+		if (rc)
+			return rc;
+
+		ctx = kzalloc_obj(struct smb3_fs_context);
+		if (!ctx)
+			return -ENOMEM;
+
+		rc = smb3_fs_context_dup(ctx, cifs_sb->ctx);
+		if (rc) {
+			kfree(ctx);
+			return rc;
+		}
+
+		fc->fs_private = ctx;
+		fc->ops = &smb3_fs_context_ops;
+		return 0;
+	}
+
 	ctx = kzalloc_obj(struct smb3_fs_context);
 	if (unlikely(!ctx))
 		return -ENOMEM;
diff --git a/fs/smb/client/smb1ops.c b/fs/smb/client/smb1ops.c
index d34b3d99f6ed..33c890e14988 100644
--- a/fs/smb/client/smb1ops.c
+++ b/fs/smb/client/smb1ops.c
@@ -36,11 +36,16 @@ void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
 
 	if (ctx && ctx->no_linux_ext) {
 		tcon->fsUnixInfo.Capability = 0;
+		spin_lock(&tcon->tc_lock);
 		tcon->unix_ext = 0; /* Unix Extensions disabled */
+		spin_unlock(&tcon->tc_lock);
 		cifs_dbg(FYI, "Linux protocol extensions disabled\n");
 		return;
-	} else if (ctx)
+	} else if (ctx) {
+		spin_lock(&tcon->tc_lock);
 		tcon->unix_ext = 1; /* Unix Extensions supported */
+		spin_unlock(&tcon->tc_lock);
+	}
 
 	if (!tcon->unix_ext) {
 		cifs_dbg(FYI, "Unix extensions disabled so not set on reconnect\n");
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 4972cfe249f6..958ca0753774 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -1189,8 +1189,10 @@ SMB2_negotiate(const unsigned int xid,
 			goto neg_exit;
 		case SMB311_PROT_ID:
 			/* ops set to 3.0 by default for default so update */
+			spin_lock(&server->srv_lock);
 			server->ops = &smb311_operations;
 			server->vals = &smb311_values;
+			spin_unlock(&server->srv_lock);
 			break;
 		default:
 			break;
@@ -1205,12 +1207,16 @@ SMB2_negotiate(const unsigned int xid,
 			goto neg_exit;
 		case SMB21_PROT_ID:
 			/* ops set to 3.0 by default for default so update */
+			spin_lock(&server->srv_lock);
 			server->ops = &smb21_operations;
 			server->vals = &smb21_values;
+			spin_unlock(&server->srv_lock);
 			break;
 		case SMB311_PROT_ID:
+			spin_lock(&server->srv_lock);
 			server->ops = &smb311_operations;
 			server->vals = &smb311_values;
+			spin_unlock(&server->srv_lock);
 			break;
 		default:
 			break;
@@ -2226,8 +2232,11 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
 	if (server->ops->validate_negotiate)
 		rc = server->ops->validate_negotiate(xid, tcon);
 	if (rc == 0) /* See MS-SMB2 2.2.10 and 3.2.5.5 */
-		if (tcon->share_flags & SMB2_SHAREFLAG_ISOLATED_TRANSPORT)
+		if (tcon->share_flags & SMB2_SHAREFLAG_ISOLATED_TRANSPORT) {
+			spin_lock(&server->srv_lock);
 			server->nosharesock = true;
+			spin_unlock(&server->srv_lock);
+		}
 tcon_exit:
 
 	free_rsp_buf(resp_buftype, rsp);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v4 2/7] smb: client: block non-reconfigurable option changes on remount
  2026-06-16  5:53 [PATCH v4 0/7] smb: client: make more mount options take effect on remount rajasimandalos
  2026-06-16  5:53 ` [PATCH v4 1/7] smb: client: sync runtime state into ctx on reconfigure rajasimandalos
@ 2026-06-16  5:53 ` rajasimandalos
  2026-06-16  6:44   ` Meetakshi Setiya
  2026-06-16  5:53 ` [PATCH v4 3/7] smb: client: sync retrans " rajasimandalos
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: rajasimandalos @ 2026-06-16  5:53 UTC (permalink / raw)
  To: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM
  Cc: linux-cifs, linux-kernel, Meetakshi Setiya, Rajasi Mandal,
	Meetakshi Setiya

From: Rajasi Mandal <rajasimandal@microsoft.com>

Several mount options (seal, sign, vers, ip, rdma, nosharesock,
persistent/resilient handles, etc.) require tearing down the
connection to take effect, but smb3_verify_reconfigure_ctx() does
not reject them.  A remount that changes any of these silently
ignores the new value, confusing users.

Now that smb3_init_fs_context() duplicates the live context (with
runtime state synced in) on reconfigure, simple != checks in
smb3_verify_reconfigure_ctx() are sound -- a difference between
new_ctx and old_ctx represents a real, intentional change by the
user rather than a spurious mismatch against init defaults.

Add comprehensive checks for connection-tied options with clear
error messages so the user sees why the remount failed.

Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>
---
 fs/smb/client/fs_context.c | 141 +++++++++++++++++++++++++++++++++++++
 1 file changed, 141 insertions(+)

diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index 576a78b6d0cb..d5a7d4dd402b 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -1070,6 +1070,147 @@ static int smb3_verify_reconfigure_ctx(struct fs_context *fc,
 		cifs_errorf(fc, "can not change nbsessinit during remount\n");
 		return -EINVAL;
 	}
+	if (new_ctx->compress != old_ctx->compress) {
+		cifs_errorf(fc, "can not change compress during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->noblocksnd != old_ctx->noblocksnd) {
+		cifs_errorf(fc, "can not change noblocksend during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->noautotune != old_ctx->noautotune) {
+		cifs_errorf(fc, "can not change noautotune during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->no_sparse != old_ctx->no_sparse) {
+		cifs_errorf(fc, "can not change nosparse during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->nodelete != old_ctx->nodelete) {
+		cifs_errorf(fc, "can not change nodelete during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->cruid_specified &&
+	    !uid_eq(new_ctx->cred_uid, old_ctx->cred_uid)) {
+		cifs_errorf(fc, "can not change cruid during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->port != old_ctx->port) {
+		cifs_errorf(fc, "can not change port during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->min_offload != old_ctx->min_offload) {
+		cifs_errorf(fc, "can not change min_enc_offload during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->echo_interval != old_ctx->echo_interval) {
+		cifs_errorf(fc, "can not change echo_interval during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->snapshot_time != old_ctx->snapshot_time) {
+		cifs_errorf(fc, "can not change snapshot during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->max_credits != old_ctx->max_credits) {
+		cifs_errorf(fc, "can not change max_credits during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->handle_timeout != old_ctx->handle_timeout) {
+		cifs_errorf(fc, "can not change handletimeout during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->got_ip &&
+	    !cifs_match_ipaddr((struct sockaddr *)&new_ctx->dstaddr,
+			       (struct sockaddr *)&old_ctx->dstaddr)) {
+		cifs_errorf(fc, "can not change ip during remount\n");
+		return -EINVAL;
+	}
+	if (!cifs_match_ipaddr((struct sockaddr *)&new_ctx->srcaddr,
+			       (struct sockaddr *)&old_ctx->srcaddr)) {
+		cifs_errorf(fc, "can not change srcaddr during remount\n");
+		return -EINVAL;
+	}
+	if (memcmp(new_ctx->source_rfc1001_name, old_ctx->source_rfc1001_name,
+		   RFC1001_NAME_LEN)) {
+		cifs_errorf(fc, "can not change netbiosname during remount\n");
+		return -EINVAL;
+	}
+	if (memcmp(new_ctx->target_rfc1001_name, old_ctx->target_rfc1001_name,
+		   RFC1001_NAME_LEN)) {
+		cifs_errorf(fc, "can not change servern during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->got_version &&
+	    (new_ctx->ops != old_ctx->ops || new_ctx->vals != old_ctx->vals)) {
+		cifs_errorf(fc, "can not change vers during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->witness != old_ctx->witness) {
+		cifs_errorf(fc, "can not change witness during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->rootfs != old_ctx->rootfs) {
+		cifs_errorf(fc, "can not change rootfs during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->linux_ext != old_ctx->linux_ext ||
+	    new_ctx->no_linux_ext != old_ctx->no_linux_ext) {
+		cifs_errorf(fc, "can not change unix during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->nocase != old_ctx->nocase) {
+		cifs_errorf(fc, "can not change nocase during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->intr != old_ctx->intr) {
+		cifs_errorf(fc, "can not change intr during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->no_psx_acl != old_ctx->no_psx_acl) {
+		cifs_errorf(fc, "can not change acl during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->local_lease != old_ctx->local_lease) {
+		cifs_errorf(fc, "can not change locallease during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->sign != old_ctx->sign) {
+		cifs_errorf(fc, "can not change sign during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->ignore_signature != old_ctx->ignore_signature) {
+		cifs_errorf(fc, "can not change ignore_signature during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->seal != old_ctx->seal) {
+		cifs_errorf(fc, "can not change seal during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->nosharesock != old_ctx->nosharesock) {
+		cifs_errorf(fc, "can not change nosharesock during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->persistent != old_ctx->persistent ||
+	    new_ctx->nopersistent != old_ctx->nopersistent) {
+		cifs_errorf(fc, "can not change persistenthandles during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->resilient != old_ctx->resilient) {
+		cifs_errorf(fc, "can not change resilienthandles during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->sockopt_tcp_nodelay != old_ctx->sockopt_tcp_nodelay) {
+		cifs_errorf(fc, "can not change tcpnodelay during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->domainauto != old_ctx->domainauto) {
+		cifs_errorf(fc, "can not change domainauto during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->rdma != old_ctx->rdma) {
+		cifs_errorf(fc, "can not change rdma during remount\n");
+		return -EINVAL;
+	}
 
 	return 0;
 }
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v4 3/7] smb: client: sync retrans on remount
  2026-06-16  5:53 [PATCH v4 0/7] smb: client: make more mount options take effect on remount rajasimandalos
  2026-06-16  5:53 ` [PATCH v4 1/7] smb: client: sync runtime state into ctx on reconfigure rajasimandalos
  2026-06-16  5:53 ` [PATCH v4 2/7] smb: client: block non-reconfigurable option changes on remount rajasimandalos
@ 2026-06-16  5:53 ` rajasimandalos
  2026-06-16  7:37   ` Meetakshi Setiya
  2026-06-16  5:53 ` [PATCH v4 4/7] smb: client: block cache=ro and cache=singleclient " rajasimandalos
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: rajasimandalos @ 2026-06-16  5:53 UTC (permalink / raw)
  To: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM
  Cc: linux-cifs, linux-kernel, Meetakshi Setiya, Rajasi Mandal,
	Meetakshi Setiya

From: Rajasi Mandal <rajasimandal@microsoft.com>

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@microsoft.com>
Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>
---
 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v4 4/7] smb: client: block cache=ro and cache=singleclient on remount
  2026-06-16  5:53 [PATCH v4 0/7] smb: client: make more mount options take effect on remount rajasimandalos
                   ` (2 preceding siblings ...)
  2026-06-16  5:53 ` [PATCH v4 3/7] smb: client: sync retrans " rajasimandalos
@ 2026-06-16  5:53 ` rajasimandalos
  2026-06-16  7:40   ` Meetakshi Setiya
  2026-06-16  5:53 ` [PATCH v4 5/7] smb: client: apply rasize " rajasimandalos
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: rajasimandalos @ 2026-06-16  5:53 UTC (permalink / raw)
  To: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM
  Cc: linux-cifs, linux-kernel, Meetakshi Setiya, Rajasi Mandal,
	Meetakshi Setiya

From: Rajasi Mandal <rajasimandal@microsoft.com>

cache=ro and cache=singleclient are mount-time environment declarations
where the admin promises that the share is read-only or exclusively
accessed.  The client bypasses server-based coherency (oplocks/leases)
and caches aggressively based on this promise.

These modes were intentionally excluded from smb3_update_mnt_flags()
when it was introduced in commit 2d39f50c2b15 ("cifs: move update of
flags into a separate function") — only cache=strict, cache=none and
cache=loose were made reconfigurable.  However, remount currently
silently accepts cache=ro and cache=singleclient without actually
applying them, which is confusing.

Add explicit checks in smb3_verify_reconfigure_ctx() to reject
attempts to change these options during remount with a clear error
message.

Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>
---
 fs/smb/client/fs_context.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index bfbea0648f6a..659fb0adb528 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -1211,6 +1211,15 @@ static int smb3_verify_reconfigure_ctx(struct fs_context *fc,
 		cifs_errorf(fc, "can not change rdma during remount\n");
 		return -EINVAL;
 	}
+	/* init default: cache_ro = false, cache_rw = false (i.e. cache=strict) */
+	if (new_ctx->cache_ro != old_ctx->cache_ro) {
+		cifs_errorf(fc, "can not change cache=ro during remount\n");
+		return -EINVAL;
+	}
+	if (new_ctx->cache_rw != old_ctx->cache_rw) {
+		cifs_errorf(fc, "can not change cache=singleclient during remount\n");
+		return -EINVAL;
+	}
 
 	return 0;
 }
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v4 5/7] smb: client: apply rasize on remount
  2026-06-16  5:53 [PATCH v4 0/7] smb: client: make more mount options take effect on remount rajasimandalos
                   ` (3 preceding siblings ...)
  2026-06-16  5:53 ` [PATCH v4 4/7] smb: client: block cache=ro and cache=singleclient " rajasimandalos
@ 2026-06-16  5:53 ` rajasimandalos
  2026-06-16  7:41   ` Meetakshi Setiya
  2026-06-16  5:53 ` [PATCH v4 6/7] smb: client: move struct tcon_list to cifsglob.h rajasimandalos
  2026-06-16  5:53 ` [PATCH v4 7/7] smb: client: allow nolease option to be reconfigured on remount rajasimandalos
  6 siblings, 1 reply; 13+ messages in thread
From: rajasimandalos @ 2026-06-16  5:53 UTC (permalink / raw)
  To: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM
  Cc: linux-cifs, linux-kernel, Meetakshi Setiya, Rajasi Mandal,
	Meetakshi Setiya

From: Rajasi Mandal <rajasimandal@microsoft.com>

rasize is accepted during remount parsing but sb->s_bdi->ra_pages is
only set in cifs_read_super() at mount time. A remount with a new
rasize value silently has no effect on the readahead window.

Update ra_pages in smb3_reconfigure() after the context has been
duplicated, using the same logic as cifs_read_super(): if rasize is
set, use it directly; otherwise fall back to 2 * rsize.

Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>
---
 fs/smb/client/fs_context.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index 659fb0adb528..0a72e1089ff7 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -1313,7 +1313,7 @@ static int smb3_reconfigure(struct fs_context *fc)
 	struct dentry *root = fc->root;
 	struct cifs_sb_info *cifs_sb = CIFS_SB(root->d_sb);
 	struct cifs_ses *ses = cifs_sb_master_tcon(cifs_sb)->ses;
-	unsigned int rsize = ctx->rsize, wsize = ctx->wsize;
+	unsigned int rsize = ctx->rsize, wsize = ctx->wsize, rasize = ctx->rasize;
 	char *new_password = NULL, *new_password2 = NULL;
 	bool need_recon = false;
 	bool need_mchan_update;
@@ -1379,9 +1379,10 @@ static int smb3_reconfigure(struct fs_context *fc)
 		STEAL_STRING_SENSITIVE(cifs_sb, ctx, password2);
 	}
 
-	/* if rsize or wsize not passed in on remount, use previous values */
+	/* if rsize, wsize, or rasize not passed in on remount, use previous values */
 	ctx->rsize = rsize ? CIFS_ALIGN_RSIZE(fc, rsize) : cifs_sb->ctx->rsize;
 	ctx->wsize = wsize ? CIFS_ALIGN_WSIZE(fc, wsize) : cifs_sb->ctx->wsize;
+	ctx->rasize = rasize ? rasize : cifs_sb->ctx->rasize;
 
 	new_ctx = kzalloc_obj(*new_ctx);
 	if (!new_ctx) {
@@ -1470,6 +1471,12 @@ static int smb3_reconfigure(struct fs_context *fc)
 	smb3_cleanup_fs_context(old_ctx);
 	old_ctx = NULL;
 	smb3_update_mnt_flags(cifs_sb);
+
+	if (cifs_sb->ctx->rasize)
+		root->d_sb->s_bdi->ra_pages = cifs_sb->ctx->rasize / PAGE_SIZE;
+	else
+		root->d_sb->s_bdi->ra_pages = 2 * (cifs_sb->ctx->rsize / PAGE_SIZE);
+
 #ifdef CONFIG_CIFS_DFS_UPCALL
 	if (!rc)
 		rc = dfs_cache_remount_fs(cifs_sb);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v4 6/7] smb: client: move struct tcon_list to cifsglob.h
  2026-06-16  5:53 [PATCH v4 0/7] smb: client: make more mount options take effect on remount rajasimandalos
                   ` (4 preceding siblings ...)
  2026-06-16  5:53 ` [PATCH v4 5/7] smb: client: apply rasize " rajasimandalos
@ 2026-06-16  5:53 ` rajasimandalos
  2026-06-16  5:53 ` [PATCH v4 7/7] smb: client: allow nolease option to be reconfigured on remount rajasimandalos
  6 siblings, 0 replies; 13+ messages in thread
From: rajasimandalos @ 2026-06-16  5:53 UTC (permalink / raw)
  To: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM
  Cc: linux-cifs, linux-kernel, Meetakshi Setiya, Rajasi Mandal

From: Rajasi Mandal <rajasimandal@microsoft.com>

struct tcon_list is a small list-node wrapper that pairs a list_head
with a cifs_tcon pointer, used to safely iterate tcons under a
superblock outside tlink_tree_lock.

It is currently file-static in misc.c, used only by
cifs_close_all_deferred_files_sb().  Move it next to the similar
struct file_list in cifsglob.h so that other _sb() iteration helpers
can reuse it instead of redefining the same shape locally.

No functional change.

Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
Reviewed-by: Bharath SM <bharathsm@microsoft.com>
---
 fs/smb/client/cifsglob.h | 5 +++++
 fs/smb/client/misc.c     | 5 -----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index a462c1590a9e..38e27ba6d8f6 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -1807,6 +1807,11 @@ struct file_list {
 	struct cifsFileInfo *cfile;
 };
 
+struct tcon_list {
+	struct list_head entry;
+	struct cifs_tcon *tcon;
+};
+
 struct cifs_mount_ctx {
 	struct cifs_sb_info *cifs_sb;
 	struct smb3_fs_context *fs_ctx;
diff --git a/fs/smb/client/misc.c b/fs/smb/client/misc.c
index 0c54b9b79a2c..7ef135dc8268 100644
--- a/fs/smb/client/misc.c
+++ b/fs/smb/client/misc.c
@@ -28,11 +28,6 @@
 #include "fs_context.h"
 #include "cached_dir.h"
 
-struct tcon_list {
-	struct list_head entry;
-	struct cifs_tcon *tcon;
-};
-
 /* The xid serves as a useful identifier for each incoming vfs request,
    in a similar way to the mid which is useful to track each sent smb,
    and CurrentXid can also provide a running counter (although it
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v4 7/7] smb: client: allow nolease option to be reconfigured on remount
  2026-06-16  5:53 [PATCH v4 0/7] smb: client: make more mount options take effect on remount rajasimandalos
                   ` (5 preceding siblings ...)
  2026-06-16  5:53 ` [PATCH v4 6/7] smb: client: move struct tcon_list to cifsglob.h rajasimandalos
@ 2026-06-16  5:53 ` rajasimandalos
  6 siblings, 0 replies; 13+ messages in thread
From: rajasimandalos @ 2026-06-16  5:53 UTC (permalink / raw)
  To: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM
  Cc: linux-cifs, linux-kernel, Meetakshi Setiya, Rajasi Mandal

From: Rajasi Mandal <rajasimandal@microsoft.com>

Changing nolease via remount is silently accepted but has no effect:
the value is not propagated to the live tcons, and stale lease-bearing
state from before the switch keeps using the old behavior.

Make nolease take effect on remount:

 - Add smb3_sync_tcon_opts() which walks the tlink_tree under
   tlink_tree_lock and propagates ctx->no_lease to tcon->no_lease for
   every tcon under this superblock so future opens honor the new
   setting.  Call it from smb3_reconfigure() after the context has
   been updated.

 - On switch to nolease, drop deferred file handles via
   cifs_close_all_deferred_files_sb() (each holds an active lease).

 - On switch to nolease, evict cached directory fids via the new
   invalidate_all_cached_dirs_sb() helper (each holds a directory
   lease).

invalidate_all_cached_dirs_sb() mirrors cifs_close_all_deferred_files_sb():
take tc_count refs on every tcon under tlink_tree_lock, drop the lock,
then call invalidate_all_cached_dirs() per tcon (it can sleep).  Two
new tcon_ref trace tags are added for the audit trail.

Move tcon->no_lease out of the bitfield word into a plain bool.  As a
runtime writer it now shares storage with need_reconnect/need_reopen_files,
which the reconnect/reopen paths update locklessly; a bitfield write is a
read-modify-write of the whole word and could clobber a concurrent
need_reconnect update.  Its own memory location removes that race.

Existing open handles keep their leases until the server breaks them
or userspace closes the file -- nolease only governs new opens.

Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
Reviewed-by: Bharath SM <bharathsm@microsoft.com>
---
 fs/smb/client/cached_dir.c | 44 ++++++++++++++++++++++++++++++++++++++
 fs/smb/client/cached_dir.h |  1 +
 fs/smb/client/cifsglob.h   |  2 +-
 fs/smb/client/fs_context.c | 40 ++++++++++++++++++++++++++++++++++
 fs/smb/client/trace.h      |  2 ++
 5 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c
index 88d5e9a32f28..58d68a8f4d41 100644
--- a/fs/smb/client/cached_dir.c
+++ b/fs/smb/client/cached_dir.c
@@ -637,6 +637,50 @@ void invalidate_all_cached_dirs(struct cifs_tcon *tcon, bool sync)
 		flush_delayed_work(&cfids->laundromat_work);
 }
 
+/*
+ * Invalidate cached directory entries across all tcons under a
+ * superblock.  Collect references on each tcon under tlink_tree_lock,
+ * then call invalidate_all_cached_dirs() outside the spinlock since it
+ * can sleep.  Holding a tc_count reference prevents the tcon from being
+ * freed by tlink_expire_delayed() between dropping the spinlock and
+ * the call.
+ */
+void invalidate_all_cached_dirs_sb(struct cifs_sb_info *cifs_sb)
+{
+	struct rb_root *root = &cifs_sb->tlink_tree;
+	struct rb_node *node;
+	struct cifs_tcon *tcon;
+	struct tcon_link *tlink;
+	struct tcon_list *tmp_list, *q;
+	LIST_HEAD(tcon_head);
+
+	spin_lock(&cifs_sb->tlink_tree_lock);
+	for (node = rb_first(root); node; node = rb_next(node)) {
+		tlink = rb_entry(node, struct tcon_link, tl_rbnode);
+		tcon = tlink_tcon(tlink);
+		if (IS_ERR(tcon))
+			continue;
+		tmp_list = kmalloc_obj(struct tcon_list, GFP_ATOMIC);
+		if (!tmp_list)
+			break;
+		tmp_list->tcon = tcon;
+		spin_lock(&tcon->tc_lock);
+		++tcon->tc_count;
+		trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
+				    netfs_trace_tcon_ref_get_cached_inval_sb);
+		spin_unlock(&tcon->tc_lock);
+		list_add_tail(&tmp_list->entry, &tcon_head);
+	}
+	spin_unlock(&cifs_sb->tlink_tree_lock);
+
+	list_for_each_entry_safe(tmp_list, q, &tcon_head, entry) {
+		invalidate_all_cached_dirs(tmp_list->tcon, true);
+		list_del(&tmp_list->entry);
+		cifs_put_tcon(tmp_list->tcon, netfs_trace_tcon_ref_put_cached_inval_sb);
+		kfree(tmp_list);
+	}
+}
+
 static void
 cached_dir_offload_close(struct work_struct *work)
 {
diff --git a/fs/smb/client/cached_dir.h b/fs/smb/client/cached_dir.h
index fc756836da95..606ba2a0b64f 100644
--- a/fs/smb/client/cached_dir.h
+++ b/fs/smb/client/cached_dir.h
@@ -90,6 +90,7 @@ void close_cached_dir(struct cached_fid *cfid);
 void drop_cached_dir_by_name(const unsigned int xid, struct cifs_tcon *tcon,
 			     const char *name, struct cifs_sb_info *cifs_sb);
 void close_all_cached_dirs(struct cifs_sb_info *cifs_sb);
+void invalidate_all_cached_dirs_sb(struct cifs_sb_info *cifs_sb);
 void invalidate_all_cached_dirs(struct cifs_tcon *tcon, bool sync);
 bool cached_dir_lease_break(struct cifs_tcon *tcon, __u8 lease_key[16]);
 
diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 38e27ba6d8f6..713ca152b0ea 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -1262,9 +1262,9 @@ struct cifs_tcon {
 	bool need_reopen_files:1; /* need to reopen tcon file handles */
 	bool use_resilient:1; /* use resilient instead of durable handles */
 	bool use_persistent:1; /* use persistent instead of durable handles */
-	bool no_lease:1;    /* Do not request leases on files or directories */
 	bool use_witness:1; /* use witness protocol */
 	bool dummy:1; /* dummy tcon used for reconnecting channels */
+	bool no_lease;    /* Do not request leases on files or directories */
 	__le32 capabilities;
 	__u32 share_flags;
 	__u32 maximal_access;
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index 0a72e1089ff7..53f986d8e9e0 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -35,6 +35,7 @@
 #include "nterr.h"
 #include "rfc1002pdu.h"
 #include "fs_context.h"
+#include "cached_dir.h"
 
 DEFINE_MUTEX(cifs_mount_mutex);
 
@@ -1287,6 +1288,43 @@ static void smb3_sync_ses_chan_max(struct cifs_ses *ses, size_t max_channels)
 	spin_unlock(&ses->chan_lock);
 }
 
+/*
+ * Propagate ctx->no_lease to every tcon under this superblock so future
+ * opens honor the new setting after a remount.  When switching to nolease,
+ * also drop deferred file handles and invalidate cached directory fids,
+ * since each holds an active lease from before the switch.
+ *
+ * Existing open handles keep their leases until the server breaks them
+ * or userspace closes the file -- nolease only governs new opens.
+ */
+static void smb3_sync_tcon_opts(struct cifs_sb_info *cifs_sb,
+				struct smb3_fs_context *ctx)
+{
+	struct tcon_link *tlink;
+	struct cifs_tcon *tcon;
+	struct rb_node *node;
+
+	spin_lock(&cifs_sb->tlink_tree_lock);
+	for (node = rb_first(&cifs_sb->tlink_tree); node; node = rb_next(node)) {
+		tlink = rb_entry(node, struct tcon_link, tl_rbnode);
+		tcon = tlink_tcon(tlink);
+		if (IS_ERR(tcon))
+			continue;
+		tcon->no_lease = ctx->no_lease;
+	}
+	spin_unlock(&cifs_sb->tlink_tree_lock);
+
+	/*
+	 * Both _sb() helpers iterate all tcons internally and handle
+	 * their own locking.  They can sleep, so they must be called
+	 * outside tlink_tree_lock.
+	 */
+	if (ctx->no_lease) {
+		cifs_close_all_deferred_files_sb(cifs_sb);
+		invalidate_all_cached_dirs_sb(cifs_sb);
+	}
+}
+
 /*
  * Synchronize server-level options that are stored on TCP_Server_Info
  * at mount time.  These fields are consulted at runtime (retry logic)
@@ -1483,6 +1521,8 @@ static int smb3_reconfigure(struct fs_context *fc)
 #endif
 	if (!rc)
 		smb3_sync_server_opts(cifs_sb);
+	if (!rc)
+		smb3_sync_tcon_opts(cifs_sb, cifs_sb->ctx);
 
 	return rc;
 
diff --git a/fs/smb/client/trace.h b/fs/smb/client/trace.h
index 5b21ad3c15fb..1e61a36759ed 100644
--- a/fs/smb/client/trace.h
+++ b/fs/smb/client/trace.h
@@ -173,6 +173,7 @@
 	EM(netfs_trace_tcon_ref_free_ipc,		"FRE Ipc   ") \
 	EM(netfs_trace_tcon_ref_free_ipc_fail,		"FRE Ipc-F ") \
 	EM(netfs_trace_tcon_ref_free_reconnect_server,	"FRE Reconn") \
+	EM(netfs_trace_tcon_ref_get_cached_inval_sb,	"GET Ch-IvS") \
 	EM(netfs_trace_tcon_ref_get_cached_laundromat,	"GET Ch-Lau") \
 	EM(netfs_trace_tcon_ref_get_cached_lease_break,	"GET Ch-Lea") \
 	EM(netfs_trace_tcon_ref_get_cancelled_close,	"GET Cn-Cls") \
@@ -186,6 +187,7 @@
 	EM(netfs_trace_tcon_ref_new_ipc,		"NEW Ipc   ") \
 	EM(netfs_trace_tcon_ref_new_reconnect_server,	"NEW Reconn") \
 	EM(netfs_trace_tcon_ref_put_cached_close,	"PUT Ch-Cls") \
+	EM(netfs_trace_tcon_ref_put_cached_inval_sb,	"PUT Ch-IvS") \
 	EM(netfs_trace_tcon_ref_put_cancelled_close,	"PUT Cn-Cls") \
 	EM(netfs_trace_tcon_ref_put_cancelled_close_fid, "PUT Cn-Fid") \
 	EM(netfs_trace_tcon_ref_put_cancelled_mid,	"PUT Cn-Mid") \
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 1/7] smb: client: sync runtime state into ctx on reconfigure
  2026-06-16  5:53 ` [PATCH v4 1/7] smb: client: sync runtime state into ctx on reconfigure rajasimandalos
@ 2026-06-16  6:44   ` Meetakshi Setiya
  0 siblings, 0 replies; 13+ messages in thread
From: Meetakshi Setiya @ 2026-06-16  6:44 UTC (permalink / raw)
  To: rajasimandalos
  Cc: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM, linux-cifs, linux-kernel, Rajasi Mandal,
	Meetakshi Setiya

Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>

On Mon, Jun 15, 2026 at 10:54 PM <rajasimandalos@gmail.com> wrote:
>
> From: Rajasi Mandal <rajasimandal@microsoft.com>
>
> smb3_init_fs_context() builds a fresh context with init defaults on
> every call, including reconfigure (remount).  Many fields displayed
> by cifs_show_options() are sourced from tcon/server/ses rather than
> from ctx, so the init defaults do not reflect the live mount and
> cannot be used as a baseline for comparing new vs old options on
> remount.
>
> Detect FS_CONTEXT_FOR_RECONFIGURE in smb3_init_fs_context() and
> duplicate the existing cifs_sb->ctx instead.  Before duplicating,
> sync ctx with runtime state via a new helper
> smb3_sync_ctx_from_runtime() so the baseline matches what
> cifs_show_options() displays.  Add srv_lock / tc_lock around the
> relevant runtime writers (SMB2_negotiate, SMB2_tcon,
> reset_cifs_unix_caps, cifs_swn_set_server_dstaddr) so the helper
> can read them without torn-read races.
>
> Also preserve inherited multichannel/max_channels values in
> smb3_handle_conflicting_options() during reconfigure when neither
> option is explicitly specified, since the dup'd context already
> carries them.
>
> This is preparatory plumbing for a subsequent commit that compares
> new_ctx against old_ctx in smb3_verify_reconfigure_ctx() to reject
> non-reconfigurable option changes.
>
> Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
> Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>
> ---
>  fs/smb/client/cifs_swn.h   |  14 ++++-
>  fs/smb/client/fs_context.c | 111 +++++++++++++++++++++++++++++++++++++
>  fs/smb/client/smb1ops.c    |   7 ++-
>  fs/smb/client/smb2pdu.c    |  11 +++-
>  4 files changed, 139 insertions(+), 4 deletions(-)
>
> diff --git a/fs/smb/client/cifs_swn.h b/fs/smb/client/cifs_swn.h
> index 955d07b69450..caf0779d4d07 100644
> --- a/fs/smb/client/cifs_swn.h
> +++ b/fs/smb/client/cifs_swn.h
> @@ -26,11 +26,21 @@ void cifs_swn_check(void);
>
>  static inline bool cifs_swn_set_server_dstaddr(struct TCP_Server_Info *server)
>  {
> +       bool ret = false;
> +
> +       /*
> +        * srv_lock serializes the 128-byte sockaddr_storage write against
> +        * concurrent readers (e.g. cifs_show_address(), reconn_set_ipaddr_
> +        * from_hostname() snapshot, smb3_sync_ctx_from_runtime()) and other
> +        * writers like cifs_chan_update_iface() which already use srv_lock.
> +        */
> +       spin_lock(&server->srv_lock);
>         if (server->use_swn_dstaddr) {
>                 server->dstaddr = server->swn_dstaddr;
> -               return true;
> +               ret = true;
>         }
> -       return false;
> +       spin_unlock(&server->srv_lock);
> +       return ret;
>  }
>
>  static inline void cifs_swn_reset_server_dstaddr(struct TCP_Server_Info *server)
> diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
> index 9addc74ce57e..576a78b6d0cb 100644
> --- a/fs/smb/client/fs_context.c
> +++ b/fs/smb/client/fs_context.c
> @@ -926,6 +926,81 @@ static void smb3_fs_context_free(struct fs_context *fc)
>         smb3_cleanup_fs_context(ctx);
>  }
>
> +/*
> + * Sync cifs_sb->ctx with runtime state from tcon/server/ses so the
> + * baseline matches what cifs_show_options() displays.  Wide fields
> + * (dstaddr, ops/vals) are protected by the matching server/tcon lock;
> + * the remaining word-sized scalars rely on the same unsynchronized-read
> + * pattern already used by cifs_show_options().
> + */
> +static int smb3_sync_ctx_from_runtime(struct cifs_sb_info *cifs_sb)
> +{
> +       struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
> +       struct TCP_Server_Info *server = tcon->ses->server;
> +       struct cifs_ses *ses = tcon->ses;
> +       struct smb3_fs_context *ctx = cifs_sb->ctx;
> +       const char *domain;
> +       int unicode;
> +
> +       /*
> +        * Server fields that can drift from ctx after mount:
> +        *  - ops/vals: dialect renegotiation during reconnect (paired,
> +        *    so read under srv_lock to match the writer in SMB2_negotiate)
> +        *  - dstaddr: SWN witness failover updates server->dstaddr; the
> +        *    128-byte sockaddr_storage is not atomic, so srv_lock is
> +        *    required against torn reads
> +        *  - nosharesock: can be flipped to true post-mount by SMB2_tcon
> +        *    on STATUS_BAD_NETWORK_NAME with ISOLATED_TRANSPORT, so read
> +        *    under srv_lock to pair with that writer
> +        */
> +       spin_lock(&server->srv_lock);
> +       ctx->ops = server->ops;
> +       ctx->vals = server->vals;
> +       ctx->dstaddr = server->dstaddr;
> +       ctx->nosharesock = server->nosharesock;
> +       spin_unlock(&server->srv_lock);
> +
> +       /*
> +        * tcon->unix_ext can be flipped post-mount by reset_cifs_unix_caps()
> +        * on SMB1 reconnect (smb1_reconnect path). Read under tc_lock to pair
> +        * with that writer. tcon->posix_extensions is only ever set at
> +        * mount-time pre-publish, but read it under the same lock so the
> +        * derived linux_ext/no_linux_ext pair is consistent.
> +        */
> +       spin_lock(&tcon->tc_lock);
> +       if (tcon->posix_extensions || tcon->unix_ext) {
> +               ctx->linux_ext = 1;
> +               ctx->no_linux_ext = 0;
> +       } else {
> +               ctx->linux_ext = 0;
> +               ctx->no_linux_ext = 1;
> +       }
> +       spin_unlock(&tcon->tc_lock);
> +       ctx->seal         = tcon->seal;
> +       ctx->persistent   = tcon->use_persistent;
> +       ctx->nopersistent = !tcon->use_persistent;
> +       ctx->resilient    = tcon->use_resilient;
> +       ctx->witness      = tcon->use_witness;
> +
> +       /*
> +        * Session fields: domainName and unicode are effectively
> +        * write-once (set during session setup, never freed/replaced
> +        * while the session exists), so plain reads are safe.
> +        */
> +       domain = ses->domainName;
> +       unicode = ses->unicode;
> +
> +       if (domain && !ctx->domainname) {
> +               ctx->domainname = kstrdup(domain, GFP_KERNEL);
> +               if (!ctx->domainname)
> +                       return -ENOMEM;
> +       }
> +       if (unicode >= 0)
> +               ctx->unicode = unicode;
> +
> +       return 0;
> +}
> +
>  /*
>   * Compare the old and new proposed context during reconfigure
>   * and check if the changes are compatible.
> @@ -1961,6 +2036,42 @@ int smb3_init_fs_context(struct fs_context *fc)
>         char *nodename = utsname()->nodename;
>         int i;
>
> +       /*
> +        * For reconfigure (remount), duplicate the existing mount context
> +        * instead of building one from scratch with init defaults.
> +        *
> +        * VFS sets fc->root before calling init_fs_context for reconfigure,
> +        * so we can access the existing superblock's context.  We first sync
> +        * cifs_sb->ctx with runtime state (tcon/server/ses) so that ctx
> +        * matches what cifs_show_options() displays.  Then we dup old_ctx
> +        * into new_ctx.  The parser will overwrite only the options
> +        * explicitly passed on remount, so any difference between new_ctx
> +        * and old_ctx in smb3_verify_reconfigure_ctx() represents a real,
> +        * intentional change by the user.
> +        */
> +       if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) {
> +               struct cifs_sb_info *cifs_sb = CIFS_SB(fc->root->d_sb);
> +               int rc;
> +
> +               rc = smb3_sync_ctx_from_runtime(cifs_sb);
> +               if (rc)
> +                       return rc;
> +
> +               ctx = kzalloc_obj(struct smb3_fs_context);
> +               if (!ctx)
> +                       return -ENOMEM;
> +
> +               rc = smb3_fs_context_dup(ctx, cifs_sb->ctx);
> +               if (rc) {
> +                       kfree(ctx);
> +                       return rc;
> +               }
> +
> +               fc->fs_private = ctx;
> +               fc->ops = &smb3_fs_context_ops;
> +               return 0;
> +       }
> +
>         ctx = kzalloc_obj(struct smb3_fs_context);
>         if (unlikely(!ctx))
>                 return -ENOMEM;
> diff --git a/fs/smb/client/smb1ops.c b/fs/smb/client/smb1ops.c
> index d34b3d99f6ed..33c890e14988 100644
> --- a/fs/smb/client/smb1ops.c
> +++ b/fs/smb/client/smb1ops.c
> @@ -36,11 +36,16 @@ void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
>
>         if (ctx && ctx->no_linux_ext) {
>                 tcon->fsUnixInfo.Capability = 0;
> +               spin_lock(&tcon->tc_lock);
>                 tcon->unix_ext = 0; /* Unix Extensions disabled */
> +               spin_unlock(&tcon->tc_lock);
>                 cifs_dbg(FYI, "Linux protocol extensions disabled\n");
>                 return;
> -       } else if (ctx)
> +       } else if (ctx) {
> +               spin_lock(&tcon->tc_lock);
>                 tcon->unix_ext = 1; /* Unix Extensions supported */
> +               spin_unlock(&tcon->tc_lock);
> +       }
>
>         if (!tcon->unix_ext) {
>                 cifs_dbg(FYI, "Unix extensions disabled so not set on reconnect\n");
> diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
> index 4972cfe249f6..958ca0753774 100644
> --- a/fs/smb/client/smb2pdu.c
> +++ b/fs/smb/client/smb2pdu.c
> @@ -1189,8 +1189,10 @@ SMB2_negotiate(const unsigned int xid,
>                         goto neg_exit;
>                 case SMB311_PROT_ID:
>                         /* ops set to 3.0 by default for default so update */
> +                       spin_lock(&server->srv_lock);
>                         server->ops = &smb311_operations;
>                         server->vals = &smb311_values;
> +                       spin_unlock(&server->srv_lock);
>                         break;
>                 default:
>                         break;
> @@ -1205,12 +1207,16 @@ SMB2_negotiate(const unsigned int xid,
>                         goto neg_exit;
>                 case SMB21_PROT_ID:
>                         /* ops set to 3.0 by default for default so update */
> +                       spin_lock(&server->srv_lock);
>                         server->ops = &smb21_operations;
>                         server->vals = &smb21_values;
> +                       spin_unlock(&server->srv_lock);
>                         break;
>                 case SMB311_PROT_ID:
> +                       spin_lock(&server->srv_lock);
>                         server->ops = &smb311_operations;
>                         server->vals = &smb311_values;
> +                       spin_unlock(&server->srv_lock);
>                         break;
>                 default:
>                         break;
> @@ -2226,8 +2232,11 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
>         if (server->ops->validate_negotiate)
>                 rc = server->ops->validate_negotiate(xid, tcon);
>         if (rc == 0) /* See MS-SMB2 2.2.10 and 3.2.5.5 */
> -               if (tcon->share_flags & SMB2_SHAREFLAG_ISOLATED_TRANSPORT)
> +               if (tcon->share_flags & SMB2_SHAREFLAG_ISOLATED_TRANSPORT) {
> +                       spin_lock(&server->srv_lock);
>                         server->nosharesock = true;
> +                       spin_unlock(&server->srv_lock);
> +               }
>  tcon_exit:
>
>         free_rsp_buf(resp_buftype, rsp);
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 2/7] smb: client: block non-reconfigurable option changes on remount
  2026-06-16  5:53 ` [PATCH v4 2/7] smb: client: block non-reconfigurable option changes on remount rajasimandalos
@ 2026-06-16  6:44   ` Meetakshi Setiya
  0 siblings, 0 replies; 13+ messages in thread
From: Meetakshi Setiya @ 2026-06-16  6:44 UTC (permalink / raw)
  To: rajasimandalos
  Cc: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM, linux-cifs, linux-kernel, Rajasi Mandal,
	Meetakshi Setiya

Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>

On Mon, Jun 15, 2026 at 10:54 PM <rajasimandalos@gmail.com> wrote:
>
> From: Rajasi Mandal <rajasimandal@microsoft.com>
>
> Several mount options (seal, sign, vers, ip, rdma, nosharesock,
> persistent/resilient handles, etc.) require tearing down the
> connection to take effect, but smb3_verify_reconfigure_ctx() does
> not reject them.  A remount that changes any of these silently
> ignores the new value, confusing users.
>
> Now that smb3_init_fs_context() duplicates the live context (with
> runtime state synced in) on reconfigure, simple != checks in
> smb3_verify_reconfigure_ctx() are sound -- a difference between
> new_ctx and old_ctx represents a real, intentional change by the
> user rather than a spurious mismatch against init defaults.
>
> Add comprehensive checks for connection-tied options with clear
> error messages so the user sees why the remount failed.
>
> Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
> Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>
> ---
>  fs/smb/client/fs_context.c | 141 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 141 insertions(+)
>
> diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
> index 576a78b6d0cb..d5a7d4dd402b 100644
> --- a/fs/smb/client/fs_context.c
> +++ b/fs/smb/client/fs_context.c
> @@ -1070,6 +1070,147 @@ static int smb3_verify_reconfigure_ctx(struct fs_context *fc,
>                 cifs_errorf(fc, "can not change nbsessinit during remount\n");
>                 return -EINVAL;
>         }
> +       if (new_ctx->compress != old_ctx->compress) {
> +               cifs_errorf(fc, "can not change compress during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->noblocksnd != old_ctx->noblocksnd) {
> +               cifs_errorf(fc, "can not change noblocksend during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->noautotune != old_ctx->noautotune) {
> +               cifs_errorf(fc, "can not change noautotune during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->no_sparse != old_ctx->no_sparse) {
> +               cifs_errorf(fc, "can not change nosparse during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->nodelete != old_ctx->nodelete) {
> +               cifs_errorf(fc, "can not change nodelete during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->cruid_specified &&
> +           !uid_eq(new_ctx->cred_uid, old_ctx->cred_uid)) {
> +               cifs_errorf(fc, "can not change cruid during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->port != old_ctx->port) {
> +               cifs_errorf(fc, "can not change port during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->min_offload != old_ctx->min_offload) {
> +               cifs_errorf(fc, "can not change min_enc_offload during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->echo_interval != old_ctx->echo_interval) {
> +               cifs_errorf(fc, "can not change echo_interval during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->snapshot_time != old_ctx->snapshot_time) {
> +               cifs_errorf(fc, "can not change snapshot during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->max_credits != old_ctx->max_credits) {
> +               cifs_errorf(fc, "can not change max_credits during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->handle_timeout != old_ctx->handle_timeout) {
> +               cifs_errorf(fc, "can not change handletimeout during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->got_ip &&
> +           !cifs_match_ipaddr((struct sockaddr *)&new_ctx->dstaddr,
> +                              (struct sockaddr *)&old_ctx->dstaddr)) {
> +               cifs_errorf(fc, "can not change ip during remount\n");
> +               return -EINVAL;
> +       }
> +       if (!cifs_match_ipaddr((struct sockaddr *)&new_ctx->srcaddr,
> +                              (struct sockaddr *)&old_ctx->srcaddr)) {
> +               cifs_errorf(fc, "can not change srcaddr during remount\n");
> +               return -EINVAL;
> +       }
> +       if (memcmp(new_ctx->source_rfc1001_name, old_ctx->source_rfc1001_name,
> +                  RFC1001_NAME_LEN)) {
> +               cifs_errorf(fc, "can not change netbiosname during remount\n");
> +               return -EINVAL;
> +       }
> +       if (memcmp(new_ctx->target_rfc1001_name, old_ctx->target_rfc1001_name,
> +                  RFC1001_NAME_LEN)) {
> +               cifs_errorf(fc, "can not change servern during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->got_version &&
> +           (new_ctx->ops != old_ctx->ops || new_ctx->vals != old_ctx->vals)) {
> +               cifs_errorf(fc, "can not change vers during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->witness != old_ctx->witness) {
> +               cifs_errorf(fc, "can not change witness during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->rootfs != old_ctx->rootfs) {
> +               cifs_errorf(fc, "can not change rootfs during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->linux_ext != old_ctx->linux_ext ||
> +           new_ctx->no_linux_ext != old_ctx->no_linux_ext) {
> +               cifs_errorf(fc, "can not change unix during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->nocase != old_ctx->nocase) {
> +               cifs_errorf(fc, "can not change nocase during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->intr != old_ctx->intr) {
> +               cifs_errorf(fc, "can not change intr during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->no_psx_acl != old_ctx->no_psx_acl) {
> +               cifs_errorf(fc, "can not change acl during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->local_lease != old_ctx->local_lease) {
> +               cifs_errorf(fc, "can not change locallease during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->sign != old_ctx->sign) {
> +               cifs_errorf(fc, "can not change sign during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->ignore_signature != old_ctx->ignore_signature) {
> +               cifs_errorf(fc, "can not change ignore_signature during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->seal != old_ctx->seal) {
> +               cifs_errorf(fc, "can not change seal during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->nosharesock != old_ctx->nosharesock) {
> +               cifs_errorf(fc, "can not change nosharesock during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->persistent != old_ctx->persistent ||
> +           new_ctx->nopersistent != old_ctx->nopersistent) {
> +               cifs_errorf(fc, "can not change persistenthandles during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->resilient != old_ctx->resilient) {
> +               cifs_errorf(fc, "can not change resilienthandles during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->sockopt_tcp_nodelay != old_ctx->sockopt_tcp_nodelay) {
> +               cifs_errorf(fc, "can not change tcpnodelay during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->domainauto != old_ctx->domainauto) {
> +               cifs_errorf(fc, "can not change domainauto during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->rdma != old_ctx->rdma) {
> +               cifs_errorf(fc, "can not change rdma during remount\n");
> +               return -EINVAL;
> +       }
>
>         return 0;
>  }
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 3/7] smb: client: sync retrans on remount
  2026-06-16  5:53 ` [PATCH v4 3/7] smb: client: sync retrans " rajasimandalos
@ 2026-06-16  7:37   ` Meetakshi Setiya
  0 siblings, 0 replies; 13+ messages in thread
From: Meetakshi Setiya @ 2026-06-16  7:37 UTC (permalink / raw)
  To: rajasimandalos
  Cc: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM, linux-cifs, linux-kernel, Rajasi Mandal,
	Meetakshi Setiya

Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>

On Mon, Jun 15, 2026 at 10:54 PM <rajasimandalos@gmail.com> wrote:
>
> From: Rajasi Mandal <rajasimandal@microsoft.com>
>
> 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@microsoft.com>
> Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>
> ---
>  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
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 4/7] smb: client: block cache=ro and cache=singleclient on remount
  2026-06-16  5:53 ` [PATCH v4 4/7] smb: client: block cache=ro and cache=singleclient " rajasimandalos
@ 2026-06-16  7:40   ` Meetakshi Setiya
  0 siblings, 0 replies; 13+ messages in thread
From: Meetakshi Setiya @ 2026-06-16  7:40 UTC (permalink / raw)
  To: rajasimandalos
  Cc: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM, linux-cifs, linux-kernel, Rajasi Mandal,
	Meetakshi Setiya

Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>

On Mon, Jun 15, 2026 at 10:54 PM <rajasimandalos@gmail.com> wrote:
>
> From: Rajasi Mandal <rajasimandal@microsoft.com>
>
> cache=ro and cache=singleclient are mount-time environment declarations
> where the admin promises that the share is read-only or exclusively
> accessed.  The client bypasses server-based coherency (oplocks/leases)
> and caches aggressively based on this promise.
>
> These modes were intentionally excluded from smb3_update_mnt_flags()
> when it was introduced in commit 2d39f50c2b15 ("cifs: move update of
> flags into a separate function") — only cache=strict, cache=none and
> cache=loose were made reconfigurable.  However, remount currently
> silently accepts cache=ro and cache=singleclient without actually
> applying them, which is confusing.
>
> Add explicit checks in smb3_verify_reconfigure_ctx() to reject
> attempts to change these options during remount with a clear error
> message.
>
> Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
> Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>
> ---
>  fs/smb/client/fs_context.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
> index bfbea0648f6a..659fb0adb528 100644
> --- a/fs/smb/client/fs_context.c
> +++ b/fs/smb/client/fs_context.c
> @@ -1211,6 +1211,15 @@ static int smb3_verify_reconfigure_ctx(struct fs_context *fc,
>                 cifs_errorf(fc, "can not change rdma during remount\n");
>                 return -EINVAL;
>         }
> +       /* init default: cache_ro = false, cache_rw = false (i.e. cache=strict) */
> +       if (new_ctx->cache_ro != old_ctx->cache_ro) {
> +               cifs_errorf(fc, "can not change cache=ro during remount\n");
> +               return -EINVAL;
> +       }
> +       if (new_ctx->cache_rw != old_ctx->cache_rw) {
> +               cifs_errorf(fc, "can not change cache=singleclient during remount\n");
> +               return -EINVAL;
> +       }
>
>         return 0;
>  }
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 5/7] smb: client: apply rasize on remount
  2026-06-16  5:53 ` [PATCH v4 5/7] smb: client: apply rasize " rajasimandalos
@ 2026-06-16  7:41   ` Meetakshi Setiya
  0 siblings, 0 replies; 13+ messages in thread
From: Meetakshi Setiya @ 2026-06-16  7:41 UTC (permalink / raw)
  To: rajasimandalos
  Cc: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Bharath SM, linux-cifs, linux-kernel, Rajasi Mandal,
	Meetakshi Setiya

Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>

On Mon, Jun 15, 2026 at 10:54 PM <rajasimandalos@gmail.com> wrote:
>
> From: Rajasi Mandal <rajasimandal@microsoft.com>
>
> rasize is accepted during remount parsing but sb->s_bdi->ra_pages is
> only set in cifs_read_super() at mount time. A remount with a new
> rasize value silently has no effect on the readahead window.
>
> Update ra_pages in smb3_reconfigure() after the context has been
> duplicated, using the same logic as cifs_read_super(): if rasize is
> set, use it directly; otherwise fall back to 2 * rsize.
>
> Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
> Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>
> ---
>  fs/smb/client/fs_context.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
> index 659fb0adb528..0a72e1089ff7 100644
> --- a/fs/smb/client/fs_context.c
> +++ b/fs/smb/client/fs_context.c
> @@ -1313,7 +1313,7 @@ static int smb3_reconfigure(struct fs_context *fc)
>         struct dentry *root = fc->root;
>         struct cifs_sb_info *cifs_sb = CIFS_SB(root->d_sb);
>         struct cifs_ses *ses = cifs_sb_master_tcon(cifs_sb)->ses;
> -       unsigned int rsize = ctx->rsize, wsize = ctx->wsize;
> +       unsigned int rsize = ctx->rsize, wsize = ctx->wsize, rasize = ctx->rasize;
>         char *new_password = NULL, *new_password2 = NULL;
>         bool need_recon = false;
>         bool need_mchan_update;
> @@ -1379,9 +1379,10 @@ static int smb3_reconfigure(struct fs_context *fc)
>                 STEAL_STRING_SENSITIVE(cifs_sb, ctx, password2);
>         }
>
> -       /* if rsize or wsize not passed in on remount, use previous values */
> +       /* if rsize, wsize, or rasize not passed in on remount, use previous values */
>         ctx->rsize = rsize ? CIFS_ALIGN_RSIZE(fc, rsize) : cifs_sb->ctx->rsize;
>         ctx->wsize = wsize ? CIFS_ALIGN_WSIZE(fc, wsize) : cifs_sb->ctx->wsize;
> +       ctx->rasize = rasize ? rasize : cifs_sb->ctx->rasize;
>
>         new_ctx = kzalloc_obj(*new_ctx);
>         if (!new_ctx) {
> @@ -1470,6 +1471,12 @@ static int smb3_reconfigure(struct fs_context *fc)
>         smb3_cleanup_fs_context(old_ctx);
>         old_ctx = NULL;
>         smb3_update_mnt_flags(cifs_sb);
> +
> +       if (cifs_sb->ctx->rasize)
> +               root->d_sb->s_bdi->ra_pages = cifs_sb->ctx->rasize / PAGE_SIZE;
> +       else
> +               root->d_sb->s_bdi->ra_pages = 2 * (cifs_sb->ctx->rsize / PAGE_SIZE);
> +
>  #ifdef CONFIG_CIFS_DFS_UPCALL
>         if (!rc)
>                 rc = dfs_cache_remount_fs(cifs_sb);
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-06-16  7:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-16  5:53 [PATCH v4 0/7] smb: client: make more mount options take effect on remount rajasimandalos
2026-06-16  5:53 ` [PATCH v4 1/7] smb: client: sync runtime state into ctx on reconfigure rajasimandalos
2026-06-16  6:44   ` Meetakshi Setiya
2026-06-16  5:53 ` [PATCH v4 2/7] smb: client: block non-reconfigurable option changes on remount rajasimandalos
2026-06-16  6:44   ` Meetakshi Setiya
2026-06-16  5:53 ` [PATCH v4 3/7] smb: client: sync retrans " rajasimandalos
2026-06-16  7:37   ` Meetakshi Setiya
2026-06-16  5:53 ` [PATCH v4 4/7] smb: client: block cache=ro and cache=singleclient " rajasimandalos
2026-06-16  7:40   ` Meetakshi Setiya
2026-06-16  5:53 ` [PATCH v4 5/7] smb: client: apply rasize " rajasimandalos
2026-06-16  7:41   ` Meetakshi Setiya
2026-06-16  5:53 ` [PATCH v4 6/7] smb: client: move struct tcon_list to cifsglob.h rajasimandalos
2026-06-16  5:53 ` [PATCH v4 7/7] smb: client: allow nolease option to be reconfigured on remount rajasimandalos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®