mirror of
https://github.com/ceph/ceph
synced 2025-01-03 09:32:43 +00:00
OSDMap: fill in get_primary_shard
Signed-off-by: Samuel Just <sam.just@inktank.com>
This commit is contained in:
parent
285cf7728a
commit
109b3c9e7f
@ -627,7 +627,27 @@ public:
|
||||
assert(i != pools.end());
|
||||
return i->second.ec_pool();
|
||||
}
|
||||
spg_t get_primary_shard(pg_t pgid) const { return spg_t(); /* TODOSAM: fix */}
|
||||
bool get_primary_shard(pg_t pgid, spg_t *out) const {
|
||||
map<int64_t, pg_pool_t>::const_iterator i = get_pools().find(pgid.pool());
|
||||
if (i == get_pools().end()) {
|
||||
return false;
|
||||
}
|
||||
int primary;
|
||||
vector<int> acting;
|
||||
pg_to_acting_osds(pgid, &acting, &primary);
|
||||
if (i->second.ec_pool()) {
|
||||
for (shard_id_t i = 0; i < acting.size(); ++i) {
|
||||
if (acting[i] == primary) {
|
||||
*out = spg_t(pgid, i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
*out = spg_t(pgid);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int64_t lookup_pg_pool_name(const string& name) {
|
||||
if (name_pool.count(name))
|
||||
|
@ -67,6 +67,7 @@ struct pg_shard_t {
|
||||
int osd;
|
||||
shard_id_t shard;
|
||||
pg_shard_t() : osd(-1), shard(ghobject_t::NO_SHARD) {}
|
||||
explicit pg_shard_t(int osd) : osd(osd), shard(ghobject_t::NO_SHARD) {}
|
||||
pg_shard_t(int osd, shard_id_t shard) : osd(osd), shard(shard) {}
|
||||
static pg_shard_t undefined_shard() {
|
||||
return pg_shard_t(-1, ghobject_t::NO_SHARD);
|
||||
|
Loading…
Reference in New Issue
Block a user