summaryrefslogtreecommitdiffstats
path: root/src/crimson
diff options
context:
space:
mode:
authorKefu Chai <kchai@redhat.com>2019-09-19 10:10:54 +0200
committerKefu Chai <kchai@redhat.com>2019-09-19 12:23:20 +0200
commit4aed49b6261904554116a7258914a94d3d62570f (patch)
treeb18e5d2e99f099bd78f7283b2fe154be461666ca /src/crimson
parentcrimson/osd/heartbeat: avoid racing when connecting to peer (diff)
downloadceph-4aed49b6261904554116a7258914a94d3d62570f.tar.xz
ceph-4aed49b6261904554116a7258914a94d3d62570f.zip
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 <kchai@redhat.com>
Diffstat (limited to 'src/crimson')
-rw-r--r--src/crimson/osd/osd.cc35
-rw-r--r--src/crimson/osd/osd.h2
2 files changed, 22 insertions, 15 deletions
diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc
index ca5ababac3d..7d2a5ad4975 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<int> 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<int> 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 5c7b5c5242f..01c6b09b8ba 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;
};