From: Kefu Chai Date: Thu, 11 Mar 2021 10:28:18 +0000 (+0800) Subject: mon/OSDMonitor: restructure OSDMonitor::check_failures() loop X-Git-Tag: v14.2.22~36^2~1^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b4a352bd08f777c4f64ab3f1071f3225035cf161;p=ceph.git mon/OSDMonitor: restructure OSDMonitor::check_failures() loop 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 (cherry picked from commit 6e512b2f1e228eb808d6bff1e5c159c4d16667ef) --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 414c26931232..cc3747b09d84 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2901,12 +2901,13 @@ bool OSDMonitor::can_mark_in(int i) bool OSDMonitor::check_failures(utime_t now) { bool found_failure = false; - for (map::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; }