public inbox for linux-cifs@vger.kernel.org
 help / color / mirror / Atom feed
From: rajasimandalos@gmail.com
To: sfrench@samba.org, linux-cifs@vger.kernel.org
Cc: pc@manguebit.org, ronniesahlberg@gmail.com,
	sprasad@microsoft.com, tom@talpey.com, metze@samba.org,
	bharathsm@microsoft.com, samba-technical@lists.samba.org,
	linux-kernel@vger.kernel.org,
	Rajasi Mandal <rajasimandal@microsoft.com>
Subject: [PATCH 6/9] smb: client: allow nolease option to be reconfigured on remount
Date: Thu,  9 Apr 2026 09:59:23 +0000	[thread overview]
Message-ID: <20260409095926.905020-6-rajasimandalos@gmail.com> (raw)
In-Reply-To: <20260409095926.905020-1-rajasimandalos@gmail.com>

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


  parent reply	other threads:[~2026-04-09 10:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` [PATCH 4/9] smb: client: sync retrans " rajasimandalos
2026-04-09  9:59 ` [PATCH 5/9] smb: client: sync echo_interval " rajasimandalos
2026-04-09  9:59 ` rajasimandalos [this message]
2026-04-09  9:59 ` [PATCH 7/9] smb: client: block cache=ro and cache=singleclient " rajasimandalos
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260409095926.905020-6-rajasimandalos@gmail.com \
    --to=rajasimandalos@gmail.com \
    --cc=bharathsm@microsoft.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=metze@samba.org \
    --cc=pc@manguebit.org \
    --cc=rajasimandal@microsoft.com \
    --cc=ronniesahlberg@gmail.com \
    --cc=samba-technical@lists.samba.org \
    --cc=sfrench@samba.org \
    --cc=sprasad@microsoft.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox