ceph::timespan ScrubMachine::get_time_scrubbing() const
{
- // note: the state_cast does not work in the Session ctor
- auto session = state_cast<const Session*>();
- if (!session) {
- dout(20) << fmt::format("{}: not in session", __func__) << dendl;
+ if (!m_session_started_at) {
+ dout(30) << fmt::format("{}: no session_start time", __func__) << dendl;
return ceph::timespan{};
}
- if (session && session->m_session_started_at != ScrubTimePoint{}) {
- dout(20) << fmt::format(
- "{}: session_started_at: {} d:{}", __func__,
- session->m_session_started_at,
- ScrubClock::now() - session->m_session_started_at)
+ const auto dur = ScrubClock::now() - *m_session_started_at;
+ dout(20) << fmt::format(
+ "{}: session_started_at: {} duration:{}ms", __func__,
+ *m_session_started_at,
+ ceil<milliseconds>(dur).count())
<< dendl;
- return ScrubClock::now() - session->m_session_started_at;
- }
- dout(30) << fmt::format("{}: no session_start time", __func__) << dendl;
- return ceph::timespan{};
+ return dur;
}
std::optional<pg_scrubbing_status_t> ScrubMachine::get_reservation_status()
dout(10) << "-- state -->> PrimaryActive/Session" << dendl;
DECLARE_LOCALS; // 'scrbr' & 'pg_id' aliases
+ machine.m_session_started_at = ScrubClock::now();
+
m_perf_set = scrbr->get_labeled_counters();
m_osd_counters = scrbr->get_osd_perf_counters();
m_counters_idx = &scrbr->get_unlabeled_counters();
{
DECLARE_LOCALS; // 'scrbr' & 'pg_id' aliases
m_reservations.reset();
+ machine.m_session_started_at.reset();
// note the interaction between clearing the 'queued' flag and two
// other states: the snap-mapper and the scrubber internal state.
// if the begin-time stamp was not set 'off' (as done if the scrubbing
// completed successfully), we use it now to set the 'failed scrub' duration.
- if (session.m_session_started_at != ScrubTimePoint{}) {
+ if (machine.m_session_started_at) {
// delay the next invocation of the scrubber on this target
scrbr->on_mid_scrub_abort(
session.m_abort_reason.value_or(Scrub::delay_cause_t::aborted));
- auto logged_duration = ScrubClock::now() - session.m_session_started_at;
+ auto logged_duration = ScrubClock::now() - *machine.m_session_started_at;
session.m_osd_counters->tinc(session.m_counters_idx->failed_elapsed,
logged_duration);
session.m_osd_counters->inc(session.m_counters_idx->failed_cnt);
// set the 'scrub duration'
auto duration = machine.get_time_scrubbing();
- scrbr->set_scrub_duration(duration_cast<milliseconds>(duration));
- session.m_session_started_at = ScrubTimePoint{};
+ scrbr->set_scrub_duration(ceil<milliseconds>(duration));
+ machine.m_session_started_at.reset();
session.m_osd_counters->tinc(
session.m_counters_idx->successful_elapsed, duration);
public:
friend class PgScrubber;
- public:
explicit ScrubMachine(PG* pg, ScrubMachineListener* pg_scrub);
virtual ~ScrubMachine();
sc::state_machine<ScrubMachine, NotActive>::process_event(evt);
}
-// ///////////////// aux declarations & functions //////////////////////// //
+ /// the time when the session was initiated
+ std::optional<ScrubTimePoint> m_session_started_at;
+
+ // ///////////////// aux declarations & functions //////////////////////// //
private:
+
/**
* scheduled_event_state_t
*
/// this pool type)
const ScrubCounterSet* m_counters_idx{nullptr};
- /// the time when the session was initiated
- ScrubTimePoint m_session_started_at{ScrubClock::now()};
-
/// abort reason - if known. Determines the delay time imposed on the
/// failed scrub target.
std::optional<Scrub::delay_cause_t> m_abort_reason{std::nullopt};