]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/scrub: moving ScrubJob declaration as-is
authorRonen Friedman <rfriedma@redhat.com>
Sat, 9 Sep 2023 19:44:00 +0000 (14:44 -0500)
committerRonen Friedman <rfriedma@redhat.com>
Wed, 20 Sep 2023 06:39:10 +0000 (01:39 -0500)
from osd_scrub_sched.h into scrub_job.h.

A purely mechanical step. No code is changed.

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/osd/scrubber/osd_scrub_sched.h
src/osd/scrubber/scrub_job.h [new file with mode: 0644]

index b00654153205f0e8a895fd4631f9ba207a1e9e71..8ad52e02949b0fb3c3f0f59650ca022e1692ac20 100644 (file)
@@ -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<qu_state_t> 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<ScrubQueue::ScrubJob> {
       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 (file)
index 0000000..5bddb50
--- /dev/null
@@ -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<qu_state_t> 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);
+};