From: Sage Weil Date: Fri, 10 Feb 2017 04:08:19 +0000 (-0500) Subject: osd/OSDMap: make is_acting_osd_shard an explicit spg_t check X-Git-Tag: v12.0.1~383^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=557e73cb8a25cf4ae1c7f93609b014577704b763;p=ceph.git osd/OSDMap: make is_acting_osd_shard an explicit spg_t check Ensure that the ps value is < the pool pg_num. Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 9078808e0d55..92db3419e8cd 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -7534,7 +7534,7 @@ void OSD::consume_map() for (set::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 concerned_sessions; get_sessions_possibly_interested_in_pg(*p, &concerned_sessions); for (set::iterator i = concerned_sessions.begin(); diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 89bda09f2907..29b063a171c8 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -1725,11 +1725,14 @@ void OSDMap::pg_to_raw_up(pg_t pg, vector *up, int *primary) const _apply_primary_affinity(pps, *pool, up, primary); } -void OSDMap::_pg_to_up_acting_osds(const pg_t& pg, vector *up, int *up_primary, - vector *acting, int *acting_primary) const +void OSDMap::_pg_to_up_acting_osds( + const pg_t& pg, vector *up, int *up_primary, + vector *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) diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index b33c7ab748ef..e7bcb46aa676 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -655,7 +655,8 @@ private: * map to up and acting. Fills in whatever fields are non-NULL. */ void _pg_to_up_acting_osds(const pg_t& pg, vector *up, int *up_primary, - vector *acting, int *acting_primary) const; + vector *acting, int *acting_primary, + bool raw_pg_to_pg = true) const; public: /*** @@ -777,17 +778,17 @@ 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 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; }