Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Samuel Cabrero and committed by
Steve French
0ac4e291 06f08dab

+43
+5
fs/cifs/cifsfs.c
··· 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
+3
fs/cifs/cifsglob.h
··· 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 /*
+25
fs/cifs/connect.c
··· 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 ··· 2106 2104 } 2107 2105 tcon->use_resilient = true; 2108 2106 } 2107 + #ifdef CONFIG_CIFS_SWN_UPCALL 2108 + tcon->use_witness = false; 2109 + if (ctx->witness) { 2110 + if (ses->server->vals->protocol_id >= SMB30_PROT_ID) { 2111 + if (tcon->capabilities & SMB2_SHARE_CAP_CLUSTER) { 2112 + /* TODO witness register */ 2113 + tcon->use_witness = true; 2114 + } else { 2115 + /* TODO: try to extend for non-cluster uses (eg multichannel) */ 2116 + cifs_dbg(VFS, "witness requested on mount but no CLUSTER capability on share\n"); 2117 + rc = -EOPNOTSUPP; 2118 + goto out_fail; 2119 + } 2120 + } else { 2121 + cifs_dbg(VFS, "SMB3 or later required for witness option\n"); 2122 + rc = -EOPNOTSUPP; 2123 + goto out_fail; 2124 + } 2125 + } 2126 + #endif 2109 2127 2110 2128 /* If the user really knows what they are doing they can override */ 2111 2129 if (tcon->share_flags & SMB2_SHAREFLAG_NO_CACHING) { ··· 3878 3856 ctx->sectype = master_tcon->ses->sectype; 3879 3857 ctx->sign = master_tcon->ses->sign; 3880 3858 ctx->seal = master_tcon->seal; 3859 + #ifdef CONFIG_CIFS_SWN_UPCALL 3860 + ctx->witness = master_tcon->use_witness; 3861 + #endif 3881 3862 3882 3863 rc = cifs_set_vol_auth(ctx, master_tcon->ses); 3883 3864 if (rc) {
+8
fs/cifs/fs_context.c
··· 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 1003 case Opt_cache: 1005 1004 if (cifs_parse_cache_flavor(param->string, ctx) != 0) 1006 1005 goto cifs_parse_mount_err; 1006 + break; 1007 + case Opt_witness: 1008 + #ifndef CONFIG_CIFS_SWN_UPCALL 1009 + cifs_dbg(VFS, "Witness support needs CONFIG_CIFS_SWN_UPCALL config option\n"); 1010 + goto cifs_parse_mount_err; 1011 + #endif 1012 + ctx->witness = true; 1007 1013 break; 1008 1014 case Opt_rootfs: 1009 1015 #ifdef CONFIG_CIFS_ROOT
+2
fs/cifs/fs_context.h
··· 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, ··· 242 241 unsigned int max_channels; 243 242 __u16 compression; /* compression algorithm 0xFFFF default 0=disabled */ 244 243 bool rootfs:1; /* if it's a SMB root file system */ 244 + bool witness:1; /* use witness protocol */ 245 245 246 246 char *mount_options; 247 247 };