]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd/MissingLoc.cc: do not rely on missing_loc_sources only
authorNeha Ojha <nojha@redhat.com>
Fri, 6 Sep 2019 03:35:51 +0000 (20:35 -0700)
committerNeha Ojha <nojha@redhat.com>
Fri, 6 Sep 2019 22:49:36 +0000 (15:49 -0700)
In 624ade487ea4aeaf988cc1767e0b293f76addd5b, we relied on missing_loc_sources
to check for strays and remove an OSD from missing_loc. However, it is
possible that missing_loc_sources is empty while there are still OSDs
present in missing_loc. Since the aim is to just remove a stray OSD from
missing_loc, we do not need to rely on missing_loc_sources. We still
clean missing_loc_sources if any stray is present in it.

Signed-off-by: Neha Ojha <nojha@redhat.com>
src/osd/MissingLoc.cc

index c5929d6be7edef34e89483b24782ab46ea269043..8e96f0fb8be33fbe795ca4bc9e476e59e1c89084 100644 (file)
@@ -187,7 +187,33 @@ void MissingLoc::check_recovery_sources(const OSDMapRef& osdmap)
 
 void MissingLoc::remove_stray_recovery_sources(pg_shard_t stray)
 {
-  set<pg_shard_t> now_stray;
+  ldout(cct, 10) << __func__ << " remove osd " << stray << " from missing_loc" << 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 (*q == stray) {
+        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;
+    }
+  }
+  // filter missing_loc_sources
   for (set<pg_shard_t>::iterator p = missing_loc_sources.begin();
        p != missing_loc_sources.end();
        ) {
@@ -195,41 +221,7 @@ void MissingLoc::remove_stray_recovery_sources(pg_shard_t stray)
       ++p;
       continue;
     }
-    ldout(cct, 10) << __func__ << " source osd." << *p << " now stray" << dendl;
-    now_stray.insert(*p);
+    ldout(cct, 10) << __func__ << " remove osd" << stray << " from missing_loc_sources" << dendl;
     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;
-      }
-    }
-  }
 }