History

cifs: add witness mount option and data structs

Add 'witness' mount option to register for witness notifications.

Samuel Cabrero committed 5 years ago

Commit 0ac4e291 parent 06f08da5 files · +43 −0Browse files

Unified · Split

5 files
  1. fs/cifs/cifsfs.c +5 −0
  2. fs/cifs/cifsglob.h +3 −0
  3. fs/cifs/connect.c +25 −0
  4. fs/cifs/fs_context.c +8 −0
  5. fs/cifs/fs_context.h +2 −0
fs/cifs/cifsfs.c+5−0
@@ -638,6 +638,11 @@ cifs_show_options(struct seq_file *s, struct dentry *root) · 637 unmodified lines
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+3−0
@@ -1086,6 +1086,9 @@ struct cifs_tcon { · 1085 unmodified lines
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+25−0
@@ -1944,6 +1944,8 @@ cifs_put_tcon(struct cifs_tcon *tcon) · 1943 unmodified lines
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) · 154 unmodified lines
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) · 1746 unmodified lines
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+8−0
@@ -119,6 +119,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = { · 118 unmodified lines
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, · 879 unmodified lines
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+2−0
@@ -102,6 +102,7 @@ enum cifs_param { · 101 unmodified lines
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 { · 133 unmodified lines
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 };