From c43853afd5748d5092c6474016cbbf5bc607de44 Mon Sep 17 00:00:00 2001 From: Ronen Friedman Date: Tue, 10 Sep 2024 01:08:14 -0500 Subject: [PATCH] osd/scrub: set_op_parameters() no longer uses the 'requested' flags ... and the same goes for request_rescrubbing(). The requested_flag_t::auto_repair can now be removed. Signed-off-by: Ronen Friedman --- src/osd/scrubber/pg_scrubber.cc | 80 ++++++++++++++++----------------- src/osd/scrubber/pg_scrubber.h | 15 ++----- src/osd/scrubber_common.h | 15 +------ 3 files changed, 44 insertions(+), 66 deletions(-) diff --git a/src/osd/scrubber/pg_scrubber.cc b/src/osd/scrubber/pg_scrubber.cc index 408089bba30..163641d92aa 100644 --- a/src/osd/scrubber/pg_scrubber.cc +++ b/src/osd/scrubber/pg_scrubber.cc @@ -61,10 +61,6 @@ ostream& operator<<(ostream& out, const scrub_flags_t& sf) ostream& operator<<(ostream& out, const requested_scrub_t& sf) { - if (sf.auto_repair) - out << " planned AUTO_REPAIR"; - if (sf.need_auto) - out << " NEED_AUTO"; if (sf.req_scrub) out << " planned REQ_SCRUB"; @@ -686,11 +682,10 @@ bool PgScrubber::is_after_repair_required() const * Note that no need to requeue the target, as it will be requeued * when the scrub ends. */ -void PgScrubber::request_rescrubbing(requested_scrub_t& request_flags) +void PgScrubber::request_rescrubbing() { - dout(10) << __func__ << " flags: " << request_flags << dendl; - - request_flags.need_auto = true; + dout(10) << fmt::format("{}: job on entry: {}", __func__, *m_scrub_job) + << dendl; auto& trgt = m_scrub_job->get_target(scrub_level_t::deep); trgt.up_urgency_to(urgency_t::repairing); const auto clock_now = ceph_clock_now(); @@ -1676,52 +1671,29 @@ void PgScrubber::replica_scrub_op(OpRequestRef op) cost); } -void PgScrubber::set_op_parameters( - ScrubPGPreconds pg_cond, - const requested_scrub_t& request) +void PgScrubber::set_op_parameters(ScrubPGPreconds pg_cond) { - dout(10) << fmt::format("{}: @ input: {}", __func__, request) << dendl; + dout(10) << fmt::format("{}: target: {}", __func__, *m_active_target) + << dendl; - set_queued_or_active(); // we are fully committed now. + set_queued_or_active(); // we are fully committed now. // write down the epoch of starting a new scrub. Will be used // to discard stale messages from previous aborted scrubs. m_epoch_start = m_pg->get_osdmap_epoch(); - m_flags.check_repair = m_active_target->urgency() == urgency_t::after_repair; - m_flags.auto_repair = false; - if (ScrubJob::has_high_queue_priority(m_active_target->urgency())) { - // specific high priority scrubs - high queue priority - /// \todo consider - do we really want high queue priority for any scrub? - m_flags.priority = get_pg_cct()->_conf->osd_requested_scrub_priority; - } else { - // regular, low-priority scrubs - low queue priority - unless blocking - // client I/O - m_flags.priority = m_pg->get_scrub_priority(); - } + // set the session attributes, as coded in m_flags, m_is_deep and m_is_repair - // 'deep-on-error' is set for periodic shallow scrubs, if allowed - // by the environment - if (m_active_target->is_shallow() && pg_cond.can_autorepair && - m_active_target->urgency() == urgency_t::periodic_regular) { - m_flags.deep_scrub_on_error = true; - dout(10) << fmt::format( - "{}: auto repair with scrubbing, rescrub if errors found", - __func__) - << dendl; - } + m_flags.check_repair = m_active_target->urgency() == urgency_t::after_repair; + m_is_deep = m_active_target->sched_info.level == scrub_level_t::deep; state_set(PG_STATE_SCRUBBING); - - // will we be deep-scrubbing? - m_is_deep = m_active_target->sched_info.level == scrub_level_t::deep; if (m_is_deep) { state_set(PG_STATE_DEEP_SCRUB); - if (pg_cond.can_autorepair || request.auto_repair) { - m_flags.auto_repair = true; - } } + m_flags.auto_repair = m_is_deep && pg_cond.can_autorepair; + // m_is_repair is set for all repair cases - for operator-requested // repairs, for deep-scrubs initiated automatically after a shallow scrub // that has ended with repairable error, and for 'repair-on-the-go' (i.e. @@ -1739,6 +1711,30 @@ void PgScrubber::set_op_parameters( update_op_mode_text(); } + + // 'deep-on-error' is set for periodic shallow scrubs, if allowed + // by the environment + if (!m_is_deep && pg_cond.can_autorepair && + m_active_target->urgency() == urgency_t::periodic_regular) { + m_flags.deep_scrub_on_error = true; + dout(10) << fmt::format( + "{}: auto repair with scrubbing, rescrub if errors found", + __func__) + << dendl; + } else { + m_flags.deep_scrub_on_error = false; + } + + if (ScrubJob::has_high_queue_priority(m_active_target->urgency())) { + // specific high priority scrubs - high queue priority + /// \todo consider - do we really want high queue priority for any scrub? + m_flags.priority = get_pg_cct()->_conf->osd_requested_scrub_priority; + } else { + // regular, low-priority scrubs - low queue priority - unless blocking + // client I/O + m_flags.priority = m_pg->get_scrub_priority(); + } + // The publishing here is required for tests synchronization. // The PG state flags were modified. m_pg->publish_stats_to_osd(); @@ -2110,7 +2106,7 @@ void PgScrubber::scrub_finish() cleanup_on_finish(); if (do_auto_scrub) { - request_rescrubbing(m_planned_scrub); + request_rescrubbing(); } // determine the next scrub time update_scrub_job(delay_ready_t::delay_ready); @@ -2388,7 +2384,7 @@ Scrub::schedule_result_t PgScrubber::start_scrub_session( state_clear(PG_STATE_REPAIR); m_active_target = trgt; - set_op_parameters(pg_cond, m_planned_scrub); + set_op_parameters(pg_cond); // dequeue the PG's "other" target m_osds->get_scrub_services().remove_from_osd_queue(m_pg_id); m_scrub_job->clear_both_targets_queued(); diff --git a/src/osd/scrubber/pg_scrubber.h b/src/osd/scrubber/pg_scrubber.h index d90ad171bdb..b1aecf19d92 100644 --- a/src/osd/scrubber/pg_scrubber.h +++ b/src/osd/scrubber/pg_scrubber.h @@ -143,9 +143,8 @@ struct scrub_flags_t { unsigned int priority{0}; /** - * set by queue_scrub() if either planned_scrub.auto_repair or - * need_auto were set. - * Tested at scrub end. + * set by set_op_parameters() for deep scrubs, if the hardware + * supports auto repairing and osd_scrub_auto_repair is enabled. */ bool auto_repair{false}; @@ -365,14 +364,8 @@ class PgScrubber : public ScrubPgIF, /** * finalize the parameters of the initiated scrubbing session: - * - * The "current scrub" flags (m_flags) are set from the 'planned_scrub' - * flag-set; PG_STATE_SCRUBBING, and possibly PG_STATE_DEEP_SCRUB & - * PG_STATE_REPAIR are set. */ - void set_op_parameters( - Scrub::ScrubPGPreconds pg_cond, - const requested_scrub_t& request) final; + void set_op_parameters(Scrub::ScrubPGPreconds pg_cond) final; void cleanup_store(ObjectStore::Transaction* t) final; @@ -841,7 +834,7 @@ class PgScrubber : public ScrubPgIF, /** * initiate a deep-scrub after the current scrub ended with errors. */ - void request_rescrubbing(requested_scrub_t& req_flags); + void request_rescrubbing(); /** * combine cluster & pool configuration options into a single struct diff --git a/src/osd/scrubber_common.h b/src/osd/scrubber_common.h index 657b4130093..44bc5b8b752 100644 --- a/src/osd/scrubber_common.h +++ b/src/osd/scrubber_common.h @@ -317,14 +317,6 @@ struct requested_scrub_t { * scrubbing starts, will cause auto_repair to be set. */ bool need_auto{false}; - - /* - * the value of auto_repair is determined in sched_scrub() (once per scrub. - * previous value is not remembered). Set if - * - allowed by configuration and backend, and - * - for periodic scrubs: time_for_deep was just set RRR - */ - bool auto_repair{false}; }; std::ostream& operator<<(std::ostream& out, const requested_scrub_t& sf); @@ -337,8 +329,7 @@ struct fmt::formatter { auto format(const requested_scrub_t& rs, FormatContext& ctx) const { return fmt::format_to(ctx.out(), - "(plnd:{}{}{})", - rs.auto_repair ? " auto_repair" : "", + "(plnd:{}{})", rs.need_auto ? " need_auto" : "", rs.req_scrub ? " req_scrub" : ""); } @@ -457,9 +448,7 @@ struct ScrubPgIF { Scrub::ScrubPGPreconds pg_cond, const requested_scrub_t& requested_flags) = 0; - virtual void set_op_parameters( - Scrub::ScrubPGPreconds pg_cond, - const requested_scrub_t&) = 0; + virtual void set_op_parameters(Scrub::ScrubPGPreconds pg_cond) = 0; /// stop any active scrubbing (on interval end) and unregister from /// the OSD scrub queue -- 2.39.5