From 963cafe673af8ea8c2d9131b6c199ad8117d8453 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Wed, 6 Jan 2021 09:30:13 -0500 Subject: [PATCH] mount.ceph: collect v2 addresses for non-legacy ms_mode options 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 (cherry picked from commit 50da7ad7f0a5b75314c51ca4f4c1f2c013c0e8b8) --- src/mount/conf.cc | 15 ++++++++++++--- src/mount/mount.ceph.c | 11 ++++++++++- src/mount/mount.ceph.h | 2 +- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/mount/conf.cc b/src/mount/conf.cc index 228f53e72187f..3acb426aac9eb 100644 --- a/src/mount/conf.cc +++ b/src/mount/conf.cc @@ -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(); diff --git a/src/mount/mount.ceph.c b/src/mount/mount.ceph.c index 133bc554f5088..10a76c43517b3 100644 --- a/src/mount/mount.ceph.c +++ b/src/mount/mount.ceph.c @@ -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", diff --git a/src/mount/mount.ceph.h b/src/mount/mount.ceph.h index b61176923d8dd..673175db5a8e9 100644 --- a/src/mount/mount.ceph.h +++ b/src/mount/mount.ceph.h @@ -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 } -- 2.39.5