Add 'witness' mount option to register for witness notifications.
Unified · Split
| @@ -638,6 +638,11 @@ cifs_show_options(struct seq_file *s, struct dentry *root) · 637 unmodified lines | ||
| 638 | 638 | seq_printf(s, ",multichannel,max_channels=%zu", |
| 639 | 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 | 646 | return 0; |
| 642 | 647 | } |
| 643 | 648 | |
| @@ -1086,6 +1086,9 @@ struct cifs_tcon { · 1085 unmodified lines | ||
| 1086 | 1086 | int remap:2; |
| 1087 | 1087 | struct list_head ulist; /* cache update list */ |
| 1088 | 1088 | #endif |
| 1089 | +#ifdef CONFIG_CIFS_SWN_UPCALL | |
| 1090 | + bool use_witness:1; /* use witness protocol */ | |
| 1091 | +#endif | |
| 1089 | 1092 | }; |
| 1090 | 1093 | |
| 1091 | 1094 | /* |
| @@ -1944,6 +1944,8 @@ cifs_put_tcon(struct cifs_tcon *tcon) · 1943 unmodified lines | ||
| 1944 | 1944 | return; |
| 1945 | 1945 | } |
| 1946 | 1946 | |
| 1947 | + /* TODO witness unregister */ | |
| 1948 | + | |
| 1947 | 1949 | list_del_init(&tcon->tcon_list); |
| 1948 | 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 | 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 | 2130 | /* If the user really knows what they are doing they can override */ |
| 2109 | 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 | 3878 | ctx->sectype = master_tcon->ses->sectype; |
| 3857 | 3879 | ctx->sign = master_tcon->ses->sign; |
| 3858 | 3880 | ctx->seal = master_tcon->seal; |
| 3881 | +#ifdef CONFIG_CIFS_SWN_UPCALL | |
| 3882 | + ctx->witness = master_tcon->use_witness; | |
| 3883 | +#endif | |
| 3859 | 3884 | |
| 3860 | 3885 | rc = cifs_set_vol_auth(ctx, master_tcon->ses); |
| 3861 | 3886 | if (rc) { |
| @@ -119,6 +119,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = { · 118 unmodified lines | ||
| 119 | 119 | fsparam_flag("modesid", Opt_modesid), |
| 120 | 120 | fsparam_flag("rootfs", Opt_rootfs), |
| 121 | 121 | fsparam_flag("compress", Opt_compress), |
| 122 | + fsparam_flag("witness", Opt_witness), | |
| 122 | 123 | |
| 123 | 124 | /* Mount options which take numeric value */ |
| 124 | 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 | 1005 | if (cifs_parse_cache_flavor(param->string, ctx) != 0) |
| 1005 | 1006 | goto cifs_parse_mount_err; |
| 1006 | 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 | 1015 | case Opt_rootfs: |
| 1008 | 1016 | #ifdef CONFIG_CIFS_ROOT |
| 1009 | 1017 | ctx->rootfs = true; |
| @@ -102,6 +102,7 @@ enum cifs_param { · 101 unmodified lines | ||
| 102 | 102 | Opt_rootfs, |
| 103 | 103 | Opt_multichannel, |
| 104 | 104 | Opt_compress, |
| 105 | + Opt_witness, | |
| 105 | 106 | |
| 106 | 107 | /* Mount options which take numeric value */ |
| 107 | 108 | Opt_backupuid, |
| @@ -241,6 +242,7 @@ struct smb3_fs_context { · 133 unmodified lines | ||
| 241 | 242 | unsigned int max_channels; |
| 242 | 243 | __u16 compression; /* compression algorithm 0xFFFF default 0=disabled */ |
| 243 | 244 | bool rootfs:1; /* if it's a SMB root file system */ |
| 245 | + bool witness:1; /* use witness protocol */ | |
| 244 | 246 | |
| 245 | 247 | char *mount_options; |
| 246 | 248 | }; |