summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve French <stfrench@microsoft.com>2019-09-11 22:46:20 -0400
committerSteve French <stfrench@microsoft.com>2019-09-16 12:43:38 -0400
commit3e7a02d47872081f4b6234a9f72500f1d10f060c (patch)
tree9d1b1a19b0d85510b38b6afbe848d24080ca62fc
parent7dcc82c2dfd5f12eba19d19d39c50bff70b4f94a (diff)
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>
-rw-r--r--fs/cifs/cifsfs.c2
-rw-r--r--fs/cifs/cifsglob.h2
-rw-r--r--fs/cifs/connect.c9
-rw-r--r--fs/cifs/smb2pdu.c2
4 files changed, 13 insertions, 2 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index c1b685072063..69601a9b29ad 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -438,6 +438,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
438 cifs_show_security(s, tcon->ses); 438 cifs_show_security(s, tcon->ses);
439 cifs_show_cache_flavor(s, cifs_sb); 439 cifs_show_cache_flavor(s, cifs_sb);
440 440
441 if (tcon->no_lease)
442 seq_puts(s, ",nolease");
441 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER) 443 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)
442 seq_puts(s, ",multiuser"); 444 seq_puts(s, ",multiuser");
443 else if (tcon->ses->user_name) 445 else if (tcon->ses->user_name)
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index ef2199913217..09b60ec5de3e 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -579,6 +579,7 @@ struct smb_vol {
579 bool noblocksnd:1; 579 bool noblocksnd:1;
580 bool noautotune:1; 580 bool noautotune:1;
581 bool nostrictsync:1; /* do not force expensive SMBflush on every sync */ 581 bool nostrictsync:1; /* do not force expensive SMBflush on every sync */
582 bool no_lease:1; /* disable requesting leases */
582 bool fsc:1; /* enable fscache */ 583 bool fsc:1; /* enable fscache */
583 bool mfsymlinks:1; /* use Minshall+French Symlinks */ 584 bool mfsymlinks:1; /* use Minshall+French Symlinks */
584 bool multiuser:1; 585 bool multiuser:1;
@@ -1090,6 +1091,7 @@ struct cifs_tcon {
1090 bool need_reopen_files:1; /* need to reopen tcon file handles */ 1091 bool need_reopen_files:1; /* need to reopen tcon file handles */
1091 bool use_resilient:1; /* use resilient instead of durable handles */ 1092 bool use_resilient:1; /* use resilient instead of durable handles */
1092 bool use_persistent:1; /* use persistent instead of durable handles */ 1093 bool use_persistent:1; /* use persistent instead of durable handles */
1094 bool no_lease:1; /* Do not request leases on files or directories */
1093 __le32 capabilities; 1095 __le32 capabilities;
1094 __u32 share_flags; 1096 __u32 share_flags;
1095 __u32 maximal_access; 1097 __u32 maximal_access;
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index df1ccb581828..e16b6cc1e31b 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -74,7 +74,7 @@ enum {
74 Opt_user_xattr, Opt_nouser_xattr, 74 Opt_user_xattr, Opt_nouser_xattr,
75 Opt_forceuid, Opt_noforceuid, 75 Opt_forceuid, Opt_noforceuid,
76 Opt_forcegid, Opt_noforcegid, 76 Opt_forcegid, Opt_noforcegid,
77 Opt_noblocksend, Opt_noautotune, 77 Opt_noblocksend, Opt_noautotune, Opt_nolease,
78 Opt_hard, Opt_soft, Opt_perm, Opt_noperm, 78 Opt_hard, Opt_soft, Opt_perm, Opt_noperm,
79 Opt_mapposix, Opt_nomapposix, 79 Opt_mapposix, Opt_nomapposix,
80 Opt_mapchars, Opt_nomapchars, Opt_sfu, 80 Opt_mapchars, Opt_nomapchars, Opt_sfu,
@@ -135,6 +135,7 @@ static const match_table_t cifs_mount_option_tokens = {
135 { Opt_noforcegid, "noforcegid" }, 135 { Opt_noforcegid, "noforcegid" },
136 { Opt_noblocksend, "noblocksend" }, 136 { Opt_noblocksend, "noblocksend" },
137 { Opt_noautotune, "noautotune" }, 137 { Opt_noautotune, "noautotune" },
138 { Opt_nolease, "nolease" },
138 { Opt_hard, "hard" }, 139 { Opt_hard, "hard" },
139 { Opt_soft, "soft" }, 140 { Opt_soft, "soft" },
140 { Opt_perm, "perm" }, 141 { Opt_perm, "perm" },
@@ -1738,6 +1739,9 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
1738 case Opt_noautotune: 1739 case Opt_noautotune:
1739 vol->noautotune = 1; 1740 vol->noautotune = 1;
1740 break; 1741 break;
1742 case Opt_nolease:
1743 vol->no_lease = 1;
1744 break;
1741 case Opt_hard: 1745 case Opt_hard:
1742 vol->retry = 1; 1746 vol->retry = 1;
1743 break; 1747 break;
@@ -3294,6 +3298,8 @@ static int match_tcon(struct cifs_tcon *tcon, struct smb_vol *volume_info)
3294 return 0; 3298 return 0;
3295 if (tcon->handle_timeout != volume_info->handle_timeout) 3299 if (tcon->handle_timeout != volume_info->handle_timeout)
3296 return 0; 3300 return 0;
3301 if (tcon->no_lease != volume_info->no_lease)
3302 return 0;
3297 return 1; 3303 return 1;
3298} 3304}
3299 3305
@@ -3516,6 +3522,7 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
3516 tcon->nocase = volume_info->nocase; 3522 tcon->nocase = volume_info->nocase;
3517 tcon->nohandlecache = volume_info->nohandlecache; 3523 tcon->nohandlecache = volume_info->nohandlecache;
3518 tcon->local_lease = volume_info->local_lease; 3524 tcon->local_lease = volume_info->local_lease;
3525 tcon->no_lease = volume_info->no_lease;
3519 INIT_LIST_HEAD(&tcon->pending_opens); 3526 INIT_LIST_HEAD(&tcon->pending_opens);
3520 3527
3521 spin_lock(&cifs_tcp_ses_lock); 3528 spin_lock(&cifs_tcp_ses_lock);
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 01d5c4af2458..ce647cfdc04f 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -2459,7 +2459,7 @@ SMB2_open_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, __u8 *oplock,
2459 iov[1].iov_len = uni_path_len; 2459 iov[1].iov_len = uni_path_len;
2460 iov[1].iov_base = path; 2460 iov[1].iov_base = path;
2461 2461
2462 if (!server->oplocks) 2462 if ((!server->oplocks) || (tcon->no_lease))
2463 *oplock = SMB2_OPLOCK_LEVEL_NONE; 2463 *oplock = SMB2_OPLOCK_LEVEL_NONE;
2464 2464
2465 if (!(server->capabilities & SMB2_GLOBAL_CAP_LEASING) || 2465 if (!(server->capabilities & SMB2_GLOBAL_CAP_LEASING) ||