]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mount.ceph: collect v2 addresses for non-legacy ms_mode options 38788/head
authorJeff Layton <jlayton@redhat.com>
Wed, 6 Jan 2021 14:30:13 +0000 (09:30 -0500)
committerJeff Layton <jlayton@redhat.com>
Thu, 7 Jan 2021 13:37:57 +0000 (08:37 -0500)
The kclient recently had support for msgr2 merged, and with that we have
a new ms_mode mount option. The mount helper's support for autodiscovery
of mons currently always ignores v2 addresses.

Change the helper to look for the ms_mode in the provided options and if
it's set to anything but "legacy", have it collect v2 addresses instead
of v1 addrs. The default is still "legacy" so if the option is not
provided, we will still collect v1 addrs.

Fixes: https://tracker.ceph.com/issues/48765
Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/mount/conf.cc
src/mount/mount.ceph.c
src/mount/mount.ceph.h

index 7957683175ee75a4bae6686dd77e73bd6bdb0022..104969eefbf39830c7c58f379b44cafd2ef71e10 100644 (file)
@@ -20,6 +20,7 @@
 
 extern "C" void mount_ceph_get_config_info(const char *config_file,
                                           const char *name,
+                                          bool v2_addrs,
                                           struct ceph_config_info *cci)
 {
   int err;
@@ -53,9 +54,17 @@ extern "C" void mount_ceph_get_config_info(const char *config_file,
   for (const auto& mon : monc.monmap.addr_mons) {
     auto& eaddr = mon.first;
 
-    // For now, kernel client only accepts legacy addrs
-    if (!eaddr.is_legacy())
-      continue;
+    /*
+     * Filter v1 addrs if we're running in ms_mode=legacy. Filter
+     * v2 addrs for any other ms_mode.
+     */
+    if (v2_addrs) {
+      if (!eaddr.is_msgr2())
+       continue;
+    } else {
+      if (!eaddr.is_legacy())
+       continue;
+    }
 
     std::string addr;
     addr += eaddr.ip_only_to_str();
index 33acafb935db9ae682c4ee6f810c62e6f4c6e4e1..af3e4389fbf6bb5d0ec61c86a830498dcf54b828 100644 (file)
@@ -19,6 +19,7 @@
 
 bool verboseflag = false;
 bool skip_mtab_flag = false;
+bool v2_addrs = false;
 static const char * const EMPTY_STRING = "";
 
 /* TODO duplicates logic from kernel */
@@ -155,7 +156,7 @@ static int fetch_config_info(struct ceph_mount_info *cmi)
                ret = drop_capabilities();
                if (ret)
                        exit(1);
-               mount_ceph_get_config_info(cmi->cmi_conf, cmi->cmi_name, cci);
+               mount_ceph_get_config_info(cmi->cmi_conf, cmi->cmi_name, v2_addrs, cci);
                exit(0);
        } else {
                /* parent */
@@ -318,6 +319,14 @@ static int parse_options(const char *data, struct ceph_mount_info *cmi)
                        /* keep pointer to value */
                        name = value;
                        skip = false;
+               } else if (strcmp(data, "ms_mode") == 0) {
+                       if (!value || !*value) {
+                               fprintf(stderr, "mount option ms_mode requires a value.\n");
+                               return -EINVAL;
+                       }
+                       /* Only legacy ms_mode needs v1 addrs */
+                       v2_addrs = strcmp(value, "legacy");
+                       skip = false;
                } else {
                        /* unrecognized mount options, passing to kernel */
                        skip = false;
index b61176923d8dd5e1090244c90b0bb3158b6632d1..673175db5a8e9f23ec14bde4ad4d3eb93e69d637 100644 (file)
@@ -32,7 +32,7 @@ struct ceph_config_info {
 };
 
 void mount_ceph_get_config_info(const char *config_file, const char *name,
-                               struct ceph_config_info *cci);
+                               bool v2_addrs, struct ceph_config_info *cci);
 
 #ifdef __cplusplus
 }