osd_weight[o] = CEPH_OSD_OUT;
}
osd_info.resize(m);
- osd_addr.resize(m);
- osd_cluster_addr.resize(m);
- osd_hb_addr.resize(m);
+ osd_addrs->client_addr.resize(m);
+ osd_addrs->cluster_addr.resize(m);
+ osd_addrs->hb_addr.resize(m);
calc_num_osds();
}
int OSDMap::identify_osd(const entity_addr_t& addr) const
{
- for (unsigned i=0; i<osd_addr.size(); i++)
- if ((osd_addr[i] == addr) || (osd_cluster_addr[i] == addr))
+ for (int i=0; i<max_osd; i++)
+ if ((get_addr(i) == addr) || (get_cluster_addr(i) == addr))
return i;
return -1;
}
bool OSDMap::find_osd_on_ip(const entity_addr_t& ip) const
{
- for (unsigned i=0; i<osd_addr.size(); i++)
- if (osd_addr[i].is_same_host(ip) || osd_cluster_addr[i].is_same_host(ip))
+ for (int i=0; i<max_osd; i++)
+ if (get_addr(i).is_same_host(ip) || get_cluster_addr(i).is_same_host(ip))
return i;
return -1;
}
i != inc.new_up_client.end();
i++) {
osd_state[i->first] |= CEPH_OSD_EXISTS | CEPH_OSD_UP;
- osd_addr[i->first] = i->second;
+ osd_addrs->client_addr[i->first].reset(new entity_addr_t(i->second));
if (inc.new_hb_up.empty())
- osd_hb_addr[i->first] = i->second; //this is a backward-compatibility hack
+ osd_addrs->hb_addr[i->first].reset(new entity_addr_t(i->second)); //this is a backward-compatibility hack
else
- osd_hb_addr[i->first] = inc.new_hb_up[i->first];
+ osd_addrs->hb_addr[i->first].reset(new entity_addr_t(inc.new_hb_up[i->first]));
osd_info[i->first].up_from = epoch;
}
for (map<int32_t,entity_addr_t>::iterator i = inc.new_up_internal.begin();
i != inc.new_up_internal.end();
i++)
- osd_cluster_addr[i->first] = i->second;
+ osd_addrs->cluster_addr[i->first].reset(new entity_addr_t(i->second));
// info
for (map<int32_t,epoch_t>::iterator i = inc.new_up_thru.begin();
i != inc.new_up_thru.end();
::encode(max_osd, bl);
::encode(osd_state, bl);
::encode(osd_weight, bl);
- ::encode(osd_addr, bl);
+ ::encode(osd_addrs->client_addr, bl);
// for ::encode(pg_temp, bl);
n = pg_temp.size();
::encode(max_osd, bl);
::encode(osd_state, bl);
::encode(osd_weight, bl);
- ::encode(osd_addr, bl);
+ ::encode(osd_addrs->client_addr, bl);
::encode(pg_temp, bl);
// extended
__u16 ev = CEPH_OSDMAP_VERSION_EXT;
::encode(ev, bl);
- ::encode(osd_hb_addr, bl);
+ ::encode(osd_addrs->hb_addr, bl);
::encode(osd_info, bl);
::encode(blacklist, bl);
- ::encode(osd_cluster_addr, bl);
+ ::encode(osd_addrs->cluster_addr, bl);
::encode(cluster_snapshot_epoch, bl);
::encode(cluster_snapshot, bl);
}
::decode(max_osd, p);
::decode(osd_state, p);
::decode(osd_weight, p);
- ::decode(osd_addr, p);
+ ::decode(osd_addrs->client_addr, p);
if (v <= 5) {
pg_temp.clear();
::decode(n, p);
__u16 ev = 0;
if (v >= 5)
::decode(ev, p);
- ::decode(osd_hb_addr, p);
+ ::decode(osd_addrs->hb_addr, p);
::decode(osd_info, p);
if (v < 5)
::decode(pool_name, p);
::decode(blacklist, p);
if (ev >= 6)
- ::decode(osd_cluster_addr, p);
+ ::decode(osd_addrs->cluster_addr, p);
else
- osd_cluster_addr.resize(osd_addr.size());
+ osd_addrs->cluster_addr.resize(osd_addrs->client_addr.size());
if (ev >= 7) {
::decode(cluster_snapshot_epoch, p);
int num_osd; // not saved
int32_t max_osd;
vector<uint8_t> osd_state;
- vector<entity_addr_t> osd_addr;
- vector<entity_addr_t> osd_cluster_addr;
- vector<entity_addr_t> osd_hb_addr;
+
+ struct addrs_s {
+ vector<std::tr1::shared_ptr<entity_addr_t> > client_addr;
+ vector<std::tr1::shared_ptr<entity_addr_t> > cluster_addr;
+ vector<std::tr1::shared_ptr<entity_addr_t> > hb_addr;
+ };
+ std::tr1::shared_ptr<addrs_s> osd_addrs;
+
vector<__u32> osd_weight; // 16.16 fixed point, 0x10000 = "in", 0 = "out"
vector<osd_info_t> osd_info;
map<pg_t,vector<int> > pg_temp; // temp pg mapping (e.g. while we rebuild)
pool_max(-1),
flags(0),
num_osd(0), max_osd(0),
+ osd_addrs(new addrs_s),
cluster_snapshot_epoch(0) {
memset(&fsid, 0, sizeof(fsid));
}
}
const entity_addr_t &get_addr(int osd) const {
assert(exists(osd));
- return osd_addr[osd];
+ return *osd_addrs->client_addr[osd];
}
const entity_addr_t &get_cluster_addr(int osd) const {
assert(exists(osd));
- if (osd_cluster_addr[osd] == entity_addr_t())
+ if (*osd_addrs->cluster_addr[osd] == entity_addr_t())
return get_addr(osd);
- return osd_cluster_addr[osd];
+ return *osd_addrs->cluster_addr[osd];
}
const entity_addr_t &get_hb_addr(int osd) const {
assert(exists(osd));
- return osd_hb_addr[osd];
+ return *osd_addrs->hb_addr[osd];
}
entity_inst_t get_inst(int osd) const {
- assert(exists(osd));
assert(is_up(osd));
- return entity_inst_t(entity_name_t::OSD(osd), osd_addr[osd]);
+ return entity_inst_t(entity_name_t::OSD(osd), get_addr(osd));
}
entity_inst_t get_cluster_inst(int osd) const {
- assert(exists(osd));
assert(is_up(osd));
- if (osd_cluster_addr[osd] == entity_addr_t())
- return get_inst(osd);
- return entity_inst_t(entity_name_t::OSD(osd), osd_cluster_addr[osd]);
+ return entity_inst_t(entity_name_t::OSD(osd), get_cluster_addr(osd));
}
entity_inst_t get_hb_inst(int osd) const {
- assert(exists(osd));
assert(is_up(osd));
- return entity_inst_t(entity_name_t::OSD(osd), osd_hb_addr[osd]);
+ return entity_inst_t(entity_name_t::OSD(osd), get_hb_addr(osd));
}
const epoch_t& get_up_from(int osd) const {