Skip to content

Commit 3e7a02d

Browse files
committed
smb3: allow disabling requesting leases
In some cases to work around server bugs or performance problems it can be helpful to be able to disable requesting SMB2.1/SMB3 leases on a particular mount (not to all servers and all shares we are mounted to). Add new mount parm "nolease" which turns off requesting leases on directory or file opens. Currently the only way to disable leases is globally through a module load parameter. This is more granular. Suggested-by: Pavel Shilovsky <pshilov@microsoft.com> Signed-off-by: Steve French <stfrench@microsoft.com> Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com> Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com> CC: Stable <stable@vger.kernel.org>
1 parent 7dcc82c commit 3e7a02d

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

fs/cifs/cifsfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
438438
cifs_show_security(s, tcon->ses);
439439
cifs_show_cache_flavor(s, cifs_sb);
440440

441+
if (tcon->no_lease)
442+
seq_puts(s, ",nolease");
441443
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)
442444
seq_puts(s, ",multiuser");
443445
else if (tcon->ses->user_name)

fs/cifs/cifsglob.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ struct smb_vol {
579579
bool noblocksnd:1;
580580
bool noautotune:1;
581581
bool nostrictsync:1; /* do not force expensive SMBflush on every sync */
582+
bool no_lease:1; /* disable requesting leases */
582583
bool fsc:1; /* enable fscache */
583584
bool mfsymlinks:1; /* use Minshall+French Symlinks */
584585
bool multiuser:1;
@@ -1090,6 +1091,7 @@ struct cifs_tcon {
10901091
bool need_reopen_files:1; /* need to reopen tcon file handles */
10911092
bool use_resilient:1; /* use resilient instead of durable handles */
10921093
bool use_persistent:1; /* use persistent instead of durable handles */
1094+
bool no_lease:1; /* Do not request leases on files or directories */
10931095
__le32 capabilities;
10941096
__u32 share_flags;
10951097
__u32 maximal_access;

fs/cifs/connect.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ enum {
7474
Opt_user_xattr, Opt_nouser_xattr,
7575
Opt_forceuid, Opt_noforceuid,
7676
Opt_forcegid, Opt_noforcegid,
77-
Opt_noblocksend, Opt_noautotune,
77+
Opt_noblocksend, Opt_noautotune, Opt_nolease,
7878
Opt_hard, Opt_soft, Opt_perm, Opt_noperm,
7979
Opt_mapposix, Opt_nomapposix,
8080
Opt_mapchars, Opt_nomapchars, Opt_sfu,
@@ -135,6 +135,7 @@ static const match_table_t cifs_mount_option_tokens = {
135135
{ Opt_noforcegid, "noforcegid" },
136136
{ Opt_noblocksend, "noblocksend" },
137137
{ Opt_noautotune, "noautotune" },
138+
{ Opt_nolease, "nolease" },
138139
{ Opt_hard, "hard" },
139140
{ Opt_soft, "soft" },
140141
{ Opt_perm, "perm" },
@@ -1738,6 +1739,9 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
17381739
case Opt_noautotune:
17391740
vol->noautotune = 1;
17401741
break;
1742+
case Opt_nolease:
1743+
vol->no_lease = 1;
1744+
break;
17411745
case Opt_hard:
17421746
vol->retry = 1;
17431747
break;
@@ -3294,6 +3298,8 @@ static int match_tcon(struct cifs_tcon *tcon, struct smb_vol *volume_info)
32943298
return 0;
32953299
if (tcon->handle_timeout != volume_info->handle_timeout)
32963300
return 0;
3301+
if (tcon->no_lease != volume_info->no_lease)
3302+
return 0;
32973303
return 1;
32983304
}
32993305

@@ -3516,6 +3522,7 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
35163522
tcon->nocase = volume_info->nocase;
35173523
tcon->nohandlecache = volume_info->nohandlecache;
35183524
tcon->local_lease = volume_info->local_lease;
3525+
tcon->no_lease = volume_info->no_lease;
35193526
INIT_LIST_HEAD(&tcon->pending_opens);
35203527

35213528
spin_lock(&cifs_tcp_ses_lock);

fs/cifs/smb2pdu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2459,7 +2459,7 @@ SMB2_open_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, __u8 *oplock,
24592459
iov[1].iov_len = uni_path_len;
24602460
iov[1].iov_base = path;
24612461

2462-
if (!server->oplocks)
2462+
if ((!server->oplocks) || (tcon->no_lease))
24632463
*oplock = SMB2_OPLOCK_LEVEL_NONE;
24642464

24652465
if (!(server->capabilities & SMB2_GLOBAL_CAP_LEASING) ||

0 commit comments

Comments
 (0)