diff options
author | Jeff Layton <jlayton@redhat.com> | 2021-01-06 15:30:13 +0100 |
---|---|---|
committer | Jeff Layton <jlayton@redhat.com> | 2021-01-07 14:37:57 +0100 |
commit | 50da7ad7f0a5b75314c51ca4f4c1f2c013c0e8b8 (patch) | |
tree | ea055486c2abf72fb4c88418452691fb56f22646 /src/mount | |
parent | Merge pull request #38784 from sebastian-philipp/resurect-doc-dev-cephadm (diff) | |
download | ceph-50da7ad7f0a5b75314c51ca4f4c1f2c013c0e8b8.tar.xz ceph-50da7ad7f0a5b75314c51ca4f4c1f2c013c0e8b8.zip |
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 <jlayton@redhat.com>
Diffstat (limited to 'src/mount')
-rw-r--r-- | src/mount/conf.cc | 15 | ||||
-rw-r--r-- | src/mount/mount.ceph.c | 11 | ||||
-rw-r--r-- | 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 7957683175e..104969eefbf 100644 --- a/src/mount/conf.cc +++ b/src/mount/conf.cc @@ -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(); diff --git a/src/mount/mount.ceph.c b/src/mount/mount.ceph.c index 33acafb935d..af3e4389fbf 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 */ @@ -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; diff --git a/src/mount/mount.ceph.h b/src/mount/mount.ceph.h index b61176923d8..673175db5a8 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 } |