Skip to content

Commit

Permalink
Merge PR ceph#38788 into master
Browse files Browse the repository at this point in the history
* refs/pull/38788/head:
	mount.ceph: collect v2 addresses for non-legacy ms_mode options

Reviewed-by: Ilya Dryomov <[email protected]>
Reviewed-by: Patrick Donnelly <[email protected]>
  • Loading branch information
batrick committed Jan 11, 2021
2 parents a59ecd3 + 50da7ad commit 5304a13
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/mount/conf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
11 changes: 10 additions & 1 deletion src/mount/mount.ceph.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/mount/mount.ceph.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 5304a13

Please sign in to comment.