@@ -6454,20 +6454,7 @@ void OSD::tick_without_osd_lock()
64546454 service.get_scrub_services ().initiate_scrub (service.is_recovery_active ());
64556455 service.promote_throttle_recalibrate ();
64566456 resume_creating_pg ();
6457- bool need_send_beacon = false ;
6458- const auto now = ceph::coarse_mono_clock::now ();
6459- {
6460- // borrow lec lock to pretect last_sent_beacon from changing
6461- std::lock_guard l{min_last_epoch_clean_lock};
6462- const auto elapsed = now - last_sent_beacon;
6463- if (std::chrono::duration_cast<std::chrono::seconds>(elapsed).count () >
6464- cct->_conf ->osd_beacon_report_interval ) {
6465- need_send_beacon = true ;
6466- }
6467- }
6468- if (need_send_beacon) {
6469- send_beacon (now);
6470- }
6457+ maybe_send_beacon ();
64716458 }
64726459
64736460 mgrc.update_daemon_health (get_health_metrics ());
@@ -7383,6 +7370,26 @@ void OSD::send_beacon(const ceph::coarse_mono_clock::time_point& now)
73837370 }
73847371}
73857372
7373+ void OSD::maybe_send_beacon ()
7374+ {
7375+ bool need_send_beacon = false ;
7376+ const auto now = ceph::coarse_mono_clock::now ();
7377+ {
7378+ // borrow lec lock to protect last_sent_beacon from changing
7379+ std::lock_guard l{min_last_epoch_clean_lock};
7380+ const auto elapsed = now - last_sent_beacon;
7381+ if (std::chrono::duration_cast<std::chrono::seconds>(elapsed).count () >
7382+ cct->_conf ->osd_beacon_report_interval ) {
7383+ need_send_beacon = true ;
7384+ }
7385+ }
7386+ if (need_send_beacon) {
7387+ send_beacon (now);
7388+ } else {
7389+ dout (20 ) << __func__ << " beacon would be too frequent; skipping" << dendl;
7390+ }
7391+ }
7392+
73867393void OSD::handle_command (MCommand *m)
73877394{
73887395 ConnectionRef con = m->get_connection ();
@@ -7469,7 +7476,7 @@ void OSD::scrub_purged_snaps()
74697476 int tr = store->queue_transaction (service.meta_ch , std::move (t), nullptr );
74707477 ceph_assert (tr == 0 );
74717478 if (is_active ()) {
7472- send_beacon ( ceph::coarse_mono_clock::now () );
7479+ maybe_send_beacon ( );
74737480 }
74747481 dout (10 ) << __func__ << " done" << dendl;
74757482}
0 commit comments