]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: restructure OSDMonitor::check_failures() loop
authorKefu Chai <kchai@redhat.com>
Thu, 11 Mar 2021 10:28:18 +0000 (18:28 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 7 May 2021 03:04:49 +0000 (11:04 +0800)
will add a trim failures call in the loop, which mutates failure_info,
while we are still iterating this map. so have to restructure the loop
a little bit.

Fixes: https://tracker.ceph.com/issues/47380
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 6e512b2f1e228eb808d6bff1e5c159c4d16667ef)

src/mon/OSDMonitor.cc

index 414c269312329ae56aa61dcbe068bf82694d41c1..cc3747b09d84532bcde431ce4a5e0d4423134650 100644 (file)
@@ -2901,12 +2901,13 @@ bool OSDMonitor::can_mark_in(int i)
 bool OSDMonitor::check_failures(utime_t now)
 {
   bool found_failure = false;
-  for (map<int,failure_info_t>::iterator p = failure_info.begin();
-       p != failure_info.end();
-       ++p) {
-    if (can_mark_down(p->first)) {
-      found_failure |= check_failure(now, p->first, p->second);
+  auto p = failure_info.begin();
+  while (p != failure_info.end()) {
+    auto& [target_osd, fi] = *p;
+    if (can_mark_down(target_osd)) {
+      found_failure |= check_failure(now, target_osd, fi);
     }
+    ++p;
   }
   return found_failure;
 }