From: Kefu Chai Date: Sat, 11 Mar 2017 09:51:13 +0000 (+0800) Subject: osd: send osd-beacon to mon periodically X-Git-Tag: v12.0.2~256^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=78484dc71bc5bf21f1224c521192addcbff43257;p=ceph.git osd: send osd-beacon to mon periodically add an option named "osd_beacon_report_interval" to specify the interval to send osd-beacon. Signed-off-by: Kefu Chai --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 8c22e3837824d..cadcff155c404 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -789,6 +789,7 @@ OPTION(osd_mon_heartbeat_interval, OPT_INT, 30) // (seconds) how often to ping OPTION(osd_mon_report_interval_max, OPT_INT, 600) OPTION(osd_mon_report_interval_min, OPT_INT, 5) // pg stats, failures, up_thru, boot. OPTION(osd_mon_report_max_in_flight, OPT_INT, 2) // max updates in flight +OPTION(osd_beacon_report_interval, OPT_INT, 300) // (second) how often to send beacon message to monitor OPTION(osd_pg_stat_report_interval_max, OPT_INT, 500) // report pg stats for any given pg at least this often OPTION(osd_mon_ack_timeout, OPT_DOUBLE, 30.0) // time out a mon if it doesn't ack stats OPTION(osd_stats_ack_timeout_factor, OPT_DOUBLE, 2.0) // multiples of mon_ack_timeout diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 6f8d51f2acc9a..e7358ccd0b872 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -68,6 +68,7 @@ #include "messages/MOSDOp.h" #include "messages/MOSDOpReply.h" #include "messages/MOSDBackoff.h" +#include "messages/MOSDBeacon.h" #include "messages/MOSDRepOp.h" #include "messages/MOSDRepOpReply.h" #include "messages/MOSDSubOp.h" @@ -4514,6 +4515,15 @@ void OSD::tick() do_waiters(); tick_timer.add_event_after(OSD_TICK_INTERVAL, new C_Tick(this)); + + if (is_active()) { + const auto now = ceph::coarse_mono_clock::now(); + const auto elapsed = now - last_sent_beacon; + if (chrono::duration_cast(elapsed).count() > + cct->_conf->osd_beacon_report_interval) { + send_beacon(now); + } + } } void OSD::tick_without_osd_lock() @@ -4964,6 +4974,7 @@ void OSD::ms_handle_connect(Connection *con) send_pg_stats(now); map_lock.put_read(); + send_beacon(ceph::coarse_mono_clock::now()); } // full map requests may happen while active or pre-boot @@ -5538,6 +5549,19 @@ void OSD::flush_pg_stats() osd_lock.Lock(); } +void OSD::send_beacon(const ceph::coarse_mono_clock::time_point& now) +{ + dout(20) << __func__ << dendl; + last_sent_beacon = now; + const auto& monmap = monc->monmap; + // send beacon to mon even if we are just connected, and the monmap is not + // initialized yet by then. + if (monmap.epoch == 0 && + monmap.get_required_features().contains_all( + ceph::features::mon::FEATURE_LUMINOUS)) { + monc->send_mon_message(new MOSDBeacon()); + } +} void OSD::handle_command(MMonCommand *m) { diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 8ec611cd34f35..f1d107283a6a9 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -2131,6 +2131,9 @@ protected: void handle_pg_stats_ack(class MPGStatsAck *ack); void flush_pg_stats(); + ceph::coarse_mono_clock::time_point last_sent_beacon; + void send_beacon(const ceph::coarse_mono_clock::time_point& now); + void pg_stat_queue_enqueue(PG *pg) { pg_stat_queue_lock.Lock(); if (pg->is_primary() && !pg->stat_queue_item.is_on_list()) {