]> 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)
committersinguliere <singuliere@autistici.org>
Thu, 1 Apr 2021 21:06:45 +0000 (23:06 +0200)
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 168a9830fba7d14a408e13a449d4fcfd7676c67f..d776db14bec25e2bf8abfa91c4cfc890e77431cf 100644 (file)
@@ -3099,12 +3099,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;
 }