Add resilienthandles mount parm
Since many servers (Windows clients, and non-clustered servers) do not support persistent handles but do support resilient handles, allow the user to specify a mount option "resilienthandles" in order to get more reliable connections and less chance of data loss (at least when SMB2.1 or later). Default resilient handle timeout (120 seconds to recent Windows server) is used. Reviewed-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steve French <steve.french@primarydata.com>
This commit is contained in:
Родитель
b56eae4df9
Коммит
592fafe644
|
@ -456,6 +456,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
|
||||||
seq_puts(s, ",hard");
|
seq_puts(s, ",hard");
|
||||||
if (tcon->use_persistent)
|
if (tcon->use_persistent)
|
||||||
seq_puts(s, ",persistenthandles");
|
seq_puts(s, ",persistenthandles");
|
||||||
|
else if (tcon->use_resilient)
|
||||||
|
seq_puts(s, ",resilienthandles");
|
||||||
if (tcon->unix_ext)
|
if (tcon->unix_ext)
|
||||||
seq_puts(s, ",unix");
|
seq_puts(s, ",unix");
|
||||||
else
|
else
|
||||||
|
|
|
@ -496,6 +496,7 @@ struct smb_vol {
|
||||||
bool nosharesock:1;
|
bool nosharesock:1;
|
||||||
bool persistent:1;
|
bool persistent:1;
|
||||||
bool nopersistent:1;
|
bool nopersistent:1;
|
||||||
|
bool resilient:1; /* noresilient not required since not fored for CA */
|
||||||
unsigned int rsize;
|
unsigned int rsize;
|
||||||
unsigned int wsize;
|
unsigned int wsize;
|
||||||
bool sockopt_tcp_nodelay:1;
|
bool sockopt_tcp_nodelay:1;
|
||||||
|
@ -897,6 +898,7 @@ struct cifs_tcon {
|
||||||
bool broken_posix_open; /* e.g. Samba server versions < 3.3.2, 3.2.9 */
|
bool broken_posix_open; /* e.g. Samba server versions < 3.3.2, 3.2.9 */
|
||||||
bool broken_sparse_sup; /* if server or share does not support sparse */
|
bool broken_sparse_sup; /* if server or share does not support sparse */
|
||||||
bool need_reconnect:1; /* connection reset, tid now invalid */
|
bool need_reconnect:1; /* connection reset, tid now invalid */
|
||||||
|
bool use_resilient:1; /* use resilient instead of durable handles */
|
||||||
bool use_persistent:1; /* use persistent instead of durable handles */
|
bool use_persistent:1; /* use persistent instead of durable handles */
|
||||||
#ifdef CONFIG_CIFS_SMB2
|
#ifdef CONFIG_CIFS_SMB2
|
||||||
bool print:1; /* set if connection to printer share */
|
bool print:1; /* set if connection to printer share */
|
||||||
|
|
|
@ -88,6 +88,7 @@ enum {
|
||||||
Opt_fsc, Opt_mfsymlinks,
|
Opt_fsc, Opt_mfsymlinks,
|
||||||
Opt_multiuser, Opt_sloppy, Opt_nosharesock,
|
Opt_multiuser, Opt_sloppy, Opt_nosharesock,
|
||||||
Opt_persistent, Opt_nopersistent,
|
Opt_persistent, Opt_nopersistent,
|
||||||
|
Opt_resilient, Opt_noresilient,
|
||||||
|
|
||||||
/* Mount options which take numeric value */
|
/* Mount options which take numeric value */
|
||||||
Opt_backupuid, Opt_backupgid, Opt_uid,
|
Opt_backupuid, Opt_backupgid, Opt_uid,
|
||||||
|
@ -172,6 +173,8 @@ static const match_table_t cifs_mount_option_tokens = {
|
||||||
{ Opt_nosharesock, "nosharesock" },
|
{ Opt_nosharesock, "nosharesock" },
|
||||||
{ Opt_persistent, "persistenthandles"},
|
{ Opt_persistent, "persistenthandles"},
|
||||||
{ Opt_nopersistent, "nopersistenthandles"},
|
{ Opt_nopersistent, "nopersistenthandles"},
|
||||||
|
{ Opt_resilient, "resilienthandles"},
|
||||||
|
{ Opt_noresilient, "noresilienthandles"},
|
||||||
|
|
||||||
{ Opt_backupuid, "backupuid=%s" },
|
{ Opt_backupuid, "backupuid=%s" },
|
||||||
{ Opt_backupgid, "backupgid=%s" },
|
{ Opt_backupgid, "backupgid=%s" },
|
||||||
|
@ -1510,12 +1513,23 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
|
||||||
break;
|
break;
|
||||||
case Opt_persistent:
|
case Opt_persistent:
|
||||||
vol->persistent = true;
|
vol->persistent = true;
|
||||||
if (vol->nopersistent) {
|
if ((vol->nopersistent) || (vol->resilient)) {
|
||||||
cifs_dbg(VFS,
|
cifs_dbg(VFS,
|
||||||
"persistenthandles mount options conflict\n");
|
"persistenthandles mount options conflict\n");
|
||||||
goto cifs_parse_mount_err;
|
goto cifs_parse_mount_err;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Opt_resilient:
|
||||||
|
vol->resilient = true;
|
||||||
|
if (vol->persistent) {
|
||||||
|
cifs_dbg(VFS,
|
||||||
|
"persistenthandles mount options conflict\n");
|
||||||
|
goto cifs_parse_mount_err;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Opt_noresilient:
|
||||||
|
vol->resilient = false; /* already the default */
|
||||||
|
break;
|
||||||
|
|
||||||
/* Numeric Values */
|
/* Numeric Values */
|
||||||
case Opt_backupuid:
|
case Opt_backupuid:
|
||||||
|
@ -2681,6 +2695,7 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
|
||||||
"SMB3 or later required for persistent handles\n");
|
"SMB3 or later required for persistent handles\n");
|
||||||
rc = -EOPNOTSUPP;
|
rc = -EOPNOTSUPP;
|
||||||
goto out_fail;
|
goto out_fail;
|
||||||
|
#ifdef CONFIG_CIFS_SMB2
|
||||||
} else if (ses->server->capabilities &
|
} else if (ses->server->capabilities &
|
||||||
SMB2_GLOBAL_CAP_PERSISTENT_HANDLES)
|
SMB2_GLOBAL_CAP_PERSISTENT_HANDLES)
|
||||||
tcon->use_persistent = true;
|
tcon->use_persistent = true;
|
||||||
|
@ -2689,12 +2704,23 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
|
||||||
"Persistent handles not supported on share\n");
|
"Persistent handles not supported on share\n");
|
||||||
rc = -EOPNOTSUPP;
|
rc = -EOPNOTSUPP;
|
||||||
goto out_fail;
|
goto out_fail;
|
||||||
|
#endif /* CONFIG_CIFS_SMB2 */
|
||||||
}
|
}
|
||||||
|
#ifdef CONFIG_CIFS_SMB2
|
||||||
} else if ((tcon->capabilities & SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY)
|
} else if ((tcon->capabilities & SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY)
|
||||||
&& (ses->server->capabilities & SMB2_GLOBAL_CAP_PERSISTENT_HANDLES)
|
&& (ses->server->capabilities & SMB2_GLOBAL_CAP_PERSISTENT_HANDLES)
|
||||||
&& (volume_info->nopersistent == false)) {
|
&& (volume_info->nopersistent == false)) {
|
||||||
cifs_dbg(FYI, "enabling persistent handles\n");
|
cifs_dbg(FYI, "enabling persistent handles\n");
|
||||||
tcon->use_persistent = true;
|
tcon->use_persistent = true;
|
||||||
|
#endif /* CONFIG_CIFS_SMB2 */
|
||||||
|
} else if (volume_info->resilient) {
|
||||||
|
if (ses->server->vals->protocol_id == 0) {
|
||||||
|
cifs_dbg(VFS,
|
||||||
|
"SMB2.1 or later required for resilient handles\n");
|
||||||
|
rc = -EOPNOTSUPP;
|
||||||
|
goto out_fail;
|
||||||
|
}
|
||||||
|
tcon->use_resilient = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3545,12 +3571,15 @@ try_mount_again:
|
||||||
goto mount_fail_check;
|
goto mount_fail_check;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_CIFS_SMB2
|
||||||
if ((volume_info->persistent == true) && ((ses->server->capabilities &
|
if ((volume_info->persistent == true) && ((ses->server->capabilities &
|
||||||
SMB2_GLOBAL_CAP_PERSISTENT_HANDLES) == 0)) {
|
SMB2_GLOBAL_CAP_PERSISTENT_HANDLES) == 0)) {
|
||||||
cifs_dbg(VFS, "persistent handles not supported by server\n");
|
cifs_dbg(VFS, "persistent handles not supported by server\n");
|
||||||
rc = -EOPNOTSUPP;
|
rc = -EOPNOTSUPP;
|
||||||
goto mount_fail_check;
|
goto mount_fail_check;
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_CIFS_SMB2*/
|
||||||
|
|
||||||
/* search for existing tcon to this server share */
|
/* search for existing tcon to this server share */
|
||||||
tcon = cifs_get_tcon(ses, volume_info);
|
tcon = cifs_get_tcon(ses, volume_info);
|
||||||
if (IS_ERR(tcon)) {
|
if (IS_ERR(tcon)) {
|
||||||
|
|
|
@ -43,6 +43,7 @@ smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
|
||||||
struct smb2_file_all_info *smb2_data = NULL;
|
struct smb2_file_all_info *smb2_data = NULL;
|
||||||
__u8 smb2_oplock[17];
|
__u8 smb2_oplock[17];
|
||||||
struct cifs_fid *fid = oparms->fid;
|
struct cifs_fid *fid = oparms->fid;
|
||||||
|
struct network_resiliency_req nr_ioctl_req;
|
||||||
|
|
||||||
smb2_path = cifs_convert_path_to_utf16(oparms->path, oparms->cifs_sb);
|
smb2_path = cifs_convert_path_to_utf16(oparms->path, oparms->cifs_sb);
|
||||||
if (smb2_path == NULL) {
|
if (smb2_path == NULL) {
|
||||||
|
@ -67,6 +68,24 @@ smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
|
||||||
if (rc)
|
if (rc)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|
||||||
|
if (oparms->tcon->use_resilient) {
|
||||||
|
nr_ioctl_req.Timeout = 0; /* use server default (120 seconds) */
|
||||||
|
nr_ioctl_req.Reserved = 0;
|
||||||
|
rc = SMB2_ioctl(xid, oparms->tcon, fid->persistent_fid,
|
||||||
|
fid->volatile_fid, FSCTL_LMR_REQUEST_RESILIENCY, true,
|
||||||
|
(char *)&nr_ioctl_req, sizeof(nr_ioctl_req),
|
||||||
|
NULL, NULL /* no return info */);
|
||||||
|
if (rc == -EOPNOTSUPP) {
|
||||||
|
cifs_dbg(VFS,
|
||||||
|
"resiliency not supported by server, disabling\n");
|
||||||
|
oparms->tcon->use_resilient = false;
|
||||||
|
} else if (rc)
|
||||||
|
cifs_dbg(FYI, "error %d setting resiliency\n", rc);
|
||||||
|
|
||||||
|
rc = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
/* open response does not have IndexNumber field - get it */
|
/* open response does not have IndexNumber field - get it */
|
||||||
rc = SMB2_get_srv_num(xid, oparms->tcon, fid->persistent_fid,
|
rc = SMB2_get_srv_num(xid, oparms->tcon, fid->persistent_fid,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче