]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd/MissingLoc, PeeringState: remove osd from missing loc in purge_strays()
authorNeha Ojha <nojha@redhat.com>
Sat, 31 Aug 2019 01:15:58 +0000 (18:15 -0700)
committerNeha Ojha <nojha@redhat.com>
Tue, 3 Sep 2019 22:27:42 +0000 (15:27 -0700)
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 <nojha@redhat.com>
src/osd/MissingLoc.cc
src/osd/MissingLoc.h
src/osd/PeeringState.cc

index 4b3833aaa014ade94e311cd7f8eb8623a94c2f43..c5929d6be7edef34e89483b24782ab46ea269043 100644 (file)
@@ -184,3 +184,52 @@ void MissingLoc::check_recovery_sources(const OSDMapRef& osdmap)
     }
   }
 }
+
+void MissingLoc::remove_stray_recovery_sources(pg_shard_t stray)
+{
+  set<pg_shard_t> now_stray;
+  for (set<pg_shard_t>::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<hobject_t, set<pg_shard_t>>::iterator p = missing_loc.begin();
+    while (p != missing_loc.end()) {
+      set<pg_shard_t>::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;
+      }
+    }
+  }
+}
index 3b1ff161b21b9ffeaef3e241a3e05ab90853172c..f0cbadbb44ad3d0743b60cd17fd5d30acebd1f96 100644 (file)
@@ -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);
index d16c28f045c80c5669d45d7c2d639b25c3a8b9c0..2ab1eea378b091159541d619d6afe51510558c12 100644 (file)
@@ -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;
   }