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
638 seq_printf(s, ",multichannel,max_channels=%zu",638 seq_printf(s, ",multichannel,max_channels=%zu",
639 tcon->ses->chan_max);639 tcon->ses->chan_max);
640 640
641#ifdef CONFIG_CIFS_SWN_UPCALL
642 if (tcon->use_witness)
643 seq_puts(s, ",witness");
644#endif
645
641 return 0;646 return 0;
642}647}
643 648
fs/cifs/cifsglob.h+3−0
@@ -1086,6 +1086,9 @@ struct cifs_tcon { · 1085 unmodified lines
1086 int remap:2;1086 int remap:2;
1087 struct list_head ulist; /* cache update list */1087 struct list_head ulist; /* cache update list */
1088#endif1088#endif
1089#ifdef CONFIG_CIFS_SWN_UPCALL
1090 bool use_witness:1; /* use witness protocol */
1091#endif
1089};1092};
1090 1093
1091/*1094/*
fs/cifs/connect.c+25−0
@@ -1944,6 +1944,8 @@ cifs_put_tcon(struct cifs_tcon *tcon) · 1943 unmodified lines
1944 return;1944 return;
1945 }1945 }
1946 1946
1947 /* TODO witness unregister */
1948
1947 list_del_init(&tcon->tcon_list);1949 list_del_init(&tcon->tcon_list);
1948 spin_unlock(&cifs_tcp_ses_lock);1950 spin_unlock(&cifs_tcp_ses_lock);
1949 1951
@@ -2104,6 +2106,26 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx) · 154 unmodified lines
2104 }2106 }
2105 tcon->use_resilient = true;2107 tcon->use_resilient = true;
2106 }2108 }
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
2107 2129
2108 /* If the user really knows what they are doing they can override */2130 /* If the user really knows what they are doing they can override */
2109 if (tcon->share_flags & SMB2_SHAREFLAG_NO_CACHING) {2131 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
3856 ctx->sectype = master_tcon->ses->sectype;3878 ctx->sectype = master_tcon->ses->sectype;
3857 ctx->sign = master_tcon->ses->sign;3879 ctx->sign = master_tcon->ses->sign;
3858 ctx->seal = master_tcon->seal;3880 ctx->seal = master_tcon->seal;
3881#ifdef CONFIG_CIFS_SWN_UPCALL
3882 ctx->witness = master_tcon->use_witness;
3883#endif
3859 3884
3860 rc = cifs_set_vol_auth(ctx, master_tcon->ses);3885 rc = cifs_set_vol_auth(ctx, master_tcon->ses);
3861 if (rc) {3886 if (rc) {
fs/cifs/fs_context.c+8−0
@@ -119,6 +119,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = { · 118 unmodified lines
119 fsparam_flag("modesid", Opt_modesid),119 fsparam_flag("modesid", Opt_modesid),
120 fsparam_flag("rootfs", Opt_rootfs),120 fsparam_flag("rootfs", Opt_rootfs),
121 fsparam_flag("compress", Opt_compress),121 fsparam_flag("compress", Opt_compress),
122 fsparam_flag("witness", Opt_witness),
122 123
123 /* Mount options which take numeric value */124 /* Mount options which take numeric value */
124 fsparam_u32("backupuid", Opt_backupuid),125 fsparam_u32("backupuid", Opt_backupuid),
@@ -1004,6 +1005,13 @@ static int smb3_fs_context_parse_param(struct fs_context *fc, · 879 unmodified lines
1004 if (cifs_parse_cache_flavor(param->string, ctx) != 0)1005 if (cifs_parse_cache_flavor(param->string, ctx) != 0)
1005 goto cifs_parse_mount_err;1006 goto cifs_parse_mount_err;
1006 break;1007 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;
1007 case Opt_rootfs:1015 case Opt_rootfs:
1008#ifdef CONFIG_CIFS_ROOT1016#ifdef CONFIG_CIFS_ROOT
1009 ctx->rootfs = true;1017 ctx->rootfs = true;
fs/cifs/fs_context.h+2−0
@@ -102,6 +102,7 @@ enum cifs_param { · 101 unmodified lines
102 Opt_rootfs,102 Opt_rootfs,
103 Opt_multichannel,103 Opt_multichannel,
104 Opt_compress,104 Opt_compress,
105 Opt_witness,
105 106
106 /* Mount options which take numeric value */107 /* Mount options which take numeric value */
107 Opt_backupuid,108 Opt_backupuid,
@@ -241,6 +242,7 @@ struct smb3_fs_context { · 133 unmodified lines
241 unsigned int max_channels;242 unsigned int max_channels;
242 __u16 compression; /* compression algorithm 0xFFFF default 0=disabled */243 __u16 compression; /* compression algorithm 0xFFFF default 0=disabled */
243 bool rootfs:1; /* if it's a SMB root file system */244 bool rootfs:1; /* if it's a SMB root file system */
245 bool witness:1; /* use witness protocol */
244 246
245 char *mount_options;247 char *mount_options;
246};248};