// Not needed yet -- mainly for scrub scheduling
}
- /// Notify PG that Primary/Replica status has changed (to update scrub registration)
- void on_primary_status_change(bool was_primary, bool now_primary) final {
- }
-
/// Need to reschedule next scrub. Assuming no change in role
void reschedule_scrub() final {
}
void PG::on_info_history_change()
{
ceph_assert(m_scrubber);
- m_scrubber->on_primary_change(__func__, m_planned_scrub);
+ dout(20) << fmt::format(
+ "{} for a {}", __func__,
+ (is_primary() ? "Primary" : "non-primary"))
+ << dendl;
+ reschedule_scrub();
}
void PG::reschedule_scrub()
}
}
-void PG::on_primary_status_change(bool was_primary, bool now_primary)
-{
- // make sure we have a working scrubber when becoming a primary
- if (was_primary != now_primary) {
- ceph_assert(m_scrubber);
- m_scrubber->on_primary_change(__func__, m_planned_scrub);
- }
-}
-
void PG::scrub_requested(scrub_level_t scrub_level, scrub_type_t scrub_type)
{
ceph_assert(m_scrubber);
{
projected_last_update = eversion_t();
cancel_recovery();
-
- ceph_assert(m_scrubber);
- // log some scrub data before we react to the interval
- dout(20) << __func__ << (is_scrub_queued_or_active() ? " scrubbing " : " ")
- << "flags: " << m_planned_scrub << dendl;
-
- m_scrubber->on_primary_change(__func__, m_planned_scrub);
+ m_scrubber->on_new_interval();
}
epoch_t PG::cluster_osdmap_trim_lower_bound() {
snap_trimq = snaps;
release_pg_backoffs();
projected_last_update = info.last_update;
+ m_scrubber->on_pg_activate(m_planned_scrub);
}
void PG::on_active_exit()
void on_info_history_change() override;
- void on_primary_status_change(bool was_primary, bool now_primary) override;
-
void reschedule_scrub() override;
void scrub_requested(scrub_level_t scrub_level, scrub_type_t scrub_type) override;
// did primary change?
if (was_old_primary != is_primary()) {
state_clear(PG_STATE_CLEAN);
- // queue/dequeue the scrubber
- pl->on_primary_status_change(was_old_primary, is_primary());
}
pl->on_role_change();
/// Notify that info/history changed (generally to update scrub registration)
virtual void on_info_history_change() = 0;
- /// Notify PG that Primary/Replica status has changed (to update scrub registration)
- virtual void on_primary_status_change(bool was_primary, bool now_primary) = 0;
-
/// Need to reschedule next scrub. Assuming no change in role
virtual void reschedule_scrub() = 0;
// ///////////////////////////////////////////////////////////////////// //
// scrub-op registration handling
+/* on_new_interval
+ *
+ * Responsible for restting any scrub state and releasing any resources.
+ * Any inflight events will be ignored via check_interval/should_drop_message
+ * or canceled.
+ */
+void PgScrubber::on_new_interval()
+{
+ dout(10) << fmt::format(
+ "{}: current role:{} active?{} q/a:{}", __func__,
+ (is_primary() ? "Primary" : "Replica/other"),
+ is_scrub_active(), is_queued_or_active())
+ << dendl;
+
+ m_fsm->process_event(FullReset{});
+ // we may be the primary
+ if (is_queued_or_active()) {
+ clear_pgscrub_state();
+ }
+ rm_from_osd_scrubbing();
+}
bool PgScrubber::is_scrub_registered() const
{
}
}
-void PgScrubber::on_primary_change(
- std::string_view caller,
- const requested_scrub_t& request_flags)
+void PgScrubber::on_pg_activate(const requested_scrub_t& request_flags)
{
+ ceph_assert(is_primary());
if (!m_scrub_job) {
// we won't have a chance to see more logs from this function, thus:
- dout(10) << fmt::format(
- "{}: (from {}& w/{}) {}.Reg-state:{:.7}. No scrub-job",
- __func__, caller, request_flags,
- (is_primary() ? "Primary" : "Replica/other"),
- registration_state())
- << dendl;
+ dout(2) << fmt::format(
+ "{}: flags:<{}> {}.Reg-state:{:.7}. No scrub-job", __func__,
+ request_flags, (is_primary() ? "Primary" : "Replica/other"),
+ registration_state())
+ << dendl;
return;
}
+ ceph_assert(!is_queued_or_active());
auto pre_state = m_scrub_job->state_desc();
auto pre_reg = registration_state();
- if (is_primary()) {
- auto suggested = m_osds->get_scrub_services().determine_scrub_time(
- request_flags, m_pg->info, m_pg->get_pgpool().info.opts);
- m_osds->get_scrub_services().register_with_osd(m_scrub_job, suggested);
- } else {
- m_osds->get_scrub_services().remove_from_osd_queue(m_scrub_job);
- }
- // is there an interval change we should respond to?
- if (is_primary() && is_scrub_active()) {
- if (m_interval_start < m_pg->get_same_interval_since()) {
- dout(10) << fmt::format(
- "{}: interval changed ({} -> {}). Aborting active scrub.",
- __func__, m_interval_start, m_pg->get_same_interval_since())
- << dendl;
- scrub_clear_state();
- }
- }
+ auto suggested = m_osds->get_scrub_services().determine_scrub_time(
+ request_flags, m_pg->info, m_pg->get_pgpool().info.opts);
+ m_osds->get_scrub_services().register_with_osd(m_scrub_job, suggested);
- dout(10)
- << fmt::format(
- "{} (from {} {}): {}. <{:.5}>&<{:.10}> --> <{:.5}>&<{:.14}>",
- __func__, caller, request_flags,
- (is_primary() ? "Primary" : "Replica/other"), pre_reg, pre_state,
- registration_state(), m_scrub_job->state_desc())
- << dendl;
+ dout(10) << fmt::format(
+ "{}: <flags:{}> {} <{:.5}>&<{:.10}> --> <{:.5}>&<{:.14}>",
+ __func__, request_flags,
+ (is_primary() ? "Primary" : "Replica/other"), pre_reg,
+ pre_state, registration_state(), m_scrub_job->state_desc())
+ << dendl;
}
/*
void rm_from_osd_scrubbing() final;
- void on_primary_change(
- std::string_view caller,
- const requested_scrub_t& request_flags) final;
+ void on_pg_activate(const requested_scrub_t& request_flags) final;
void scrub_requested(
scrub_level_t scrub_level,
/// handle a message carrying a replica map
void map_from_replica(OpRequestRef op) final;
+ void on_new_interval() final;
+
void scrub_clear_state() final;
bool is_queued_or_active() const final;
virtual void set_op_parameters(const requested_scrub_t&) = 0;
+ /// stop any active scrubbing (on interval end) and unregister from
+ /// the OSD scrub queue
+ virtual void on_new_interval() = 0;
+
virtual void scrub_clear_state() = 0;
virtual void handle_query_state(ceph::Formatter* f) = 0;
virtual bool reserve_local() = 0;
/**
- * Register/de-register with the OSD scrub queue
- *
- * Following our status as Primary or replica.
+ * if activated as a Primary - register the scrub job with the OSD
+ * scrub queue
*/
- virtual void on_primary_change(
- std::string_view caller,
- const requested_scrub_t& request_flags) = 0;
+ virtual void on_pg_activate(const requested_scrub_t& request_flags) = 0;
/**
* Recalculate the required scrub time.