X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fkrbd.cc;h=5e011d7a9a077becce2b83cfac72f8390948ec1d;hb=adb31ebba1b9f736f0a7e05b9be808af79cfce80;hp=0d463dea52e92dfa7085044e32afb657d8ed054e;hpb=8b89984e92223ec320fb4c70589c39f384c86985;p=ceph.git diff --git a/ceph/src/krbd.cc b/ceph/src/krbd.cc index 0d463dea5..5e011d7a9 100644 --- a/ceph/src/krbd.cc +++ b/ceph/src/krbd.cc @@ -44,6 +44,7 @@ #include #include +#include #include static const int UDEV_BUF_SIZE = 1 << 20; /* doubled to 2M (SO_RCVBUFFORCE) */ @@ -184,24 +185,39 @@ static int have_minor_attr(void) } static int build_map_buf(CephContext *cct, const krbd_spec& spec, - const char *options, string *pbuf) + const string& options, string *pbuf) { + bool msgr2 = false; ostringstream oss; int r; + boost::char_separator sep(","); + boost::tokenizer> tok(options, sep); + for (const auto& t : tok) { + if (boost::starts_with(t, "ms_mode=")) { + /* msgr2 unless ms_mode=legacy */ + msgr2 = t.compare(8, t.npos, "legacy"); + } + } + MonMap monmap; r = monmap.build_initial(cct, false, cerr); if (r < 0) return r; - list mon_addr; - monmap.list_addrs(mon_addr); - - for (const auto &p : mon_addr) { - if (oss.tellp() > 0) { - oss << ","; + /* + * If msgr2, filter TYPE_MSGR2 addresses. Otherwise, filter + * TYPE_LEGACY addresses. + */ + for (const auto& p : monmap.mon_info) { + for (const auto& a : p.second.public_addrs.v) { + if ((msgr2 && a.is_msgr2()) || (!msgr2 && a.is_legacy())) { + if (oss.tellp() > 0) { + oss << ","; + } + oss << a.get_sockaddr(); + } } - oss << p.get_sockaddr(); } oss << " name=" << cct->_conf->name.get_id(); @@ -244,7 +260,7 @@ static int build_map_buf(CephContext *cct, const krbd_spec& spec, oss << ",key=" << key_name; } - if (strcmp(options, "") != 0) + if (!options.empty()) oss << "," << options; if (!spec.nspace_name.empty()) oss << ",_pool_ns=" << spec.nspace_name;