Commit 0ac4e291 authored by Samuel Cabrero's avatar Samuel Cabrero Committed by Steve French

cifs: add witness mount option and data structs

Add 'witness' mount option to register for witness notifications.
Signed-off-by: default avatarSamuel Cabrero <scabrero@suse.de>
Reviewed-by: default avatarAurelien Aptel <aaptel@suse.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 06f08dab
...@@ -638,6 +638,11 @@ cifs_show_options(struct seq_file *s, struct dentry *root) ...@@ -638,6 +638,11 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
seq_printf(s, ",multichannel,max_channels=%zu", seq_printf(s, ",multichannel,max_channels=%zu",
tcon->ses->chan_max); tcon->ses->chan_max);
#ifdef CONFIG_CIFS_SWN_UPCALL
if (tcon->use_witness)
seq_puts(s, ",witness");
#endif
return 0; return 0;
} }
......
...@@ -1086,6 +1086,9 @@ struct cifs_tcon { ...@@ -1086,6 +1086,9 @@ struct cifs_tcon {
int remap:2; int remap:2;
struct list_head ulist; /* cache update list */ struct list_head ulist; /* cache update list */
#endif #endif
#ifdef CONFIG_CIFS_SWN_UPCALL
bool use_witness:1; /* use witness protocol */
#endif
}; };
/* /*
......
...@@ -1944,6 +1944,8 @@ cifs_put_tcon(struct cifs_tcon *tcon) ...@@ -1944,6 +1944,8 @@ cifs_put_tcon(struct cifs_tcon *tcon)
return; return;
} }
/* TODO witness unregister */
list_del_init(&tcon->tcon_list); list_del_init(&tcon->tcon_list);
spin_unlock(&cifs_tcp_ses_lock); spin_unlock(&cifs_tcp_ses_lock);
...@@ -2104,6 +2106,26 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx) ...@@ -2104,6 +2106,26 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
} }
tcon->use_resilient = true; tcon->use_resilient = true;
} }
#ifdef CONFIG_CIFS_SWN_UPCALL
tcon->use_witness = false;
if (ctx->witness) {
if (ses->server->vals->protocol_id >= SMB30_PROT_ID) {
if (tcon->capabilities & SMB2_SHARE_CAP_CLUSTER) {
/* TODO witness register */
tcon->use_witness = true;
} else {
/* TODO: try to extend for non-cluster uses (eg multichannel) */
cifs_dbg(VFS, "witness requested on mount but no CLUSTER capability on share\n");
rc = -EOPNOTSUPP;
goto out_fail;
}
} else {
cifs_dbg(VFS, "SMB3 or later required for witness option\n");
rc = -EOPNOTSUPP;
goto out_fail;
}
}
#endif
/* If the user really knows what they are doing they can override */ /* If the user really knows what they are doing they can override */
if (tcon->share_flags & SMB2_SHAREFLAG_NO_CACHING) { if (tcon->share_flags & SMB2_SHAREFLAG_NO_CACHING) {
...@@ -3856,6 +3878,9 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid) ...@@ -3856,6 +3878,9 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid)
ctx->sectype = master_tcon->ses->sectype; ctx->sectype = master_tcon->ses->sectype;
ctx->sign = master_tcon->ses->sign; ctx->sign = master_tcon->ses->sign;
ctx->seal = master_tcon->seal; ctx->seal = master_tcon->seal;
#ifdef CONFIG_CIFS_SWN_UPCALL
ctx->witness = master_tcon->use_witness;
#endif
rc = cifs_set_vol_auth(ctx, master_tcon->ses); rc = cifs_set_vol_auth(ctx, master_tcon->ses);
if (rc) { if (rc) {
......
...@@ -119,6 +119,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = { ...@@ -119,6 +119,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {
fsparam_flag("modesid", Opt_modesid), fsparam_flag("modesid", Opt_modesid),
fsparam_flag("rootfs", Opt_rootfs), fsparam_flag("rootfs", Opt_rootfs),
fsparam_flag("compress", Opt_compress), fsparam_flag("compress", Opt_compress),
fsparam_flag("witness", Opt_witness),
/* Mount options which take numeric value */ /* Mount options which take numeric value */
fsparam_u32("backupuid", Opt_backupuid), fsparam_u32("backupuid", Opt_backupuid),
...@@ -1004,6 +1005,13 @@ static int smb3_fs_context_parse_param(struct fs_context *fc, ...@@ -1004,6 +1005,13 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
if (cifs_parse_cache_flavor(param->string, ctx) != 0) if (cifs_parse_cache_flavor(param->string, ctx) != 0)
goto cifs_parse_mount_err; goto cifs_parse_mount_err;
break; break;
case Opt_witness:
#ifndef CONFIG_CIFS_SWN_UPCALL
cifs_dbg(VFS, "Witness support needs CONFIG_CIFS_SWN_UPCALL config option\n");
goto cifs_parse_mount_err;
#endif
ctx->witness = true;
break;
case Opt_rootfs: case Opt_rootfs:
#ifdef CONFIG_CIFS_ROOT #ifdef CONFIG_CIFS_ROOT
ctx->rootfs = true; ctx->rootfs = true;
......
...@@ -102,6 +102,7 @@ enum cifs_param { ...@@ -102,6 +102,7 @@ enum cifs_param {
Opt_rootfs, Opt_rootfs,
Opt_multichannel, Opt_multichannel,
Opt_compress, Opt_compress,
Opt_witness,
/* Mount options which take numeric value */ /* Mount options which take numeric value */
Opt_backupuid, Opt_backupuid,
...@@ -241,6 +242,7 @@ struct smb3_fs_context { ...@@ -241,6 +242,7 @@ struct smb3_fs_context {
unsigned int max_channels; unsigned int max_channels;
__u16 compression; /* compression algorithm 0xFFFF default 0=disabled */ __u16 compression; /* compression algorithm 0xFFFF default 0=disabled */
bool rootfs:1; /* if it's a SMB root file system */ bool rootfs:1; /* if it's a SMB root file system */
bool witness:1; /* use witness protocol */
char *mount_options; char *mount_options;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment