for (set<spg_t>::iterator p = pgs_to_check.begin();
p != pgs_to_check.end();
++p) {
- if (!(osdmap->is_acting_osd_shard(p->pgid, whoami, p->shard))) {
+ if (!(osdmap->is_acting_osd_shard(spg_t(p->pgid, p->shard), whoami))) {
set<Session*> concerned_sessions;
get_sessions_possibly_interested_in_pg(*p, &concerned_sessions);
for (set<Session*>::iterator i = concerned_sessions.begin();
_apply_primary_affinity(pps, *pool, up, primary);
}
-void OSDMap::_pg_to_up_acting_osds(const pg_t& pg, vector<int> *up, int *up_primary,
- vector<int> *acting, int *acting_primary) const
+void OSDMap::_pg_to_up_acting_osds(
+ const pg_t& pg, vector<int> *up, int *up_primary,
+ vector<int> *acting, int *acting_primary,
+ bool raw_pg_to_pg) const
{
const pg_pool_t *pool = get_pg_pool(pg.pool());
- if (!pool) {
+ if (!pool ||
+ (!raw_pg_to_pg && pg.ps() >= pool->get_pg_num())) {
if (up)
up->clear();
if (up_primary)
* map to up and acting. Fills in whatever fields are non-NULL.
*/
void _pg_to_up_acting_osds(const pg_t& pg, vector<int> *up, int *up_primary,
- vector<int> *acting, int *acting_primary) const;
+ vector<int> *acting, int *acting_primary,
+ bool raw_pg_to_pg = true) const;
public:
/***
return -1; // we fail!
}
- bool is_acting_osd_shard(pg_t pg, int osd, shard_id_t shard) const {
+ /*
+ * check whether an spg_t maps to a particular osd
+ */
+ bool is_acting_osd_shard(spg_t pg, int osd) const {
vector<int> acting;
- int nrep = pg_to_acting_osds(pg, acting);
- if (shard == shard_id_t::NO_SHARD)
- return calc_pg_role(osd, acting, nrep) >= 0;
- if (shard >= (int)acting.size())
+ _pg_to_up_acting_osds(pg.pgid, NULL, NULL, &acting, NULL, false);
+ if (pg.shard == shard_id_t::NO_SHARD)
+ return calc_pg_role(osd, acting, acting.size()) >= 0;
+ if (pg.shard >= (int)acting.size())
return false;
- return acting[shard] == osd;
- }
- bool is_acting_osd_shard(spg_t pgid, int osd) const {
- return is_acting_osd_shard(pgid.pgid, osd, pgid.shard);
+ return acting[pg.shard] == osd;
}