summaryrefslogtreecommitdiffstats
path: root/src/osd/scrubber/scrub_machine.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/scrubber/scrub_machine.cc')
-rw-r--r--src/osd/scrubber/scrub_machine.cc48
1 files changed, 39 insertions, 9 deletions
diff --git a/src/osd/scrubber/scrub_machine.cc b/src/osd/scrubber/scrub_machine.cc
index 547a046d5bd..10866ce580a 100644
--- a/src/osd/scrubber/scrub_machine.cc
+++ b/src/osd/scrubber/scrub_machine.cc
@@ -106,6 +106,25 @@ ceph::timespan ScrubMachine::get_time_scrubbing() const
return ceph::timespan{};
}
+std::optional<pg_scrubbing_status_t> ScrubMachine::get_reservation_status()
+ const
+{
+ const auto resv_state = state_cast<const ReservingReplicas*>();
+ if (!resv_state) {
+ return std::nullopt;
+ }
+ const auto session = state_cast<const Session*>();
+ dout(30) << fmt::format(
+ "{}: we are reserving {:p}-{:p}", __func__, (void*)session,
+ (void*)resv_state)
+ << dendl;
+ if (!session || !session->m_reservations) {
+ dout(20) << fmt::format("{}: no reservations data", __func__) << dendl;
+ return std::nullopt;
+ }
+ return session->get_reservation_status();
+}
+
// ////////////// the actual actions
// ----------------------- NotActive -----------------------------------------
@@ -159,14 +178,6 @@ sc::result PrimaryIdle::react(const StartScrub&)
return transit<ReservingReplicas>();
}
-sc::result PrimaryIdle::react(const AfterRepairScrub&)
-{
- dout(10) << "PrimaryIdle::react(const AfterRepairScrub&)" << dendl;
- DECLARE_LOCALS;
- scrbr->reset_epoch();
- return transit<ReservingReplicas>();
-}
-
void PrimaryIdle::clear_state(const FullReset&) {
dout(10) << "PrimaryIdle::react(const FullReset&): clearing state flags"
<< dendl;
@@ -207,9 +218,27 @@ sc::result Session::react(const IntervalChanged&)
ceph_assert(m_reservations);
m_reservations->discard_remote_reservations();
+ m_abort_reason = delay_cause_t::interval;
return transit<NotActive>();
}
+std::optional<pg_scrubbing_status_t> Session::get_reservation_status() const
+{
+ if (!m_reservations) {
+ return std::nullopt;
+ }
+ DECLARE_LOCALS; // 'scrbr' & 'pg_id' aliases
+ const auto req = m_reservations->get_last_sent();
+ pg_scrubbing_status_t s;
+ s.m_osd_to_respond = req ? req->osd : 0;
+ s.m_ordinal_of_requested_replica = m_reservations->active_requests_cnt();
+ s.m_num_to_reserve = scrbr->get_pg()->get_actingset().size() - 1;
+ s.m_duration_seconds =
+ duration_cast<seconds>(context<ScrubMachine>().get_time_scrubbing())
+ .count();
+ return s;
+}
+
// ----------------------- ReservingReplicas ---------------------------------
@@ -308,7 +337,8 @@ ActiveScrubbing::~ActiveScrubbing()
// completed successfully), we use it now to set the 'failed scrub' duration.
if (session.m_session_started_at != ScrubTimePoint{}) {
// delay the next invocation of the scrubber on this target
- scrbr->on_mid_scrub_abort(Scrub::delay_cause_t::aborted);
+ 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;
session.m_perf_set->tinc(scrbcnt_failed_elapsed, logged_duration);