dout(10) << "Adding newly split pg " << *pg << dendl;
vector<int> up, acting;
pg->get_osdmap()->pg_to_up_acting_osds(pg->info.pgid, up, acting);
- int role = pg->get_osdmap()->calc_pg_role(service.whoami, acting);
+ int role = OSDMap::calc_pg_role(service.whoami, acting);
pg->set_role(role);
pg->reg_next_scrub();
pg->handle_loaded(rctx);
// generate state for PG's current mapping
pg->get_osdmap()->pg_to_up_acting_osds(pgid, pg->up, pg->acting);
- int role = pg->get_osdmap()->calc_pg_role(whoami, pg->acting);
+ int role = OSDMap::calc_pg_role(whoami, pg->acting);
pg->set_role(role);
PG::RecoveryCtx rctx(0, 0, 0, 0, 0, 0);
bool create = false;
if (primary) {
- assert(role == 0); // otherwise, probably bug in project_pg_history.
-
// DNE on source?
if (info.dne()) {
// is there a creation pending on this pg?
}
creating_pgs.erase(info.pgid);
} else {
- assert(role != 0); // i should be replica
- assert(!info.dne()); // and pg exists if we are hearing about it
+ assert(!info.dne()); // pg exists if we are hearing about it
}
// do we need to resurrect a deleting pg?
// am i still primary?
vector<int> acting;
- int nrep = osdmap->pg_to_acting_osds(pgid, acting);
- int role = osdmap->calc_pg_role(whoami, acting, nrep);
- if (role != 0) {
+ int primary;
+ osdmap->pg_to_acting_osds(pgid, &acting, &primary);
+ if (primary != whoami) {
dout(10) << " no longer primary for " << pgid << ", stopping creation" << dendl;
creating_pgs.erase(p);
} else {
while (p != waiting_for_pg.end()) {
pg_t pgid = p->first;
- // am i still primary?
vector<int> acting;
int nrep = osdmap->pg_to_acting_osds(pgid, acting);
int role = osdmap->calc_pg_role(whoami, acting, nrep);
// is it still ours?
vector<int> up, acting;
- osdmap->pg_to_up_acting_osds(on, up, acting);
+ int up_primary, acting_primary;
+ osdmap->pg_to_up_acting_osds(on, &up, &up_primary, &acting, &acting_primary);
int role = osdmap->calc_pg_role(whoami, acting, acting.size());
- if (role != 0) {
+ if (up_primary != whoami) {
dout(10) << "mkpg " << pgid << " not primary (role=" << role << "), skipping" << dendl;
continue;
}
// get active crush mapping
vector<int> up, acting;
osdmap->pg_to_up_acting_osds(pgid, up, acting);
- int role = osdmap->calc_pg_role(whoami, acting, acting.size());
// same primary?
pg_history_t history = it->second.history;
continue;
}
- assert(role != 0);
dout(10) << " pg " << pgid << " dne" << dendl;
pg_info_t empty(pgid);
if (it->second.type == pg_query_t::LOG ||
// There can't be recovery/backfill going on now
get_osdmap()->pg_to_up_acting_osds(child->info.pgid, child->up, child->acting);
- child->role = get_osdmap()->calc_pg_role(osd->whoami, child->acting);
+ child->role = OSDMap::calc_pg_role(osd->whoami, child->acting);
if (get_primary() != child->get_primary())
child->info.history.same_primary_since = get_osdmap()->get_epoch();
<< dendl;
} else {
// primary is the same.
- if (role == 0) {
+ if (is_primary()) {
// i am (still) primary. but my replica set changed.
state_clear(PG_STATE_CLEAN);