From: Kefu Chai Date: Thu, 11 Mar 2021 10:28:18 +0000 (+0800) Subject: mon/OSDMonitor: restructure OSDMonitor::check_failures() loop X-Git-Tag: v15.2.13~10^2~15^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8b65d5aede5ebb3a1517f8ab371206e6a68385b7;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 168a9830fba7d..d776db14bec25 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -3099,12 +3099,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; }