]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: fix the order in OSD::update_heartbeat_peers()
authorKefu Chai <kchai@redhat.com>
Thu, 19 Sep 2019 08:10:54 +0000 (16:10 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 19 Sep 2019 10:23:20 +0000 (18:23 +0800)
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>
src/crimson/osd/osd.cc
src/crimson/osd/osd.h

index ca5ababac3dc8ad2eb726e02ecdbe38fccb792f8..7d2a5ad49757426d1e17adde3f2ec95dba3fc95d 100644 (file)
@@ -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(
index 5c7b5c5242fc9b85aabca471a59c91ad86dfef02..01c6b09b8ba8cd969849b78a0d2f48d04415aefa 100644 (file)
@@ -203,7 +203,7 @@ public:
   seastar::future<> shutdown();
 
   seastar::future<> send_beacon();
-  void update_heartbeat_peers();
+  seastar::future<> update_heartbeat_peers();
 
   friend class PGAdvanceMap;
 };