]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/scrub: improve scrub information conveyed in standard 60318/head
authorRonen Friedman <rfriedma@redhat.com>
Tue, 15 Oct 2024 11:38:06 +0000 (06:38 -0500)
committerRonen Friedman <rfriedma@redhat.com>
Sun, 27 Oct 2024 10:24:27 +0000 (05:24 -0500)
PG log line references

When "mentioning" a PG in a log message, we include a set of data
items, including some scrub related information. This
commit improves the scrubber information conveyed, following
changes to the scrub scheduler.

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/osd/scrubber/pg_scrubber.cc
src/osd/scrubber/pg_scrubber.h
src/osd/scrubber_common.h

index 594ffb15e2b5bdc2f1df318cbed73d00b4173fd3..c37f31d28dc9d99f6750500a3f603149a4ddbf29 100644 (file)
@@ -2687,9 +2687,53 @@ void PgScrubber::log_cluster_warning(const std::string& warning) const
   m_osds->clog->do_log(CLOG_WARN, warning);
 }
 
-ostream& PgScrubber::show(ostream& out) const
-{
-  return out << " [ " << m_pg_id << ": " << m_flags << " ] ";
+
+ostream& PgScrubber::show_concise(ostream& out) const
+{
+  /*
+  * 'show_concise()' is only used when calling operator<< thru the ScrubPgIF,
+  * i.e. only by the PG when creating a standard log entry.
+  *
+  * desired outcome (only relevant for Primaries):
+  *
+  * if scrubbing:
+  *   (urgency,flags)
+  *   or (if blocked)
+  *   (*blocked*,urgency,flags)
+  *
+  * if not scrubbing:
+  *   either nothing (if only periodic scrubs are scheduled)
+  *   or [next-scrub: effective-lvl, urgency]
+  */
+  if (!is_primary()) {
+    return out;
+  }
+
+  if (m_active) {
+    const auto flags_txt = fmt::format("{}", m_flags);
+    const std::string sep = (flags_txt.empty() ? "" : ",");
+    if (m_active_target) {
+      return out << fmt::format(
+                "({}{}{}{})", (m_scrub_job->blocked ? "*blocked*," : ""),
+                m_active_target->urgency(), sep, flags_txt);
+    } else {
+      // only expected in a couple of messages during scrub termination
+      return out << fmt::format(
+                "(teardown{}{}{})", (m_scrub_job->blocked ? "-*blocked*" : ""),
+                sep, flags_txt);
+    }
+  }
+
+  // not actively scrubbing now. Show some info about the next scrub
+  const auto now_is = ceph_clock_now();
+  const auto& next_scrub = m_scrub_job->earliest_target(now_is);
+  if (!next_scrub.is_high_priority()) {
+    // no interesting flags to report
+    return out;
+  }
+  return out << fmt::format(
+            "[next-scrub:{},{:10.10}]", (next_scrub.is_deep() ? "dp" : "sh"),
+            next_scrub.urgency());
 }
 
 int PgScrubber::asok_debug(std::string_view cmd,
index 1a5813bd9235c1151d522989da833a83b4163cd4..3d7e16cd35938e79f724727107a6459d5966f428 100644 (file)
@@ -164,7 +164,7 @@ template <>
 struct formatter<scrub_flags_t> {
   constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
   template <typename FormatContext>
-  auto format(scrub_flags_t& sf, FormatContext& ctx) const
+  auto format(const scrub_flags_t& sf, FormatContext& ctx) const
   {
     std::string txt;
     bool sep{false};
@@ -528,7 +528,7 @@ class PgScrubber : public ScrubPgIF,
   /// to complete (in order to perform an 'after-repair' scrub)
   bool m_after_repair_scrub_required{false};
 
-  ostream& show(ostream& out) const override;
+  ostream& show_concise(ostream& out) const override;
 
  public:
   //  ------------------  the I/F used by the ScrubBackend (ScrubBeListener)
@@ -741,6 +741,12 @@ class PgScrubber : public ScrubPgIF,
   bool m_publish_sessions{false};  //< will the counter be part of 'query'
                                   //output?
 
+  /**
+   * the scrub operation flags.
+   * Set at scrub start. Checked in multiple locations - mostly
+   * at finish.
+   * Note: replicas only use the 'priority' field.
+   */
   scrub_flags_t m_flags;
 
   bool m_active{false};
index d1a0fbdccb55f9e397cb5a44cbcff764bfc33431..e3a076570b1924374268da6ae5a9c9c6ea98505b 100644 (file)
@@ -299,12 +299,11 @@ struct ScrubPgIF {
 
   virtual ~ScrubPgIF() = default;
 
-  friend std::ostream& operator<<(std::ostream& out, const ScrubPgIF& s)
-  {
-    return s.show(out);
+  friend std::ostream& operator<<(std::ostream& out, const ScrubPgIF& s) {
+    return s.show_concise(out);
   }
 
-  virtual std::ostream& show(std::ostream& out) const = 0;
+  virtual std::ostream& show_concise(std::ostream& out) const = 0;
 
   // --------------- triggering state-machine events: