]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mount.ceph: collect v2 addresses for non-legacy ms_mode options 40763/head
authorJeff Layton <jlayton@redhat.com>
Wed, 6 Jan 2021 14:30:13 +0000 (09:30 -0500)
committerNathan Cutler <ncutler@suse.com>
Sat, 10 Apr 2021 20:55:46 +0000 (22:55 +0200)
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>
(cherry picked from commit 50da7ad7f0a5b75314c51ca4f4c1f2c013c0e8b8)

src/mount/conf.cc
src/mount/mount.ceph.c
src/mount/mount.ceph.h

index 014cc821c00d3991a9ab1ea52a2857353b619457..4cf635ab944ce963a2d7a2254de6a26b0ecdb80c 100644 (file)
@@ -16,6 +16,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;
@@ -48,9 +49,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 3e34c8459be14a7d154a0e3c7244afb011ddb15c..6da74ef4c563e24c951dbb4ceb0d0e8d1865ed72 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 */
@@ -315,6 +316,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 {
                        skip = false;
                        mount_ceph_debug("mount.ceph: unrecognized mount option \"%s\", passing to kernel.\n",
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
 }