Scrub::schedule_result_t PG::start_scrubbing(
+ std::unique_ptr<Scrub::ScrubJob> candidate,
Scrub::OSDRestrictions osd_restrictions)
{
dout(10) << fmt::format(
get_pgbackend()->auto_repair_supported());
return m_scrubber->start_scrub_session(
- osd_restrictions, pg_cond, m_planned_scrub);
+ std::move(candidate), osd_restrictions, pg_cond, m_planned_scrub);
}
double PG::next_deepscrub_interval() const
bool get_must_scrub() const;
Scrub::schedule_result_t start_scrubbing(
- Scrub::OSDRestrictions osd_restrictions);
+ std::unique_ptr<Scrub::ScrubJob> candidate,
+ Scrub::OSDRestrictions osd_restrictions);
unsigned int scrub_requeue_priority(
Scrub::scrub_prio_t with_priority,
void OsdScrub::initiate_scrub(bool is_recovery_active)
{
- const utime_t scrub_time = ceph_clock_now();
- dout(10) << fmt::format(
- "time now:{:s}, recovery is active?:{}", scrub_time,
- is_recovery_active)
- << dendl;
-
if (auto blocked_pgs = get_blocked_pgs_count(); blocked_pgs > 0) {
// some PGs managed by this OSD were blocked by a locked object during
// scrub. This means we might not have the resources needed to scrub now.
<< dendl;
}
+ const utime_t scrub_time = ceph_clock_now();
+
// check the OSD-wide environment conditions (scrub resources, time, etc.).
// These may restrict the type of scrubs we are allowed to start, or just
// prevent us from starting any non-operator-initiated scrub at all.
- auto env_restrictions =
+ const auto env_restrictions =
restrictions_on_scrubbing(is_recovery_active, scrub_time);
+ dout(10) << fmt::format("scrub scheduling (@tick) starts. "
+ "time now:{:s}, recovery is active?:{} restrictions:{}",
+ scrub_time, is_recovery_active, env_restrictions)
+ << dendl;
+
if (g_conf()->subsys.should_gather<ceph_subsys_osd, 20>() &&
!env_restrictions.high_priority_only) {
debug_log_all_jobs();
return;
}
- auto res = initiate_a_scrub(candidate->pgid, env_restrictions);
+ auto candidate_pg = candidate->pgid;
+ auto res = initiate_a_scrub(std::move(candidate), env_restrictions);
switch (res) {
case schedule_result_t::target_specific_failure:
break;
case schedule_result_t::scrub_initiated:
- dout(20) << fmt::format("scrub initiated for pg[{}]", candidate->pgid)
- << dendl;
+ dout(20) << fmt::format("scrub initiated for pg[{}]", candidate_pg)
+ << dendl;
break;
}
}
Scrub::schedule_result_t OsdScrub::initiate_a_scrub(
- spg_t pgid,
+ std::unique_ptr<Scrub::ScrubJob> candidate,
Scrub::OSDRestrictions restrictions)
{
- dout(20) << fmt::format("trying pg[{}]", pgid) << dendl;
+ dout(20) << fmt::format("trying pg[{}]", candidate->pgid) << dendl;
// we have a candidate to scrub. We need some PG information to
// know if scrubbing is allowed
- auto locked_pg = m_osd_svc.get_locked_pg(pgid);
+ auto locked_pg = m_osd_svc.get_locked_pg(candidate->pgid);
if (!locked_pg) {
- // the PG was dequeued in the short timespan between creating the
- // candidates list (ready_to_scrub()) and here
- dout(5) << fmt::format("pg[{}] not found", pgid) << dendl;
+ // the PG was dequeued in the short timespan between querying the
+ // scrub queue - and now.
+ dout(5) << fmt::format("pg[{}] not found", candidate->pgid) << dendl;
return Scrub::schedule_result_t::target_specific_failure;
}
- // later on, here is where the scrub target would be dequeued
- return locked_pg->pg()->start_scrubbing(restrictions);
+ // note: the 'candidate', which in this step is a copy of the scrub job,
+ // was already dequeued. The "original" scrub job cannot be accessed from
+ // here directly. Thus - we leave it to start_scrubbing() (via a call
+ // to PgScrubber::start_scrub_session() to mark it as dequeued.
+ return locked_pg->pg()->start_scrubbing(std::move(candidate), restrictions);
}
* initiated, and if not - why.
*/
Scrub::schedule_result_t initiate_a_scrub(
- spg_t pgid,
+ std::unique_ptr<Scrub::ScrubJob> candidate,
Scrub::OSDRestrictions restrictions);
/// resource reservation management
m_fsm->process_event(PrimaryActivate{});
}
+
/*
* A note re the call to publish_stats_to_osd() below:
* - we are called from either request_rescrubbing() or scrub_requested().
Scrub::schedule_result_t PgScrubber::start_scrub_session(
+ std::unique_ptr<Scrub::ScrubJob> candidate,
Scrub::OSDRestrictions osd_restrictions,
Scrub::ScrubPGPreconds pg_cond,
const requested_scrub_t& requested_flags)
{
+ m_scrub_job->target_queued = false;
+
if (is_queued_or_active()) {
// not a real option when the queue entry is the whole ScrubJob, but
// will be possible when using level-specific targets
return schedule_result_t::target_specific_failure;
}
+ m_active_target = std::move(candidate);
+
// for all other failures - we must reinstate our entry in the Scrub Queue
if (!is_primary() || !m_pg->is_active() || !m_pg->is_clean()) {
dout(10) << __func__ << ": cannot scrub (not a clean and active primary)"
[[nodiscard]] bool is_reserving() const final;
Scrub::schedule_result_t start_scrub_session(
+ std::unique_ptr<Scrub::ScrubJob> candidate,
Scrub::OSDRestrictions osd_restrictions,
- Scrub::ScrubPGPreconds,
+ Scrub::ScrubPGPreconds pg_cond,
const requested_scrub_t& requested_flags) final;
void initiate_regular_scrub(epoch_t epoch_queued) final;
*/
bool m_queued_or_active{false};
+ /**
+ * A copy of the specific scheduling target (either shallow_target or
+ * deep_target in the scrub_job) that was selected for this active scrub
+ * session.
+ * \ATTN: in this initial step - a copy of the whole scrub-job is passed
+ * around. Later on this would be just a part of a Scrub::SchedTarget
+ */
+ std::unique_ptr<Scrub::ScrubJob> m_active_target;
+
eversion_t m_subset_last_update{};
std::unique_ptr<Scrub::Store> m_store;
namespace Scrub {
class ReplicaReservations;
struct ReplicaActive;
+ class ScrubJob;
}
/// reservation-related data sent by the primary to the replicas,
/**
* attempt to initiate a scrub session.
+ * @param candidate the scrub job to start. Later on - this will be the
+ * specific queue entry (that carries the information about the level,
+ * priority, etc. of the scrub that should be initiated on this PG).
+ * This parameter is saved by the scrubber for the whole duration of
+ * the scrub session (to be used if the scrub is aborted).
* @param osd_restrictions limitations on the types of scrubs that can
* be initiated on this OSD at this time.
* @param preconds the PG state re scrubbing at the time of the request,
* external reasons.
*/
virtual Scrub::schedule_result_t start_scrub_session(
+ std::unique_ptr<Scrub::ScrubJob> candidate,
Scrub::OSDRestrictions osd_restrictions,
- Scrub::ScrubPGPreconds,
+ Scrub::ScrubPGPreconds pg_cond,
const requested_scrub_t& requested_flags) = 0;
virtual void set_op_parameters(const requested_scrub_t&) = 0;