From: Kefu Chai Date: Thu, 19 Sep 2019 08:10:54 +0000 (+0800) Subject: crimson/osd: fix the order in OSD::update_heartbeat_peers() X-Git-Tag: v15.1.0~1487^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4aed49b6261904554116a7258914a94d3d62570f;p=ceph.git crimson/osd: fix the order in OSD::update_heartbeat_peers() before this chance, we do following things in background and in parallel: * add peers from pg map * and peers from whole osdmap * remove dead peers but we should prioritize the peer candidates, apparently, the ones from pgmap should have higher priority. as they are more likely to be used in cluser and they are more important to current OSD, as they serve the same set of PGs. so we need to do these things in a proper order: 1. add peers from pg map 2. and peers from whole osdmap 3. remove dead peers Signed-off-by: Kefu Chai --- diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index ca5ababac3dc8..7d2a5ad497574 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -963,23 +963,30 @@ seastar::future<> OSD::send_beacon() return monc->send_message(m); } -void OSD::update_heartbeat_peers() +seastar::future<> OSD::update_heartbeat_peers() { if (!state.is_active()) { - return; - } - for (auto& pg : pg_map.get_pgs()) { - vector up, acting; - osdmap->pg_to_up_acting_osds(pg.first.pgid, - &up, nullptr, - &acting, nullptr); - for (auto osd : boost::join(up, acting)) { - if (osd != CRUSH_ITEM_NONE && osd != whoami) { - heartbeat->add_peer(osd, osdmap->get_epoch()); - } - } + return seastar::now(); } - heartbeat->update_peers(whoami); + return seastar::parallel_for_each( + pg_map.get_pgs(), + [this](auto& pg) { + vector up, acting; + osdmap->pg_to_up_acting_osds(pg.first.pgid, + &up, nullptr, + &acting, nullptr); + return seastar::parallel_for_each( + boost::join(up, acting), + [this](int osd) { + if (osd == CRUSH_ITEM_NONE || osd == whoami) { + return seastar::now(); + } else { + return heartbeat->add_peer(osd, osdmap->get_epoch()); + } + }); + }).then([this] { + return heartbeat->update_peers(whoami); + }); } seastar::future<> OSD::handle_peering_op( diff --git a/src/crimson/osd/osd.h b/src/crimson/osd/osd.h index 5c7b5c5242fc9..01c6b09b8ba8c 100644 --- a/src/crimson/osd/osd.h +++ b/src/crimson/osd/osd.h @@ -203,7 +203,7 @@ public: seastar::future<> shutdown(); seastar::future<> send_beacon(); - void update_heartbeat_peers(); + seastar::future<> update_heartbeat_peers(); friend class PGAdvanceMap; };