From 6db324700ffbd52388db2da14f1d1cda34f6dbf3 Mon Sep 17 00:00:00 2001 From: Ronen Friedman Date: Sat, 9 Sep 2023 14:44:00 -0500 Subject: [PATCH] osd/scrub: moving ScrubJob declaration as-is from osd_scrub_sched.h into scrub_job.h. A purely mechanical step. No code is changed. Signed-off-by: Ronen Friedman --- src/osd/scrubber/osd_scrub_sched.h | 103 +--------------------------- src/osd/scrubber/scrub_job.h | 106 +++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 101 deletions(-) create mode 100644 src/osd/scrubber/scrub_job.h diff --git a/src/osd/scrubber/osd_scrub_sched.h b/src/osd/scrubber/osd_scrub_sched.h index b00654153205f..8ad52e02949b0 100644 --- a/src/osd/scrubber/osd_scrub_sched.h +++ b/src/osd/scrubber/osd_scrub_sched.h @@ -188,107 +188,7 @@ class ScrubQueue { ScrubQueue(CephContext* cct, Scrub::ScrubSchedListener& osds); virtual ~ScrubQueue() = default; - struct scrub_schedule_t { - utime_t scheduled_at{}; - utime_t deadline{0, 0}; - }; - - struct sched_params_t { - utime_t proposed_time{}; - double min_interval{0.0}; - double max_interval{0.0}; - must_scrub_t is_must{ScrubQueue::must_scrub_t::not_mandatory}; - }; - - struct ScrubJob final : public RefCountedObject { - - /** - * a time scheduled for scrub, and a deadline: The scrub could be delayed - * if system load is too high (but not if after the deadline),or if trying - * to scrub out of scrub hours. - */ - scrub_schedule_t schedule; - - /// pg to be scrubbed - const spg_t pgid; - - /// the OSD id (for the log) - const int whoami; - - ceph::atomic state{qu_state_t::not_registered}; - - /** - * the old 'is_registered'. Set whenever the job is registered with the OSD, - * i.e. is in either the 'to_scrub' or the 'penalized' vectors. - */ - std::atomic_bool in_queues{false}; - - /// last scrub attempt failed to secure replica resources - bool resources_failure{false}; - - /** - * 'updated' is a temporary flag, used to create a barrier after - * 'sched_time' and 'deadline' (or any other job entry) were modified by - * different task. - * 'updated' also signals the need to move a job back from the penalized - * queue to the regular one. - */ - std::atomic_bool updated{false}; - - /** - * the scrubber is waiting for locked objects to be unlocked. - * Set after a grace period has passed. - */ - bool blocked{false}; - utime_t blocked_since{}; - - utime_t penalty_timeout{0, 0}; - - CephContext* cct; - - ScrubJob(CephContext* cct, const spg_t& pg, int node_id); - - utime_t get_sched_time() const { return schedule.scheduled_at; } - - /** - * relatively low-cost(*) access to the scrub job's state, to be used in - * logging. - * (*) not a low-cost access on x64 architecture - */ - std::string_view state_desc() const - { - return ScrubQueue::qu_state_text(state.load(std::memory_order_relaxed)); - } - - void update_schedule(const ScrubQueue::scrub_schedule_t& adjusted); - - void dump(ceph::Formatter* f) const; - - /* - * as the atomic 'in_queues' appears in many log prints, accessing it for - * display-only should be made less expensive (on ARM. On x86 the _relaxed - * produces the same code as '_cs') - */ - std::string_view registration_state() const - { - return in_queues.load(std::memory_order_relaxed) ? "in-queue" - : "not-queued"; - } - - /** - * access the 'state' directly, for when a distinction between 'registered' - * and 'unregistering' is needed (both have in_queues() == true) - */ - bool is_state_registered() const { return state == qu_state_t::registered; } - - /** - * a text description of the "scheduling intentions" of this PG: - * are we already scheduled for a scrub/deep scrub? when? - */ - std::string scheduling_state(utime_t now_is, bool is_deep_expected) const; - - friend std::ostream& operator<<(std::ostream& out, const ScrubJob& pg); - }; +#include "osd/scrubber/scrub_job.h" friend class TestOSDScrub; friend class ScrubSchedTestWrapper; ///< unit-tests structure @@ -558,3 +458,4 @@ struct fmt::formatter { sjob.state.load(std::memory_order_relaxed)); } }; + diff --git a/src/osd/scrubber/scrub_job.h b/src/osd/scrubber/scrub_job.h new file mode 100644 index 0000000000000..5bddb50200e92 --- /dev/null +++ b/src/osd/scrubber/scrub_job.h @@ -0,0 +1,106 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +struct scrub_schedule_t { + utime_t scheduled_at{}; + utime_t deadline{0, 0}; +}; + + +struct sched_params_t { + utime_t proposed_time{}; + double min_interval{0.0}; + double max_interval{0.0}; + must_scrub_t is_must{ScrubQueue::must_scrub_t::not_mandatory}; +}; + + struct ScrubJob final : public RefCountedObject { + + /** + * a time scheduled for scrub, and a deadline: The scrub could be delayed + * if system load is too high (but not if after the deadline),or if trying + * to scrub out of scrub hours. + */ + scrub_schedule_t schedule; + + /// pg to be scrubbed + const spg_t pgid; + + /// the OSD id (for the log) + const int whoami; + + ceph::atomic state{qu_state_t::not_registered}; + + /** + * the old 'is_registered'. Set whenever the job is registered with the OSD, + * i.e. is in either the 'to_scrub' or the 'penalized' vectors. + */ + std::atomic_bool in_queues{false}; + + /// last scrub attempt failed to secure replica resources + bool resources_failure{false}; + + /** + * 'updated' is a temporary flag, used to create a barrier after + * 'sched_time' and 'deadline' (or any other job entry) were modified by + * different task. + * 'updated' also signals the need to move a job back from the penalized + * queue to the regular one. + */ + std::atomic_bool updated{false}; + + /** + * the scrubber is waiting for locked objects to be unlocked. + * Set after a grace period has passed. + */ + bool blocked{false}; + utime_t blocked_since{}; + + utime_t penalty_timeout{0, 0}; + + CephContext* cct; + + ScrubJob(CephContext* cct, const spg_t& pg, int node_id); + + utime_t get_sched_time() const { return schedule.scheduled_at; } + + + /** + * relatively low-cost(*) access to the scrub job's state, to be used in + * logging. + * (*) not a low-cost access on x64 architecture + */ + std::string_view state_desc() const + { + return ScrubQueue::qu_state_text(state.load(std::memory_order_relaxed)); + } + + void update_schedule(const ScrubQueue::scrub_schedule_t& adjusted); + + void dump(ceph::Formatter* f) const; + + /* + * as the atomic 'in_queues' appears in many log prints, accessing it for + * display-only should be made less expensive (on ARM. On x86 the _relaxed + * produces the same code as '_cs') + */ + std::string_view registration_state() const + { + return in_queues.load(std::memory_order_relaxed) ? "in-queue" + : "not-queued"; + } + + /** + * access the 'state' directly, for when a distinction between 'registered' + * and 'unregistering' is needed (both have in_queues() == true) + */ + bool is_state_registered() const { return state == qu_state_t::registered; } + + /** + * a text description of the "scheduling intentions" of this PG: + * are we already scheduled for a scrub/deep scrub? when? + */ + std::string scheduling_state(utime_t now_is, bool is_deep_expected) const; + + friend std::ostream& operator<<(std::ostream& out, const ScrubJob& pg); +}; -- 2.39.5