Skip to content

Commit 0ac4e29

Browse files
scabrerosmfrench
authored andcommitted
cifs: add witness mount option and data structs
Add 'witness' mount option to register for witness notifications. Signed-off-by: Samuel Cabrero <scabrero@suse.de> Reviewed-by: Aurelien Aptel <aaptel@suse.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 06f08da commit 0ac4e29

5 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎fs/cifs/cifsfs.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,11 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
638638
seq_printf(s, ",multichannel,max_channels=%zu",
639639
tcon->ses->chan_max);
640640

641+
#ifdef CONFIG_CIFS_SWN_UPCALL
642+
if (tcon->use_witness)
643+
seq_puts(s, ",witness");
644+
#endif
645+
641646
return 0;
642647
}
643648

‎fs/cifs/cifsglob.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,9 @@ struct cifs_tcon {
10861086
int remap:2;
10871087
struct list_head ulist; /* cache update list */
10881088
#endif
1089+
#ifdef CONFIG_CIFS_SWN_UPCALL
1090+
bool use_witness:1; /* use witness protocol */
1091+
#endif
10891092
};
10901093

10911094
/*

‎fs/cifs/connect.c‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,6 +1944,8 @@ cifs_put_tcon(struct cifs_tcon *tcon)
19441944
return;
19451945
}
19461946

1947+
/* TODO witness unregister */
1948+
19471949
list_del_init(&tcon->tcon_list);
19481950
spin_unlock(&cifs_tcp_ses_lock);
19491951

@@ -2104,6 +2106,26 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
21042106
}
21052107
tcon->use_resilient = true;
21062108
}
2109+
#ifdef CONFIG_CIFS_SWN_UPCALL
2110+
tcon->use_witness = false;
2111+
if (ctx->witness) {
2112+
if (ses->server->vals->protocol_id >= SMB30_PROT_ID) {
2113+
if (tcon->capabilities & SMB2_SHARE_CAP_CLUSTER) {
2114+
/* TODO witness register */
2115+
tcon->use_witness = true;
2116+
} else {
2117+
/* TODO: try to extend for non-cluster uses (eg multichannel) */
2118+
cifs_dbg(VFS, "witness requested on mount but no CLUSTER capability on share\n");
2119+
rc = -EOPNOTSUPP;
2120+
goto out_fail;
2121+
}
2122+
} else {
2123+
cifs_dbg(VFS, "SMB3 or later required for witness option\n");
2124+
rc = -EOPNOTSUPP;
2125+
goto out_fail;
2126+
}
2127+
}
2128+
#endif
21072129

21082130
/* If the user really knows what they are doing they can override */
21092131
if (tcon->share_flags & SMB2_SHAREFLAG_NO_CACHING) {
@@ -3856,6 +3878,9 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid)
38563878
ctx->sectype = master_tcon->ses->sectype;
38573879
ctx->sign = master_tcon->ses->sign;
38583880
ctx->seal = master_tcon->seal;
3881+
#ifdef CONFIG_CIFS_SWN_UPCALL
3882+
ctx->witness = master_tcon->use_witness;
3883+
#endif
38593884

38603885
rc = cifs_set_vol_auth(ctx, master_tcon->ses);
38613886
if (rc) {

‎fs/cifs/fs_context.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {
119119
fsparam_flag("modesid", Opt_modesid),
120120
fsparam_flag("rootfs", Opt_rootfs),
121121
fsparam_flag("compress", Opt_compress),
122+
fsparam_flag("witness", Opt_witness),
122123

123124
/* Mount options which take numeric value */
124125
fsparam_u32("backupuid", Opt_backupuid),
@@ -1004,6 +1005,13 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
10041005
if (cifs_parse_cache_flavor(param->string, ctx) != 0)
10051006
goto cifs_parse_mount_err;
10061007
break;
1008+
case Opt_witness:
1009+
#ifndef CONFIG_CIFS_SWN_UPCALL
1010+
cifs_dbg(VFS, "Witness support needs CONFIG_CIFS_SWN_UPCALL config option\n");
1011+
goto cifs_parse_mount_err;
1012+
#endif
1013+
ctx->witness = true;
1014+
break;
10071015
case Opt_rootfs:
10081016
#ifdef CONFIG_CIFS_ROOT
10091017
ctx->rootfs = true;

‎fs/cifs/fs_context.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ enum cifs_param {
102102
Opt_rootfs,
103103
Opt_multichannel,
104104
Opt_compress,
105+
Opt_witness,
105106

106107
/* Mount options which take numeric value */
107108
Opt_backupuid,
@@ -241,6 +242,7 @@ struct smb3_fs_context {
241242
unsigned int max_channels;
242243
__u16 compression; /* compression algorithm 0xFFFF default 0=disabled */
243244
bool rootfs:1; /* if it's a SMB root file system */
245+
bool witness:1; /* use witness protocol */
244246

245247
char *mount_options;
246248
};

0 commit comments

Comments
 (0)