]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd: add OSD::_send_active()
authorKefu Chai <kchai@redhat.com>
Wed, 27 Feb 2019 14:59:09 +0000 (22:59 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 22 Mar 2019 05:21:32 +0000 (13:21 +0800)
so PG can request monitor to update the OSD's up_thru in osdmap

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/osd/osd.cc
src/crimson/osd/osd.h
src/crimson/osd/pg.cc
src/crimson/osd/pg.h

index eb41032c4143d58ffbea68edadf51c3d7a790a60..7daec781de7616401dab804993e955cce76e63fd 100644 (file)
@@ -6,6 +6,8 @@
 #include <fmt/format.h>
 #include <fmt/ostream.h>
 #include "common/pick_address.h"
+
+#include "messages/MOSDAlive.h"
 #include "messages/MOSDBeacon.h"
 #include "messages/MOSDBoot.h"
 #include "messages/MOSDMap.h"
@@ -281,6 +283,19 @@ seastar::future<> OSD::_send_boot()
   return monc->send_message(m);
 }
 
+seastar::future<> OSD::_send_alive(epoch_t want)
+{
+  if (!osdmap->exists(whoami)) {
+    return seastar::now();
+  } else if (want <= up_thru_wanted){
+    return seastar::now();
+  } else {
+    up_thru_wanted = want;
+    auto m = make_message<MOSDAlive>(osdmap->get_epoch(), want);
+    return monc->send_message(std::move(m));
+  }
+}
+
 seastar::future<> OSD::stop()
 {
   logger().info("stop");
@@ -796,7 +811,9 @@ OSD::do_peering_event(spg_t pgid,
     return advance_pg_to(pg->second, osdmap->get_epoch()).then(
       [pg, evt=std::move(evt)]() mutable {
         return pg->second->do_peering_event(std::move(evt));
-      });
+    }).then([pg=pg->second, this] {
+        return _send_alive(pg->get_need_up_thru());
+    });
   } else {
     // todo: handle_pg_query_nopg()
     return seastar::now();
index 8efce9c53288d5e12681d9710cfce5d66a31d5f3..6a405652d1b307e2761d7e2e23c75c14722f15a4 100644 (file)
@@ -110,6 +110,9 @@ private:
   seastar::future<Ref<PG>> load_pg(spg_t pgid);
   seastar::future<> load_pgs();
 
+  epoch_t up_thru_wanted = 0;
+  seastar::future<> _send_alive(epoch_t want);
+
   // OSDMapService methods
   seastar::future<cached_map_t> get_map(epoch_t e) override;
   cached_map_t get_map() const override;
index fb60176e7229750f922ee64cedd4dbfb53040672..f1a6590e4c0067d7419a1cd4f3a02044b2fbbb45 100644 (file)
@@ -6,6 +6,11 @@
 #include "crimson/os/cyan_store.h"
 #include "crimson/osd/pg_meta.h"
 
+namespace {
+  seastar::logger& logger() {
+    return ceph::get_logger(ceph_subsys_osd);
+  }
+}
 
 PG::PG(spg_t pgid,
        pg_shard_t pg_shard,
@@ -160,6 +165,28 @@ void PG::update_last_peering_reset()
   last_peering_reset = get_osdmap_epoch();
 }
 
+epoch_t PG::get_need_up_thru() const
+{
+  return need_up_thru;
+}
+
+void PG::update_need_up_thru(const OSDMap* o)
+{
+  if (!o) {
+    o = osdmap.get();
+  }
+  if (auto up_thru = o->get_up_thru(whoami.osd);
+      up_thru < info.history.same_interval_since) {
+    logger().info("up_thru {} < same_since {}, must notify monitor",
+                  up_thru, info.history.same_interval_since);
+    need_up_thru = info.history.same_interval_since;
+  } else {
+    logger().info("up_thru {} >= same_since {}, all is well",
+                  up_thru, info.history.same_interval_since);
+    need_up_thru = 0;
+  }
+}
+
 seastar::future<> PG::do_peering_event(std::unique_ptr<PGPeeringEvent> evt)
 {
   // todo
index 601f876806d3aa327a7fb1a325dc3b8035cdc80c..4c293d707e0d6ee281f92ea85de19d9d818517fa 100644 (file)
@@ -50,6 +50,8 @@ public:
   pg_shard_t get_whoami() const;
   epoch_t get_last_peering_reset() const;
   void update_last_peering_reset();
+  epoch_t get_need_up_thru() const;
+  void update_need_up_thru(const OSDMap* o = nullptr);
 
   seastar::future<> read_state(ceph::os::CyanStore* store);
 
@@ -69,6 +71,8 @@ private:
   pg_pool_t pool;
 
   epoch_t last_peering_reset = 0;
+  epoch_t need_up_thru = 0;
+
   //< pg state
   pg_info_t info;
   //< last written info, for fast info persistence