]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mount.ceph: collect v2 addresses for non-legacy ms_mode options 39133/head
authorJeff Layton <jlayton@redhat.com>
Wed, 6 Jan 2021 14:30:13 +0000 (09:30 -0500)
committerNathan Cutler <ncutler@suse.com>
Thu, 28 Jan 2021 12:54:40 +0000 (13:54 +0100)
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 228f53e72187fcd6f1d8a2cbaf360b88d74d45eb..3acb426aac9eb9e03a2854bc53d7a717bcce916c 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 133bc554f50882c46ffcd5b4215342b66e200d13..10a76c43517b361cbbc39b24efa214e4a7bad706 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 */
@@ -308,6 +309,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
 }