]> git.apps.os.sepia.ceph.com Git - ceph.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)
committerNathan Cutler <ncutler@suse.com>
Sun, 15 Dec 2019 15:54:14 +0000 (16:54 +0100)
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>
(cherry picked from commit 624ade487ea4aeaf988cc1767e0b293f76addd5b)

Conflicts:
src/osd/MissingLoc.cc
src/osd/MissingLoc.h
src/osd/PeeringState.cc
- these files do not exist in luminous; made the changes manually to
  src/osd/PG.cc and src/osd/PG.h
- ldout(cct, ...) -> ldout(pg->cct, ...)

src/osd/PG.cc
src/osd/PG.h

index 7b9624267af23744918a35f0fca93b9386dadfce..a9611f31ca91bbc8161cd7fa104af9a396adba7f 100644 (file)
@@ -759,7 +759,56 @@ void PG::MissingLoc::check_recovery_sources(const OSDMapRef& osdmap)
     }
   }
 }
-  
+
+void PG::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(pg->cct, 10) << __func__ << " source osd." << *p << " now stray" << dendl;
+    now_stray.insert(*p);
+    missing_loc_sources.erase(p++);
+  }
+
+  if (now_stray.empty()) {
+    ldout(pg->cct, 10) << __func__ << " no source osds (" << missing_loc_sources << ") became stray" << dendl;
+  } else {
+    ldout(pg->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;
+      }
+    }
+  }
+}
+
 void PG::discover_all_missing(map<int, map<spg_t,pg_query_t> > &query_map)
 {
   auto &missing = pg_log.get_missing();
@@ -2608,6 +2657,7 @@ void PG::purge_strays()
     }
     peer_missing.erase(*p);
     peer_info.erase(*p);
+    missing_loc.remove_stray_recovery_sources(*p);
     peer_purged.insert(*p);
     removed = true;
   }
index f1e91cf9bd92475b2c615c390ddf1e089e1cf662..c13f5cc83ac08d63b70b751fc1ef52dab5336f7a 100644 (file)
@@ -594,6 +594,9 @@ public:
     /// 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);