Merge pull request #1095 from ceph/wip-7166

osd: OSDMap: build reverse name->pool map upon decoding

Reviewed-by: Loic Dachary <loic@dachary.org>
This commit is contained in:
Loic Dachary 2014-01-16 05:21:34 -08:00
commit d27731fece
2 changed files with 16 additions and 6 deletions

View File

@ -1721,12 +1721,7 @@ void OSDMap::decode_classic(bufferlist::iterator& p)
else
osd_addrs->hb_front_addr.resize(osd_addrs->hb_back_addr.size());
// index pool names
name_pool.clear();
for (map<int64_t,string>::iterator i = pool_name.begin(); i != pool_name.end(); ++i)
name_pool[i->second] = i->first;
calc_num_osds();
post_decode();
}
void OSDMap::decode(bufferlist::iterator& bl)
@ -1793,6 +1788,20 @@ void OSDMap::decode(bufferlist::iterator& bl)
}
DECODE_FINISH(bl); // wrapper
post_decode();
}
void OSDMap::post_decode()
{
// index pool names
name_pool.clear();
for (map<int64_t,string>::iterator i = pool_name.begin();
i != pool_name.end(); ++i) {
name_pool[i->second] = i->first;
}
calc_num_osds();
}
void OSDMap::dump_json(ostream& out) const

View File

@ -475,6 +475,7 @@ private:
void encode_client_old(bufferlist& bl) const;
void encode_classic(bufferlist& bl, uint64_t features) const;
void decode_classic(bufferlist::iterator& p);
void post_decode();
public:
void encode(bufferlist& bl, uint64_t features=CEPH_FEATURES_ALL) const;
void decode(bufferlist& bl);