From: Neha Ojha Date: Sat, 31 Aug 2019 01:15:58 +0000 (-0700) Subject: osd/MissingLoc, PeeringState: remove osd from missing loc in purge_strays() X-Git-Tag: v15.1.0~1681^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F30119%2Fhead;p=ceph.git osd/MissingLoc, PeeringState: remove osd from missing loc in purge_strays() We should always try to keep osds in missing_loc consistent with peer_missing and peer_info. When we remove an osd from peer_missing and peer_info, we should also remove it from missing_loc during purging strays. Signed-off-by: Neha Ojha --- diff --git a/src/osd/MissingLoc.cc b/src/osd/MissingLoc.cc index 4b3833aaa014..c5929d6be7ed 100644 --- a/src/osd/MissingLoc.cc +++ b/src/osd/MissingLoc.cc @@ -184,3 +184,52 @@ void MissingLoc::check_recovery_sources(const OSDMapRef& osdmap) } } } + +void MissingLoc::remove_stray_recovery_sources(pg_shard_t stray) +{ + set now_stray; + for (set::iterator p = missing_loc_sources.begin(); + p != missing_loc_sources.end(); + ) { + if (*p != stray) { + ++p; + continue; + } + ldout(cct, 10) << __func__ << " source osd." << *p << " now stray" << dendl; + now_stray.insert(*p); + missing_loc_sources.erase(p++); + } + + if (now_stray.empty()) { + ldout(cct, 10) << __func__ << " no source osds (" << missing_loc_sources << ") became stray" << dendl; + } else { + ldout(cct, 10) << __func__ << " sources osds " << now_stray << " now stray, remaining sources are " + << missing_loc_sources << dendl; + + // filter missing_loc + map>::iterator p = missing_loc.begin(); + while (p != missing_loc.end()) { + set::iterator q = p->second.begin(); + bool changed = false; + while (q != p->second.end()) { + if (now_stray.count(*q)) { + if (!changed) { + changed = true; + _dec_count(p->second); + } + p->second.erase(q++); + } else { + ++q; + } + } + if (p->second.empty()) { + missing_loc.erase(p++); + } else { + if (changed) { + _inc_count(p->second); + } + ++p; + } + } + } +} diff --git a/src/osd/MissingLoc.h b/src/osd/MissingLoc.h index 3b1ff161b21b..f0cbadbb44ad 100644 --- a/src/osd/MissingLoc.h +++ b/src/osd/MissingLoc.h @@ -270,6 +270,9 @@ class MissingLoc { /// Uses osdmap to update structures for now down sources void check_recovery_sources(const OSDMapRef& osdmap); + /// Remove stray from recovery sources + void remove_stray_recovery_sources(pg_shard_t stray); + /// Call when hoid is no longer missing in acting set void recovered(const hobject_t &hoid) { needs_recovery_map.erase(hoid); diff --git a/src/osd/PeeringState.cc b/src/osd/PeeringState.cc index d16c28f045c8..2ab1eea378b0 100644 --- a/src/osd/PeeringState.cc +++ b/src/osd/PeeringState.cc @@ -212,6 +212,7 @@ void PeeringState::purge_strays() } peer_missing.erase(*p); peer_info.erase(*p); + missing_loc.remove_stray_recovery_sources(*p); peer_purged.insert(*p); removed = true; }