From: Kefu Chai Date: Wed, 27 Feb 2019 14:59:09 +0000 (+0800) Subject: crimson/osd: add OSD::_send_active() X-Git-Tag: v15.0.0~151^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ec0531ea57930310c2e447a92f608006e58e9b85;p=ceph.git crimson/osd: add OSD::_send_active() so PG can request monitor to update the OSD's up_thru in osdmap Signed-off-by: Kefu Chai --- diff --git a/src/crimson/osd/osd.cc b/src/crimson/osd/osd.cc index eb41032c4143..7daec781de76 100644 --- a/src/crimson/osd/osd.cc +++ b/src/crimson/osd/osd.cc @@ -6,6 +6,8 @@ #include #include #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(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(); diff --git a/src/crimson/osd/osd.h b/src/crimson/osd/osd.h index 8efce9c53288..6a405652d1b3 100644 --- a/src/crimson/osd/osd.h +++ b/src/crimson/osd/osd.h @@ -110,6 +110,9 @@ private: seastar::future> 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 get_map(epoch_t e) override; cached_map_t get_map() const override; diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index fb60176e7229..f1a6590e4c00 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -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 evt) { // todo diff --git a/src/crimson/osd/pg.h b/src/crimson/osd/pg.h index 601f876806d3..4c293d707e0d 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -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