* [PATCH 2/9] smb: client: allow both 'lease' and 'nolease' mount options
2026-04-09 9:59 [PATCH 1/9] smb: client: block non-reconfigurable option changes on remount rajasimandalos
@ 2026-04-09 9:59 ` rajasimandalos
2026-04-13 13:30 ` Meetakshi Setiya
2026-04-09 9:59 ` [PATCH 3/9] smb: client: sync tcon-level options on remount rajasimandalos
` (6 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: rajasimandalos @ 2026-04-09 9:59 UTC (permalink / raw)
To: sfrench, linux-cifs
Cc: pc, ronniesahlberg, sprasad, tom, metze, bharathsm,
samba-technical, linux-kernel, Rajasi Mandal
From: Rajasi Mandal <rajasimandal@microsoft.com>
Change the nolease mount option from fsparam_flag() to fsparam_flag_no()
so that both 'lease' and 'nolease' are accepted as valid mount options.
Previously, only 'nolease' was recognized. Passing 'lease' would fail
with an unknown parameter error (or be silently ignored with 'sloppy').
With this change:
- 'nolease' disables lease requests (same behavior as before)
- 'lease' explicitly enables lease requests
This also renames the enum value from Opt_nolease to Opt_lease and uses
result.negated to set ctx->no_lease, which is the standard pattern used
by other flag_no options in the cifs mount option parser.
Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
---
fs/smb/client/fs_context.c | 6 +++---
fs/smb/client/fs_context.h | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index 0f6c1eb8e274..e1bf7bad5be6 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -80,7 +80,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {
fsparam_flag_no("forcegid", Opt_forcegid),
fsparam_flag("noblocksend", Opt_noblocksend),
fsparam_flag("noautotune", Opt_noautotune),
- fsparam_flag("nolease", Opt_nolease),
+ fsparam_flag_no("lease", Opt_lease),
fsparam_flag_no("hard", Opt_hard),
fsparam_flag_no("soft", Opt_soft),
fsparam_flag_no("perm", Opt_perm),
@@ -1572,8 +1572,8 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
case Opt_noautotune:
ctx->noautotune = 1;
break;
- case Opt_nolease:
- ctx->no_lease = 1;
+ case Opt_lease:
+ ctx->no_lease = result.negated;
break;
case Opt_nosparse:
ctx->no_sparse = 1;
diff --git a/fs/smb/client/fs_context.h b/fs/smb/client/fs_context.h
index 0b64fcb5d302..a80a5caff23c 100644
--- a/fs/smb/client/fs_context.h
+++ b/fs/smb/client/fs_context.h
@@ -102,7 +102,7 @@ enum cifs_param {
Opt_forcegid,
Opt_noblocksend,
Opt_noautotune,
- Opt_nolease,
+ Opt_lease,
Opt_nosparse,
Opt_hard,
Opt_soft,
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 2/9] smb: client: allow both 'lease' and 'nolease' mount options
2026-04-09 9:59 ` [PATCH 2/9] smb: client: allow both 'lease' and 'nolease' mount options rajasimandalos
@ 2026-04-13 13:30 ` Meetakshi Setiya
0 siblings, 0 replies; 14+ messages in thread
From: Meetakshi Setiya @ 2026-04-13 13:30 UTC (permalink / raw)
To: rajasimandalos
Cc: sfrench, linux-cifs, pc, ronniesahlberg, sprasad, tom, metze,
bharathsm, samba-technical, linux-kernel, Rajasi Mandal
Reviewed-by: Meetakshi Setiya <msetiya@microsoft.com>
On Thu, Apr 9, 2026 at 3:07 AM <rajasimandalos@gmail.com> wrote:
>
> From: Rajasi Mandal <rajasimandal@microsoft.com>
>
> Change the nolease mount option from fsparam_flag() to fsparam_flag_no()
> so that both 'lease' and 'nolease' are accepted as valid mount options.
>
> Previously, only 'nolease' was recognized. Passing 'lease' would fail
> with an unknown parameter error (or be silently ignored with 'sloppy').
>
> With this change:
> - 'nolease' disables lease requests (same behavior as before)
> - 'lease' explicitly enables lease requests
>
> This also renames the enum value from Opt_nolease to Opt_lease and uses
> result.negated to set ctx->no_lease, which is the standard pattern used
> by other flag_no options in the cifs mount option parser.
>
> Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
> ---
> fs/smb/client/fs_context.c | 6 +++---
> fs/smb/client/fs_context.h | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
> index 0f6c1eb8e274..e1bf7bad5be6 100644
> --- a/fs/smb/client/fs_context.c
> +++ b/fs/smb/client/fs_context.c
> @@ -80,7 +80,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {
> fsparam_flag_no("forcegid", Opt_forcegid),
> fsparam_flag("noblocksend", Opt_noblocksend),
> fsparam_flag("noautotune", Opt_noautotune),
> - fsparam_flag("nolease", Opt_nolease),
> + fsparam_flag_no("lease", Opt_lease),
> fsparam_flag_no("hard", Opt_hard),
> fsparam_flag_no("soft", Opt_soft),
> fsparam_flag_no("perm", Opt_perm),
> @@ -1572,8 +1572,8 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
> case Opt_noautotune:
> ctx->noautotune = 1;
> break;
> - case Opt_nolease:
> - ctx->no_lease = 1;
> + case Opt_lease:
> + ctx->no_lease = result.negated;
> break;
> case Opt_nosparse:
> ctx->no_sparse = 1;
> diff --git a/fs/smb/client/fs_context.h b/fs/smb/client/fs_context.h
> index 0b64fcb5d302..a80a5caff23c 100644
> --- a/fs/smb/client/fs_context.h
> +++ b/fs/smb/client/fs_context.h
> @@ -102,7 +102,7 @@ enum cifs_param {
> Opt_forcegid,
> Opt_noblocksend,
> Opt_noautotune,
> - Opt_nolease,
> + Opt_lease,
> Opt_nosparse,
> Opt_hard,
> Opt_soft,
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 3/9] smb: client: sync tcon-level options on remount
2026-04-09 9:59 [PATCH 1/9] smb: client: block non-reconfigurable option changes on remount rajasimandalos
2026-04-09 9:59 ` [PATCH 2/9] smb: client: allow both 'lease' and 'nolease' mount options rajasimandalos
@ 2026-04-09 9:59 ` rajasimandalos
2026-04-17 14:29 ` Meetakshi Setiya
2026-04-09 9:59 ` [PATCH 4/9] smb: client: sync retrans " rajasimandalos
` (5 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: rajasimandalos @ 2026-04-09 9:59 UTC (permalink / raw)
To: sfrench, linux-cifs
Cc: pc, ronniesahlberg, sprasad, tom, metze, bharathsm,
samba-technical, linux-kernel, Rajasi Mandal
From: Rajasi Mandal <rajasimandal@microsoft.com>
Several mount options are stored on each cifs_tcon at mount time but
smb3_reconfigure() only updates cifs_sb->ctx. A remount that changes
any of these options silently has no effect because the runtime code
reads from the tcon fields, not from the superblock context.
The affected options and their tcon fields are:
retry -> tcon->retry
max_cached_dirs -> tcon->max_cached_dirs
Add smb3_sync_tcon_opts() which walks the tlink_tree under
tlink_tree_lock and propagates these values from ctx to every tcon
under tc_lock. Call it from smb3_reconfigure() after the context has
been updated.
Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
---
fs/smb/client/fs_context.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index e1bf7bad5be6..90e83f07c870 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -1307,6 +1307,35 @@ static void smb3_sync_ses_chan_max(struct cifs_ses *ses, unsigned int max_channe
spin_unlock(&ses->chan_lock);
}
+/*
+ * Synchronize tcon options that are derived from ctx across all tcons
+ * associated with this superblock. These fields are consulted at runtime
+ * (reconnect, I/O, unlink/rmdir) so remount needs to update the live
+ * tcons in addition to cifs_sb->ctx.
+ */
+static void smb3_sync_tcon_opts(struct cifs_sb_info *cifs_sb,
+ struct smb3_fs_context *ctx)
+{
+ struct rb_node *node;
+
+ spin_lock(&cifs_sb->tlink_tree_lock);
+ for (node = rb_first(&cifs_sb->tlink_tree); node; node = rb_next(node)) {
+ struct tcon_link *tlink;
+ struct cifs_tcon *tcon;
+
+ tlink = rb_entry(node, struct tcon_link, tl_rbnode);
+ tcon = tlink_tcon(tlink);
+ if (IS_ERR_OR_NULL(tcon))
+ continue;
+
+ spin_lock(&tcon->tc_lock);
+ tcon->retry = ctx->retry;
+ tcon->max_cached_dirs = ctx->max_cached_dirs;
+ spin_unlock(&tcon->tc_lock);
+ }
+ spin_unlock(&cifs_sb->tlink_tree_lock);
+}
+
static int smb3_reconfigure(struct fs_context *fc)
{
struct smb3_fs_context *ctx = smb3_fc2context(fc);
@@ -1444,6 +1473,8 @@ static int smb3_reconfigure(struct fs_context *fc)
if (!rc)
rc = dfs_cache_remount_fs(cifs_sb);
#endif
+ if (!rc)
+ smb3_sync_tcon_opts(cifs_sb, cifs_sb->ctx);
return rc;
}
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 3/9] smb: client: sync tcon-level options on remount
2026-04-09 9:59 ` [PATCH 3/9] smb: client: sync tcon-level options on remount rajasimandalos
@ 2026-04-17 14:29 ` Meetakshi Setiya
0 siblings, 0 replies; 14+ messages in thread
From: Meetakshi Setiya @ 2026-04-17 14:29 UTC (permalink / raw)
To: rajasimandalos
Cc: sfrench, linux-cifs, pc, ronniesahlberg, sprasad, tom, metze,
bharathsm, samba-technical, linux-kernel, Rajasi Mandal
Hi Rajasi,
Some nits:
On Thu, Apr 9, 2026 at 3:03 AM <rajasimandalos@gmail.com> wrote:
>
> From: Rajasi Mandal <rajasimandal@microsoft.com>
>
> Several mount options are stored on each cifs_tcon at mount time but
> smb3_reconfigure() only updates cifs_sb->ctx. A remount that changes
> any of these options silently has no effect because the runtime code
> reads from the tcon fields, not from the superblock context.
>
> The affected options and their tcon fields are:
> retry -> tcon->retry
> max_cached_dirs -> tcon->max_cached_dirs
>
> Add smb3_sync_tcon_opts() which walks the tlink_tree under
> tlink_tree_lock and propagates these values from ctx to every tcon
> under tc_lock. Call it from smb3_reconfigure() after the context has
> been updated.
>
> Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
> ---
> fs/smb/client/fs_context.c | 31 +++++++++++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
> index e1bf7bad5be6..90e83f07c870 100644
> --- a/fs/smb/client/fs_context.c
> +++ b/fs/smb/client/fs_context.c
> @@ -1307,6 +1307,35 @@ static void smb3_sync_ses_chan_max(struct cifs_ses *ses, unsigned int max_channe
> spin_unlock(&ses->chan_lock);
> }
>
> +/*
> + * Synchronize tcon options that are derived from ctx across all tcons
> + * associated with this superblock. These fields are consulted at runtime
> + * (reconnect, I/O, unlink/rmdir) so remount needs to update the live
> + * tcons in addition to cifs_sb->ctx.
> + */
> +static void smb3_sync_tcon_opts(struct cifs_sb_info *cifs_sb,
> + struct smb3_fs_context *ctx)
> +{
> + struct rb_node *node;
> +
> + spin_lock(&cifs_sb->tlink_tree_lock);
> + for (node = rb_first(&cifs_sb->tlink_tree); node; node = rb_next(node)) {
> + struct tcon_link *tlink;
> + struct cifs_tcon *tcon;
Maybe declare these outside the loop?
> +
> + tlink = rb_entry(node, struct tcon_link, tl_rbnode);
> + tcon = tlink_tcon(tlink);
> + if (IS_ERR_OR_NULL(tcon))
> + continue;
> +
> + spin_lock(&tcon->tc_lock);
> + tcon->retry = ctx->retry;
> + tcon->max_cached_dirs = ctx->max_cached_dirs;
Would be good to add a comment that this will not resize the existing
cached dirents.
> + spin_unlock(&tcon->tc_lock);
> + }
> + spin_unlock(&cifs_sb->tlink_tree_lock);
> +}
> +
> static int smb3_reconfigure(struct fs_context *fc)
> {
> struct smb3_fs_context *ctx = smb3_fc2context(fc);
> @@ -1444,6 +1473,8 @@ static int smb3_reconfigure(struct fs_context *fc)
> if (!rc)
> rc = dfs_cache_remount_fs(cifs_sb);
> #endif
> + if (!rc)
> + smb3_sync_tcon_opts(cifs_sb, cifs_sb->ctx);
>
> return rc;
> }
> --
> 2.43.0
>
>
Other than that, it looks good to me.
Thanks
Meetakshi
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 4/9] smb: client: sync retrans on remount
2026-04-09 9:59 [PATCH 1/9] smb: client: block non-reconfigurable option changes on remount rajasimandalos
2026-04-09 9:59 ` [PATCH 2/9] smb: client: allow both 'lease' and 'nolease' mount options rajasimandalos
2026-04-09 9:59 ` [PATCH 3/9] smb: client: sync tcon-level options on remount rajasimandalos
@ 2026-04-09 9:59 ` rajasimandalos
2026-04-09 9:59 ` [PATCH 5/9] smb: client: sync echo_interval " rajasimandalos
` (4 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: rajasimandalos @ 2026-04-09 9:59 UTC (permalink / raw)
To: sfrench, linux-cifs
Cc: pc, ronniesahlberg, sprasad, tom, metze, bharathsm,
samba-technical, linux-kernel, Rajasi Mandal
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 assignment is guarded (if ctx->retrans) so that a bare
'mount -o remount' (which re-parses /proc/mounts and gets
retrans=0 because cifs_show_options does not print it) does not
accidentally reset the value to zero.
Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
---
fs/smb/client/fs_context.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index 90e83f07c870..31b82f8f7ead 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -1336,6 +1336,21 @@ static void smb3_sync_tcon_opts(struct cifs_sb_info *cifs_sb,
spin_unlock(&cifs_sb->tlink_tree_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.
+ */
+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;
+
+ if (ctx->retrans)
+ server->retrans = ctx->retrans;
+}
+
static int smb3_reconfigure(struct fs_context *fc)
{
struct smb3_fs_context *ctx = smb3_fc2context(fc);
@@ -1475,6 +1490,8 @@ static int smb3_reconfigure(struct fs_context *fc)
#endif
if (!rc)
smb3_sync_tcon_opts(cifs_sb, cifs_sb->ctx);
+ if (!rc)
+ smb3_sync_server_opts(cifs_sb);
return rc;
}
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 5/9] smb: client: sync echo_interval on remount
2026-04-09 9:59 [PATCH 1/9] smb: client: block non-reconfigurable option changes on remount rajasimandalos
` (2 preceding siblings ...)
2026-04-09 9:59 ` [PATCH 4/9] smb: client: sync retrans " rajasimandalos
@ 2026-04-09 9:59 ` rajasimandalos
2026-04-09 9:59 ` [PATCH 6/9] smb: client: allow nolease option to be reconfigured " rajasimandalos
` (3 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: rajasimandalos @ 2026-04-09 9:59 UTC (permalink / raw)
To: sfrench, linux-cifs
Cc: pc, ronniesahlberg, sprasad, tom, metze, bharathsm,
samba-technical, linux-kernel, Rajasi Mandal
From: Rajasi Mandal <rajasimandal@microsoft.com>
Add echo_interval handling to smb3_sync_server_opts() so that
changing echo_interval via remount actually takes effect on the
running connection.
The server echo worker fires every server->echo_interval jiffies,
but that field was never updated from cifs_sb->ctx on remount.
Convert the user-supplied seconds value to jiffies and reschedule
the echo worker with mod_delayed_work() so the new interval is
picked up immediately.
The assignment is guarded (if ctx->echo_interval) so that an
explicit echo_interval=0 does not accidentally reset the interval.
Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
---
fs/smb/client/fs_context.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index 31b82f8f7ead..5f0637035172 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -1338,9 +1338,9 @@ static void smb3_sync_tcon_opts(struct cifs_sb_info *cifs_sb,
/*
* 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.
+ * at mount time. These fields are consulted at runtime (echo work,
+ * retry logic) so remount needs to update the live server struct in
+ * addition to cifs_sb->ctx.
*/
static void smb3_sync_server_opts(struct cifs_sb_info *cifs_sb)
{
@@ -1349,6 +1349,11 @@ static void smb3_sync_server_opts(struct cifs_sb_info *cifs_sb)
if (ctx->retrans)
server->retrans = ctx->retrans;
+ if (ctx->echo_interval) {
+ server->echo_interval = ctx->echo_interval * HZ;
+ mod_delayed_work(cifsiod_wq, &server->echo,
+ server->echo_interval);
+ }
}
static int smb3_reconfigure(struct fs_context *fc)
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 6/9] smb: client: allow nolease option to be reconfigured on remount
2026-04-09 9:59 [PATCH 1/9] smb: client: block non-reconfigurable option changes on remount rajasimandalos
` (3 preceding siblings ...)
2026-04-09 9:59 ` [PATCH 5/9] smb: client: sync echo_interval " rajasimandalos
@ 2026-04-09 9:59 ` rajasimandalos
2026-04-09 9:59 ` [PATCH 7/9] smb: client: block cache=ro and cache=singleclient " rajasimandalos
` (2 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: rajasimandalos @ 2026-04-09 9:59 UTC (permalink / raw)
To: sfrench, linux-cifs
Cc: pc, ronniesahlberg, sprasad, tom, metze, bharathsm,
samba-technical, linux-kernel, Rajasi Mandal
From: Rajasi Mandal <rajasimandal@microsoft.com>
The nolease mount option (tcon->no_lease) controls whether the client
requests oplocks/leases from the server during SMB2 opens. Previously,
changing this option via remount was silently accepted but had no effect
because the value was never synced from the updated ctx to the live tcon.
Add no_lease to smb3_sync_tcon_opts() so the flag is propagated to all
tcons on remount, matching the pattern used by retry, nodelete, and
max_cached_dirs.
When switching to nolease, also close all deferred file handles via
cifs_close_all_deferred_files(). Deferred handles retain their
original lease from the previous open; without closing them, a
subsequent open would reuse the cached handle and inherit the stale
lease, preventing nolease from taking effect.
Both transitions are safe:
- lease -> nolease: deferred handles are force-closed, and future
opens get OPLOCK_LEVEL_NONE.
- nolease -> lease: future opens will request leases; existing
uncached files remain uncached until reopened.
On reconnect, cifs_reopen_file() reads the current tcon->no_lease and
the server grants (or not) accordingly, so the per-inode cache state
is naturally updated.
Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
---
fs/smb/client/fs_context.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index 5f0637035172..ce4842e778c4 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -1330,8 +1330,12 @@ static void smb3_sync_tcon_opts(struct cifs_sb_info *cifs_sb,
spin_lock(&tcon->tc_lock);
tcon->retry = ctx->retry;
+ tcon->no_lease = ctx->no_lease;
tcon->max_cached_dirs = ctx->max_cached_dirs;
spin_unlock(&tcon->tc_lock);
+
+ if (ctx->no_lease)
+ cifs_close_all_deferred_files(tcon);
}
spin_unlock(&cifs_sb->tlink_tree_lock);
}
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 7/9] smb: client: block cache=ro and cache=singleclient on remount
2026-04-09 9:59 [PATCH 1/9] smb: client: block non-reconfigurable option changes on remount rajasimandalos
` (4 preceding siblings ...)
2026-04-09 9:59 ` [PATCH 6/9] smb: client: allow nolease option to be reconfigured " rajasimandalos
@ 2026-04-09 9:59 ` rajasimandalos
2026-04-13 13:40 ` Meetakshi Setiya
2026-04-09 9:59 ` [PATCH 8/9] smb: client: fix domainauto remount by syncing domainname from session rajasimandalos
2026-04-09 9:59 ` [PATCH 9/9] smb: client: apply rasize on remount rajasimandalos
7 siblings, 1 reply; 14+ messages in thread
From: rajasimandalos @ 2026-04-09 9:59 UTC (permalink / raw)
To: sfrench, linux-cifs
Cc: pc, ronniesahlberg, sprasad, tom, metze, bharathsm,
samba-technical, linux-kernel, Rajasi Mandal
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>
---
fs/smb/client/fs_context.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index ce4842e778c4..2be72733ef2e 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -1180,6 +1180,14 @@ static int smb3_verify_reconfigure_ctx(struct fs_context *fc,
cifs_errorf(fc, "can not change rdma during remount\n");
return -EINVAL;
}
+ 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] 14+ messages in thread* Re: [PATCH 7/9] smb: client: block cache=ro and cache=singleclient on remount
2026-04-09 9:59 ` [PATCH 7/9] smb: client: block cache=ro and cache=singleclient " rajasimandalos
@ 2026-04-13 13:40 ` Meetakshi Setiya
2026-04-22 4:34 ` RAJASI MANDAL
0 siblings, 1 reply; 14+ messages in thread
From: Meetakshi Setiya @ 2026-04-13 13:40 UTC (permalink / raw)
To: rajasimandalos
Cc: sfrench, linux-cifs, pc, ronniesahlberg, sprasad, tom, metze,
bharathsm, samba-technical, linux-kernel, Rajasi Mandal
Hey Rajasi,
I guess this is not handling remounts where cache=singleclient/ro is
not specified i.e. preserving previous behaviour.
To reproduce, mount with cache=ro and remount without providing cache=ro.
sudo mount -t cifs //server/winshare /mnt/mainshare -o
remount,username=demouser
mount error(22): Invalid argument
On Thu, Apr 9, 2026 at 3:07 AM <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>
> ---
> fs/smb/client/fs_context.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
> index ce4842e778c4..2be72733ef2e 100644
> --- a/fs/smb/client/fs_context.c
> +++ b/fs/smb/client/fs_context.c
> @@ -1180,6 +1180,14 @@ static int smb3_verify_reconfigure_ctx(struct fs_context *fc,
> cifs_errorf(fc, "can not change rdma during remount\n");
> return -EINVAL;
> }
> + 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] 14+ messages in thread* Re: [PATCH 7/9] smb: client: block cache=ro and cache=singleclient on remount
2026-04-13 13:40 ` Meetakshi Setiya
@ 2026-04-22 4:34 ` RAJASI MANDAL
0 siblings, 0 replies; 14+ messages in thread
From: RAJASI MANDAL @ 2026-04-22 4:34 UTC (permalink / raw)
To: Meetakshi Setiya
Cc: sfrench, linux-cifs, pc, ronniesahlberg, sprasad, tom, metze,
bharathsm, samba-technical, linux-kernel, Rajasi Mandal
Handled in updated Patch 1
On Mon, Apr 13, 2026 at 7:10 PM Meetakshi Setiya
<meetakshisetiyaoss@gmail.com> wrote:
>
> Hey Rajasi,
>
> I guess this is not handling remounts where cache=singleclient/ro is
> not specified i.e. preserving previous behaviour.
>
> To reproduce, mount with cache=ro and remount without providing cache=ro.
>
> sudo mount -t cifs //server/winshare /mnt/mainshare -o
> remount,username=demouser
> mount error(22): Invalid argument
>
> On Thu, Apr 9, 2026 at 3:07 AM <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>
> > ---
> > fs/smb/client/fs_context.c | 8 ++++++++
> > 1 file changed, 8 insertions(+)
> >
> > diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
> > index ce4842e778c4..2be72733ef2e 100644
> > --- a/fs/smb/client/fs_context.c
> > +++ b/fs/smb/client/fs_context.c
> > @@ -1180,6 +1180,14 @@ static int smb3_verify_reconfigure_ctx(struct fs_context *fc,
> > cifs_errorf(fc, "can not change rdma during remount\n");
> > return -EINVAL;
> > }
> > + 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] 14+ messages in thread
* [PATCH 8/9] smb: client: fix domainauto remount by syncing domainname from session
2026-04-09 9:59 [PATCH 1/9] smb: client: block non-reconfigurable option changes on remount rajasimandalos
` (5 preceding siblings ...)
2026-04-09 9:59 ` [PATCH 7/9] smb: client: block cache=ro and cache=singleclient " rajasimandalos
@ 2026-04-09 9:59 ` rajasimandalos
2026-04-09 9:59 ` [PATCH 9/9] smb: client: apply rasize on remount rajasimandalos
7 siblings, 0 replies; 14+ messages in thread
From: rajasimandalos @ 2026-04-09 9:59 UTC (permalink / raw)
To: sfrench, linux-cifs
Cc: pc, ronniesahlberg, sprasad, tom, metze, bharathsm,
samba-technical, linux-kernel, Rajasi Mandal
From: Rajasi Mandal <rajasimandal@microsoft.com>
When domainauto is used at mount time, ctx->domainname stays NULL
while the server negotiates the actual domain into ses->domainName.
cifs_show_options() reads ses->domainName and outputs domain=X in
/proc/mounts. On remount, libmount re-feeds domain=X, but the
verify check compares against old ctx->domainname (NULL) and rejects
the remount with "can not change domainname during remount".
Steps to reproduce:
1. Mount with domainauto (no explicit domain= option):
mount -t cifs //server/share /mnt \
-o username=u,password=p,domainauto
At this point ctx->domainname is NULL, but the server populates
ses->domainName (e.g. "CORP") during session setup.
2. Bare remount (or any remount):
mount -o remount /mnt
libmount reads /proc/mounts, sees domain=CORP (output by
cifs_show_options() from ses->domainName), and feeds it back
to the kernel. The kernel parses domain=CORP into
new_ctx->domainname="CORP", but old ctx->domainname is still
NULL. smb3_verify_reconfigure_ctx() sees the mismatch and
rejects the remount.
This affects any server that populates ses->domainName during session
setup (Active Directory domain controllers, Azure Files) when the
admin uses domainauto instead of an explicit domain= option.
Fix this by syncing ctx->domainname from ses->domainName in
smb3_sync_ctx_from_negotiated() before the verify check runs.
Signed-off-by: Rajasi Mandal <rajasimandal@microsoft.com>
---
fs/smb/client/fs_context.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index 2be72733ef2e..d804e5da578e 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -1232,6 +1232,9 @@ static void smb3_sync_ctx_from_negotiated(struct cifs_sb_info *cifs_sb)
*/
ctx->ops = server->ops;
ctx->vals = server->vals;
+ /* /proc/mounts shows domain= from ses->domainName */
+ if (tcon->ses->domainName && !ctx->domainname)
+ ctx->domainname = kstrdup(tcon->ses->domainName, GFP_KERNEL);
}
/*
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 9/9] smb: client: apply rasize on remount
2026-04-09 9:59 [PATCH 1/9] smb: client: block non-reconfigurable option changes on remount rajasimandalos
` (6 preceding siblings ...)
2026-04-09 9:59 ` [PATCH 8/9] smb: client: fix domainauto remount by syncing domainname from session rajasimandalos
@ 2026-04-09 9:59 ` rajasimandalos
2026-04-13 13:29 ` Meetakshi Setiya
7 siblings, 1 reply; 14+ messages in thread
From: rajasimandalos @ 2026-04-09 9:59 UTC (permalink / raw)
To: sfrench, linux-cifs
Cc: pc, ronniesahlberg, sprasad, tom, metze, bharathsm,
samba-technical, linux-kernel, Rajasi Mandal
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>
---
fs/smb/client/fs_context.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index d804e5da578e..bba642442ae3 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -1504,6 +1504,12 @@ static int smb3_reconfigure(struct fs_context *fc)
smb3_cleanup_fs_context_contents(cifs_sb->ctx);
rc = smb3_fs_context_dup(cifs_sb->ctx, ctx);
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] 14+ messages in thread* Re: [PATCH 9/9] smb: client: apply rasize on remount
2026-04-09 9:59 ` [PATCH 9/9] smb: client: apply rasize on remount rajasimandalos
@ 2026-04-13 13:29 ` Meetakshi Setiya
0 siblings, 0 replies; 14+ messages in thread
From: Meetakshi Setiya @ 2026-04-13 13:29 UTC (permalink / raw)
To: rajasimandalos
Cc: sfrench, linux-cifs, pc, ronniesahlberg, sprasad, tom, metze,
bharathsm, samba-technical, linux-kernel, Rajasi Mandal
Hi Rajasi,
Before syncing the contexts, you should check if rasize has been
passed during remount at all. Else, we run the risk of overwriting
cifs_sb->ctx->rasize to 0 (the default value).
Please check how rsize and wsize handle this (a few lines above):
/* if rsize or wsize 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;
Thanks
Meetakshi
On Thu, Apr 9, 2026 at 3:08 AM <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>
> ---
> fs/smb/client/fs_context.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
> index d804e5da578e..bba642442ae3 100644
> --- a/fs/smb/client/fs_context.c
> +++ b/fs/smb/client/fs_context.c
> @@ -1504,6 +1504,12 @@ static int smb3_reconfigure(struct fs_context *fc)
> smb3_cleanup_fs_context_contents(cifs_sb->ctx);
> rc = smb3_fs_context_dup(cifs_sb->ctx, ctx);
> 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] 14+ messages in thread