cifs: move smb version mount options into fs_context.c
authorRonnie Sahlberg <lsahlber@redhat.com>
Wed, 21 Oct 2020 02:10:44 +0000 (12:10 +1000)
committerSteve French <stfrench@microsoft.com>
Thu, 22 Oct 2020 17:17:31 +0000 (12:17 -0500)
This and related patches which move mount related
code to fs_context.c has the advantage of
shriking the code in fs/cifs/connect.c (which had
the second most lines of code of any of the files
in cifs.ko and was getting harder to read due
to its size) and will also make it easier to
switch over to the new mount API in the future.

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/cifsglob.h
fs/cifs/connect.c
fs/cifs/fs_context.c
fs/cifs/fs_context.h

index a1a1a16..b6925ae 100644 (file)
@@ -195,18 +195,6 @@ struct smb_rqst {
        unsigned int    rq_tailsz;      /* length of last page */
 };
 
-enum smb_version {
-       Smb_1 = 1,
-       Smb_20,
-       Smb_21,
-       Smb_30,
-       Smb_302,
-       Smb_311,
-       Smb_3any,
-       Smb_default,
-       Smb_version_err
-};
-
 struct mid_q_entry;
 struct TCP_Server_Info;
 struct cifsFileInfo;
index f7ef38a..c38156f 100644 (file)
@@ -280,20 +280,6 @@ static const match_table_t cifs_mount_option_tokens = {
        { Opt_err, NULL }
 };
 
-static const match_table_t cifs_smb_version_tokens = {
-       { Smb_1, SMB1_VERSION_STRING },
-       { Smb_20, SMB20_VERSION_STRING},
-       { Smb_21, SMB21_VERSION_STRING },
-       { Smb_30, SMB30_VERSION_STRING },
-       { Smb_302, SMB302_VERSION_STRING },
-       { Smb_302, ALT_SMB302_VERSION_STRING },
-       { Smb_311, SMB311_VERSION_STRING },
-       { Smb_311, ALT_SMB311_VERSION_STRING },
-       { Smb_3any, SMB3ANY_VERSION_STRING },
-       { Smb_default, SMBDEFAULT_VERSION_STRING },
-       { Smb_version_err, NULL }
-};
-
 static int ip_connect(struct TCP_Server_Info *server);
 static int generic_ip_connect(struct TCP_Server_Info *server);
 static void tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink);
@@ -1327,77 +1313,6 @@ static int get_option_gid(substring_t args[], kgid_t *result)
        return 0;
 }
 
-static int
-cifs_parse_smb_version(char *value, struct smb_vol *vol, bool is_smb3)
-{
-       substring_t args[MAX_OPT_ARGS];
-
-       switch (match_token(value, cifs_smb_version_tokens, args)) {
-#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
-       case Smb_1:
-               if (disable_legacy_dialects) {
-                       cifs_dbg(VFS, "mount with legacy dialect disabled\n");
-                       return 1;
-               }
-               if (is_smb3) {
-                       cifs_dbg(VFS, "vers=1.0 (cifs) not permitted when mounting with smb3\n");
-                       return 1;
-               }
-               cifs_dbg(VFS, "Use of the less secure dialect vers=1.0 is not recommended unless required for access to very old servers\n");
-               vol->ops = &smb1_operations;
-               vol->vals = &smb1_values;
-               break;
-       case Smb_20:
-               if (disable_legacy_dialects) {
-                       cifs_dbg(VFS, "mount with legacy dialect disabled\n");
-                       return 1;
-               }
-               if (is_smb3) {
-                       cifs_dbg(VFS, "vers=2.0 not permitted when mounting with smb3\n");
-                       return 1;
-               }
-               vol->ops = &smb20_operations;
-               vol->vals = &smb20_values;
-               break;
-#else
-       case Smb_1:
-               cifs_dbg(VFS, "vers=1.0 (cifs) mount not permitted when legacy dialects disabled\n");
-               return 1;
-       case Smb_20:
-               cifs_dbg(VFS, "vers=2.0 mount not permitted when legacy dialects disabled\n");
-               return 1;
-#endif /* CIFS_ALLOW_INSECURE_LEGACY */
-       case Smb_21:
-               vol->ops = &smb21_operations;
-               vol->vals = &smb21_values;
-               break;
-       case Smb_30:
-               vol->ops = &smb30_operations;
-               vol->vals = &smb30_values;
-               break;
-       case Smb_302:
-               vol->ops = &smb30_operations; /* currently identical with 3.0 */
-               vol->vals = &smb302_values;
-               break;
-       case Smb_311:
-               vol->ops = &smb311_operations;
-               vol->vals = &smb311_values;
-               break;
-       case Smb_3any:
-               vol->ops = &smb30_operations; /* currently identical with 3.0 */
-               vol->vals = &smb3any_values;
-               break;
-       case Smb_default:
-               vol->ops = &smb30_operations; /* currently identical with 3.0 */
-               vol->vals = &smbdefault_values;
-               break;
-       default:
-               cifs_dbg(VFS, "Unknown vers= option specified: %s\n", value);
-               return 1;
-       }
-       return 0;
-}
-
 /*
  * Parse a devname into substrings and populate the vol->UNC and vol->prepath
  * fields with the result. Returns 0 on success and an error otherwise.
index deb1168..ad6c2fe 100644 (file)
 #include "cifs_debug.h"
 #include "fs_context.h"
 
+static const match_table_t cifs_smb_version_tokens = {
+       { Smb_1, SMB1_VERSION_STRING },
+       { Smb_20, SMB20_VERSION_STRING},
+       { Smb_21, SMB21_VERSION_STRING },
+       { Smb_30, SMB30_VERSION_STRING },
+       { Smb_302, SMB302_VERSION_STRING },
+       { Smb_302, ALT_SMB302_VERSION_STRING },
+       { Smb_311, SMB311_VERSION_STRING },
+       { Smb_311, ALT_SMB311_VERSION_STRING },
+       { Smb_3any, SMB3ANY_VERSION_STRING },
+       { Smb_default, SMBDEFAULT_VERSION_STRING },
+       { Smb_version_err, NULL }
+};
+
+int
+cifs_parse_smb_version(char *value, struct smb_vol *vol, bool is_smb3)
+{
+       substring_t args[MAX_OPT_ARGS];
+
+       switch (match_token(value, cifs_smb_version_tokens, args)) {
+#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
+       case Smb_1:
+               if (disable_legacy_dialects) {
+                       cifs_dbg(VFS, "mount with legacy dialect disabled\n");
+                       return 1;
+               }
+               if (is_smb3) {
+                       cifs_dbg(VFS, "vers=1.0 (cifs) not permitted when mounting with smb3\n");
+                       return 1;
+               }
+               cifs_dbg(VFS, "Use of the less secure dialect vers=1.0 is not recommended unless required for access to very old servers\n");
+               vol->ops = &smb1_operations;
+               vol->vals = &smb1_values;
+               break;
+       case Smb_20:
+               if (disable_legacy_dialects) {
+                       cifs_dbg(VFS, "mount with legacy dialect disabled\n");
+                       return 1;
+               }
+               if (is_smb3) {
+                       cifs_dbg(VFS, "vers=2.0 not permitted when mounting with smb3\n");
+                       return 1;
+               }
+               vol->ops = &smb20_operations;
+               vol->vals = &smb20_values;
+               break;
+#else
+       case Smb_1:
+               cifs_dbg(VFS, "vers=1.0 (cifs) mount not permitted when legacy dialects disabled\n");
+               return 1;
+       case Smb_20:
+               cifs_dbg(VFS, "vers=2.0 mount not permitted when legacy dialects disabled\n");
+               return 1;
+#endif /* CIFS_ALLOW_INSECURE_LEGACY */
+       case Smb_21:
+               vol->ops = &smb21_operations;
+               vol->vals = &smb21_values;
+               break;
+       case Smb_30:
+               vol->ops = &smb30_operations;
+               vol->vals = &smb30_values;
+               break;
+       case Smb_302:
+               vol->ops = &smb30_operations; /* currently identical with 3.0 */
+               vol->vals = &smb302_values;
+               break;
+       case Smb_311:
+               vol->ops = &smb311_operations;
+               vol->vals = &smb311_values;
+               break;
+       case Smb_3any:
+               vol->ops = &smb30_operations; /* currently identical with 3.0 */
+               vol->vals = &smb3any_values;
+               break;
+       case Smb_default:
+               vol->ops = &smb30_operations; /* currently identical with 3.0 */
+               vol->vals = &smbdefault_values;
+               break;
+       default:
+               cifs_dbg(VFS, "Unknown vers= option specified: %s\n", value);
+               return 1;
+       }
+       return 0;
+}
+
 static const match_table_t cifs_secflavor_tokens = {
        { Opt_sec_krb5, "krb5" },
        { Opt_sec_krb5i, "krb5i" },
index 3e3f6e2..886208a 100644 (file)
 #include <linux/parser.h>
 #include "cifsglob.h"
 
+enum smb_version {
+       Smb_1 = 1,
+       Smb_20,
+       Smb_21,
+       Smb_30,
+       Smb_302,
+       Smb_311,
+       Smb_3any,
+       Smb_default,
+       Smb_version_err
+};
+
+int cifs_parse_smb_version(char *value, struct smb_vol *vol, bool is_smb3);
+
 enum {
        Opt_cache_loose,
        Opt_cache_strict,