Merge pull request #2108 from kevincox/sizeint

Fix size of network protocol intergers.

Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2014-07-18 09:15:09 -07:00
commit df8f486288
5 changed files with 28 additions and 27 deletions

View File

@ -22,7 +22,7 @@
class MOSDPGTemp : public PaxosServiceMessage { class MOSDPGTemp : public PaxosServiceMessage {
public: public:
epoch_t map_epoch; epoch_t map_epoch;
map<pg_t, vector<int> > pg_temp; map<pg_t, vector<int32_t> > pg_temp;
MOSDPGTemp(epoch_t e) : PaxosServiceMessage(MSG_OSD_PGTEMP, e), map_epoch(e) { } MOSDPGTemp(epoch_t e) : PaxosServiceMessage(MSG_OSD_PGTEMP, e), map_epoch(e) { }
MOSDPGTemp() : PaxosServiceMessage(MSG_OSD_PGTEMP, 0) {} MOSDPGTemp() : PaxosServiceMessage(MSG_OSD_PGTEMP, 0) {}

View File

@ -1465,7 +1465,7 @@ bool OSDMonitor::preprocess_pgtemp(MOSDPGTemp *m)
goto ignore; goto ignore;
} }
for (map<pg_t,vector<int> >::iterator p = m->pg_temp.begin(); p != m->pg_temp.end(); ++p) { for (map<pg_t,vector<int32_t> >::iterator p = m->pg_temp.begin(); p != m->pg_temp.end(); ++p) {
dout(20) << " " << p->first dout(20) << " " << p->first
<< (osdmap.pg_temp->count(p->first) ? (*osdmap.pg_temp)[p->first] : empty) << (osdmap.pg_temp->count(p->first) ? (*osdmap.pg_temp)[p->first] : empty)
<< " -> " << p->second << dendl; << " -> " << p->second << dendl;
@ -1517,7 +1517,7 @@ bool OSDMonitor::prepare_pgtemp(MOSDPGTemp *m)
{ {
int from = m->get_orig_source().num(); int from = m->get_orig_source().num();
dout(7) << "prepare_pgtemp e" << m->map_epoch << " from " << m->get_orig_source_inst() << dendl; dout(7) << "prepare_pgtemp e" << m->map_epoch << " from " << m->get_orig_source_inst() << dendl;
for (map<pg_t,vector<int> >::iterator p = m->pg_temp.begin(); p != m->pg_temp.end(); ++p) { for (map<pg_t,vector<int32_t> >::iterator p = m->pg_temp.begin(); p != m->pg_temp.end(); ++p) {
uint64_t pool = p->first.pool(); uint64_t pool = p->first.pool();
if (pending_inc.old_pools.count(pool)) { if (pending_inc.old_pools.count(pool)) {
dout(10) << __func__ << " ignore " << p->first << " -> " << p->second dout(10) << __func__ << " ignore " << p->first << " -> " << p->second
@ -5936,7 +5936,7 @@ int OSDMonitor::_prepare_remove_pool(int64_t pool, ostream *ss)
pending_inc.new_pg_temp[p->first].clear(); pending_inc.new_pg_temp[p->first].clear();
} }
} }
for (map<pg_t,int>::iterator p = osdmap.primary_temp->begin(); for (map<pg_t,int32_t>::iterator p = osdmap.primary_temp->begin();
p != osdmap.primary_temp->end(); p != osdmap.primary_temp->end();
++p) { ++p) {
if (p->first.pool() == (uint64_t)pool) { if (p->first.pool() == (uint64_t)pool) {

View File

@ -698,7 +698,7 @@ void OSDMap::Incremental::dump(Formatter *f) const
f->close_section(); f->close_section();
f->open_array_section("new_pg_temp"); f->open_array_section("new_pg_temp");
for (map<pg_t,vector<int> >::const_iterator p = new_pg_temp.begin(); for (map<pg_t,vector<int32_t> >::const_iterator p = new_pg_temp.begin();
p != new_pg_temp.end(); p != new_pg_temp.end();
++p) { ++p) {
f->open_object_section("pg"); f->open_object_section("pg");
@ -712,7 +712,7 @@ void OSDMap::Incremental::dump(Formatter *f) const
f->close_section(); f->close_section();
f->open_array_section("primary_temp"); f->open_array_section("primary_temp");
for (map<pg_t, int>::const_iterator p = new_primary_temp.begin(); for (map<pg_t, int32_t>::const_iterator p = new_primary_temp.begin();
p != new_primary_temp.end(); p != new_primary_temp.end();
++p) { ++p) {
f->dump_stream("pgid") << p->first; f->dump_stream("pgid") << p->first;
@ -1092,7 +1092,7 @@ void OSDMap::remove_redundant_temporaries(CephContext *cct, const OSDMap& osdmap
{ {
ldout(cct, 10) << "remove_redundant_temporaries" << dendl; ldout(cct, 10) << "remove_redundant_temporaries" << dendl;
for (map<pg_t,vector<int> >::iterator p = osdmap.pg_temp->begin(); for (map<pg_t,vector<int32_t> >::iterator p = osdmap.pg_temp->begin();
p != osdmap.pg_temp->end(); p != osdmap.pg_temp->end();
++p) { ++p) {
if (pending_inc->new_pg_temp.count(p->first) == 0) { if (pending_inc->new_pg_temp.count(p->first) == 0) {
@ -1109,7 +1109,7 @@ void OSDMap::remove_redundant_temporaries(CephContext *cct, const OSDMap& osdmap
OSDMap templess; OSDMap templess;
templess.deepish_copy_from(osdmap); templess.deepish_copy_from(osdmap);
templess.primary_temp->clear(); templess.primary_temp->clear();
for (map<pg_t,int>::iterator p = osdmap.primary_temp->begin(); for (map<pg_t,int32_t>::iterator p = osdmap.primary_temp->begin();
p != osdmap.primary_temp->end(); p != osdmap.primary_temp->end();
++p) { ++p) {
if (pending_inc->new_primary_temp.count(p->first) == 0) { if (pending_inc->new_primary_temp.count(p->first) == 0) {
@ -1135,11 +1135,11 @@ void OSDMap::remove_down_temps(CephContext *cct,
tmpmap.deepish_copy_from(osdmap); tmpmap.deepish_copy_from(osdmap);
tmpmap.apply_incremental(*pending_inc); tmpmap.apply_incremental(*pending_inc);
for (map<pg_t,vector<int> >::iterator p = tmpmap.pg_temp->begin(); for (map<pg_t,vector<int32_t> >::iterator p = tmpmap.pg_temp->begin();
p != tmpmap.pg_temp->end(); p != tmpmap.pg_temp->end();
++p) { ++p) {
unsigned num_up = 0; unsigned num_up = 0;
for (vector<int>::iterator i = p->second.begin(); for (vector<int32_t>::iterator i = p->second.begin();
i != p->second.end(); i != p->second.end();
++i) { ++i) {
if (!tmpmap.is_down(*i)) if (!tmpmap.is_down(*i))
@ -1148,7 +1148,7 @@ void OSDMap::remove_down_temps(CephContext *cct,
if (num_up == 0) if (num_up == 0)
pending_inc->new_pg_temp[p->first].clear(); pending_inc->new_pg_temp[p->first].clear();
} }
for (map<pg_t,int>::iterator p = tmpmap.primary_temp->begin(); for (map<pg_t,int32_t>::iterator p = tmpmap.primary_temp->begin();
p != tmpmap.primary_temp->end(); p != tmpmap.primary_temp->end();
++p) { ++p) {
if (tmpmap.is_down(p->second)) if (tmpmap.is_down(p->second))
@ -1307,7 +1307,7 @@ int OSDMap::apply_incremental(const Incremental &inc)
(*pg_temp)[p->first] = p->second; (*pg_temp)[p->first] = p->second;
} }
for (map<pg_t,int>::const_iterator p = inc.new_primary_temp.begin(); for (map<pg_t,int32_t>::const_iterator p = inc.new_primary_temp.begin();
p != inc.new_primary_temp.end(); p != inc.new_primary_temp.end();
++p) { ++p) {
if (p->second == -1) if (p->second == -1)
@ -1521,7 +1521,7 @@ void OSDMap::_get_temp_osds(const pg_pool_t& pool, pg_t pg,
vector<int> *temp_pg, int *temp_primary) const vector<int> *temp_pg, int *temp_primary) const
{ {
pg = pool.raw_pg_to_pg(pg); pg = pool.raw_pg_to_pg(pg);
map<pg_t,vector<int> >::const_iterator p = pg_temp->find(pg); map<pg_t,vector<int32_t> >::const_iterator p = pg_temp->find(pg);
temp_pg->clear(); temp_pg->clear();
if (p != pg_temp->end()) { if (p != pg_temp->end()) {
for (unsigned i=0; i<p->second.size(); i++) { for (unsigned i=0; i<p->second.size(); i++) {
@ -1536,7 +1536,7 @@ void OSDMap::_get_temp_osds(const pg_pool_t& pool, pg_t pg,
} }
} }
} }
map<pg_t,int>::const_iterator pp = primary_temp->find(pg); map<pg_t,int32_t>::const_iterator pp = primary_temp->find(pg);
*temp_primary = -1; *temp_primary = -1;
if (pp != primary_temp->end()) { if (pp != primary_temp->end()) {
*temp_primary = pp->second; *temp_primary = pp->second;
@ -2126,7 +2126,7 @@ void OSDMap::dump(Formatter *f) const
f->close_section(); f->close_section();
f->open_array_section("pg_temp"); f->open_array_section("pg_temp");
for (map<pg_t,vector<int> >::const_iterator p = pg_temp->begin(); for (map<pg_t,vector<int32_t> >::const_iterator p = pg_temp->begin();
p != pg_temp->end(); p != pg_temp->end();
++p) { ++p) {
f->open_object_section("osds"); f->open_object_section("osds");
@ -2140,7 +2140,7 @@ void OSDMap::dump(Formatter *f) const
f->close_section(); f->close_section();
f->open_array_section("primary_temp"); f->open_array_section("primary_temp");
for (map<pg_t, int>::const_iterator p = primary_temp->begin(); for (map<pg_t, int32_t>::const_iterator p = primary_temp->begin();
p != primary_temp->end(); p != primary_temp->end();
++p) { ++p) {
f->dump_stream("pgid") << p->first; f->dump_stream("pgid") << p->first;
@ -2274,12 +2274,12 @@ void OSDMap::print(ostream& out) const
} }
out << std::endl; out << std::endl;
for (map<pg_t,vector<int> >::const_iterator p = pg_temp->begin(); for (map<pg_t,vector<int32_t> >::const_iterator p = pg_temp->begin();
p != pg_temp->end(); p != pg_temp->end();
++p) ++p)
out << "pg_temp " << p->first << " " << p->second << "\n"; out << "pg_temp " << p->first << " " << p->second << "\n";
for (map<pg_t,int>::const_iterator p = primary_temp->begin(); for (map<pg_t,int32_t>::const_iterator p = primary_temp->begin();
p != primary_temp->end(); p != primary_temp->end();
++p) ++p)
out << "primary_temp " << p->first << " " << p->second << "\n"; out << "primary_temp " << p->first << " " << p->second << "\n";

View File

@ -140,7 +140,7 @@ public:
map<int32_t,uint8_t> new_state; // XORed onto previous state. map<int32_t,uint8_t> new_state; // XORed onto previous state.
map<int32_t,uint32_t> new_weight; map<int32_t,uint32_t> new_weight;
map<pg_t,vector<int32_t> > new_pg_temp; // [] to remove map<pg_t,vector<int32_t> > new_pg_temp; // [] to remove
map<pg_t, int> new_primary_temp; // [-1] to remove map<pg_t, int32_t> new_primary_temp; // [-1] to remove
map<int32_t,uint32_t> new_primary_affinity; map<int32_t,uint32_t> new_primary_affinity;
map<int32_t,epoch_t> new_up_thru; map<int32_t,epoch_t> new_up_thru;
map<int32_t,pair<epoch_t,epoch_t> > new_last_clean_interval; map<int32_t,pair<epoch_t,epoch_t> > new_last_clean_interval;
@ -222,8 +222,8 @@ private:
vector<__u32> osd_weight; // 16.16 fixed point, 0x10000 = "in", 0 = "out" vector<__u32> osd_weight; // 16.16 fixed point, 0x10000 = "in", 0 = "out"
vector<osd_info_t> osd_info; vector<osd_info_t> osd_info;
ceph::shared_ptr< map<pg_t,vector<int> > > pg_temp; // temp pg mapping (e.g. while we rebuild) ceph::shared_ptr< map<pg_t,vector<int32_t> > > pg_temp; // temp pg mapping (e.g. while we rebuild)
ceph::shared_ptr< map<pg_t,int > > primary_temp; // temp primary mapping (e.g. while we rebuild) ceph::shared_ptr< map<pg_t,int32_t > > primary_temp; // temp primary mapping (e.g. while we rebuild)
ceph::shared_ptr< vector<__u32> > osd_primary_affinity; ///< 16.16 fixed point, 0x10000 = baseline ceph::shared_ptr< vector<__u32> > osd_primary_affinity; ///< 16.16 fixed point, 0x10000 = baseline
map<int64_t,pg_pool_t> pools; map<int64_t,pg_pool_t> pools;
@ -253,8 +253,8 @@ private:
flags(0), flags(0),
num_osd(0), max_osd(0), num_osd(0), max_osd(0),
osd_addrs(new addrs_s), osd_addrs(new addrs_s),
pg_temp(new map<pg_t,vector<int> >), pg_temp(new map<pg_t,vector<int32_t> >),
primary_temp(new map<pg_t,int>), primary_temp(new map<pg_t,int32_t>),
osd_uuid(new vector<uuid_d>), osd_uuid(new vector<uuid_d>),
cluster_snapshot_epoch(0), cluster_snapshot_epoch(0),
new_blacklist_entries(false), new_blacklist_entries(false),
@ -272,8 +272,8 @@ public:
void deepish_copy_from(const OSDMap& o) { void deepish_copy_from(const OSDMap& o) {
*this = o; *this = o;
primary_temp.reset(new map<pg_t,int>(*o.primary_temp)); primary_temp.reset(new map<pg_t,int32_t>(*o.primary_temp));
pg_temp.reset(new map<pg_t,vector<int> >(*o.pg_temp)); pg_temp.reset(new map<pg_t,vector<int32_t> >(*o.pg_temp));
osd_uuid.reset(new vector<uuid_d>(*o.osd_uuid)); osd_uuid.reset(new vector<uuid_d>(*o.osd_uuid));
// NOTE: this still references shared entity_addr_t's. // NOTE: this still references shared entity_addr_t's.

View File

@ -190,7 +190,8 @@ TEST_F(OSDMapTest, PrimaryTempRespected) {
pg_t rawpg(0, 0, -1); pg_t rawpg(0, 0, -1);
pg_t pgid = osdmap.raw_pg_to_pg(rawpg); pg_t pgid = osdmap.raw_pg_to_pg(rawpg);
vector<int> up_osds, acting_osds; vector<int> up_osds
vector<uint32_t> acting_osds;
int up_primary, acting_primary; int up_primary, acting_primary;
osdmap.pg_to_up_acting_osds(pgid, &up_osds, &up_primary, osdmap.pg_to_up_acting_osds(pgid, &up_osds, &up_primary,
@ -212,7 +213,7 @@ TEST_F(OSDMapTest, RemovesRedundantTemps) {
pg_t rawpg(0, 0, -1); pg_t rawpg(0, 0, -1);
pg_t pgid = osdmap.raw_pg_to_pg(rawpg); pg_t pgid = osdmap.raw_pg_to_pg(rawpg);
vector<int> up_osds, acting_osds; vector<int> up_osds, acting_osds;
int up_primary, acting_primary; int32_t up_primary, acting_primary;
osdmap.pg_to_up_acting_osds(pgid, &up_osds, &up_primary, osdmap.pg_to_up_acting_osds(pgid, &up_osds, &up_primary,
&acting_osds, &acting_primary); &acting_osds, &acting_primary);