From 9e0a1656200c2f91386215924304b495dd705dae Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Thu, 7 Jan 2016 08:09:46 -0800 Subject: [PATCH] OSD::consume_map: correctly remove pg shards which are no longer acting A particular shard may be non-active even if the osd is in the acting set. Fixes: 14278 Backport: hammer Signed-off-by: Samuel Just (cherry picked from commit bd2fdf8c56c1aeed6cea3eb59046dbb6af470111) --- src/osd/OSD.cc | 6 +----- src/osd/OSDMap.h | 9 +++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index f121a3dfbf52..47e5e8fcbc30 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -6706,11 +6706,7 @@ void OSD::consume_map() for (set::iterator p = pgs_to_check.begin(); p != pgs_to_check.end(); ++p) { - vector acting; - int nrep = osdmap->pg_to_acting_osds(p->pgid, acting); - int role = osdmap->calc_pg_role(whoami, acting, nrep); - - if (role < 0) { + if (!(osdmap->is_acting_osd_shard(p->pgid, whoami, p->shard))) { 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.h b/src/osd/OSDMap.h index acdc3af4f2cf..003f8e3c805f 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -768,6 +768,15 @@ public: return group[group.size()-1]; return -1; // we fail! } + bool is_acting_osd_shard(pg_t pg, int osd, shard_id_t shard) 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()) + return false; + return acting[shard] == osd; + } /* what replica # is a given osd? 0 primary, -1 for none. */ -- 2.47.3