Skip to content

Commit

Permalink
osd/OSDMapMapping: put mappings in a mempool
Browse files Browse the repository at this point in the history
Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Feb 16, 2017
1 parent fa632e6 commit e193f8b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/include/mempool.h
Expand Up @@ -148,6 +148,7 @@ namespace mempool {
f(buffer_meta) \
f(buffer_data) \
f(osd) \
f(osdmap_mapping) \
f(unittest_1) \
f(unittest_2)

Expand Down
2 changes: 1 addition & 1 deletion src/mon/OSDMonitor.cc
Expand Up @@ -1054,7 +1054,7 @@ void OSDMonitor::maybe_prime_pg_temp()
int n = chunk;
std::unordered_set<pg_t> did_pgs;
for (auto osd : osds) {
const vector<pg_t>& pgs = mapping->get_osd_acting_pgs(osd);
auto& pgs = mapping->get_osd_acting_pgs(osd);
dout(20) << __func__ << " osd." << osd << " " << pgs << dendl;
for (auto pgid : pgs) {
if (!did_pgs.insert(pgid).second) {
Expand Down
3 changes: 3 additions & 0 deletions src/osd/OSDMapMapping.cc
Expand Up @@ -8,6 +8,9 @@

#include "common/debug.h"

MEMPOOL_DEFINE_OBJECT_FACTORY(OSDMapMapping, osdmapmapping,
osdmap_mapping);

// ensure that we have a PoolMappings for each pool and that
// the dimensions (pg_num and size) match up.
void OSDMapMapping::_init_mappings(const OSDMap& osdmap)
Expand Down
17 changes: 12 additions & 5 deletions src/osd/OSDMapMapping.h
Expand Up @@ -167,10 +167,16 @@ class ParallelPGMapper {

/// a precalculated mapping of every PG for a given OSDMap
class OSDMapMapping {
public:
MEMPOOL_CLASS_HELPERS();
private:

struct PoolMapping {
MEMPOOL_CLASS_HELPERS();

unsigned size = 0;
unsigned pg_num = 0;
std::vector<int32_t> table;
mempool::osdmap_mapping::vector<int32_t> table;

size_t row_size() const {
return
Expand Down Expand Up @@ -233,9 +239,10 @@ class OSDMapMapping {
}
};

std::map<int64_t,PoolMapping> pools;
std::vector<std::vector<pg_t>> acting_rmap; // osd -> pg
//unused: std::vector<std::vector<pg_t>> up_rmap; // osd -> pg
mempool::osdmap_mapping::map<int64_t,PoolMapping> pools;
mempool::osdmap_mapping::vector<
mempool::osdmap_mapping::vector<pg_t>> acting_rmap; // osd -> pg
//unused: mempool::osdmap_mapping::vector<std::vector<pg_t>> up_rmap; // osd -> pg
epoch_t epoch;
uint64_t num_pgs = 0;

Expand Down Expand Up @@ -281,7 +288,7 @@ class OSDMapMapping {
p->second.get(pgid.ps(), up, up_primary, acting, acting_primary);
}

const std::vector<pg_t>& get_osd_acting_pgs(unsigned osd) {
const mempool::osdmap_mapping::vector<pg_t>& get_osd_acting_pgs(unsigned osd) {
assert(osd < acting_rmap.size());
return acting_rmap[osd];
}
Expand Down

0 comments on commit e193f8b

Please sign in to comment.