]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/scrub: unify dout macros across scrub scheduling code
authorRonen Friedman <rfriedma@redhat.com>
Wed, 13 Sep 2023 07:09:14 +0000 (02:09 -0500)
committerRonen Friedman <rfriedma@redhat.com>
Wed, 20 Sep 2023 06:39:10 +0000 (01:39 -0500)
to facilitate easy migration of code fragments between
related classes.

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

index 4fcca8e940affa4ec718b1e1eca77a03beee180f..2bbef2a6fa53c13c3b7f8996a5b6d608044b5d5a 100644 (file)
@@ -2,6 +2,7 @@
 // vim: ts=8 sw=2 smarttab
 #include "./osd_scrub_sched.h"
 
+#include <string_view>
 #include "osd/OSD.h"
 
 #include "pg_scrubber.h"
@@ -21,13 +22,17 @@ using ScrubJob = Scrub::ScrubJob;
 // ////////////////////////////////////////////////////////////////////////// //
 // ScrubQueue
 
+#define dout_subsys ceph_subsys_osd
 #undef dout_context
 #define dout_context (cct)
 #undef dout_prefix
-#define dout_prefix                                                            \
-  *_dout << "osd." << osd_service.get_nodeid() << " scrub-queue::" << __func__ \
-        << " "
+#define dout_prefix _prefix_fn(_dout, this, __func__)
 
+template <class T>
+static std::ostream& _prefix_fn(std::ostream* _dout, T* t, std::string fn = "")
+{
+  return t->gen_prefix(*_dout, fn);
+}
 
 ScrubQueue::ScrubQueue(CephContext* cct, Scrub::ScrubSchedListener& osds)
     : cct{cct}
@@ -42,6 +47,12 @@ ScrubQueue::ScrubQueue(CephContext* cct, Scrub::ScrubSchedListener& osds)
   }
 }
 
+std::ostream& ScrubQueue::gen_prefix(std::ostream& out, std::string_view fn)
+    const
+{
+  return out << fmt::format(
+            "osd.{} scrub-queue:{}: ", osd_service.get_nodeid(), fn);
+}
 
 /*
  * Modify the scrub job state:
index 90b5c9f400894797b2f53d378b9fee5b6ba31483..b5f4c5eca68895ac66cb72ef5c98aee9a0a47dfb 100644 (file)
@@ -245,6 +245,8 @@ class ScrubQueue {
                                      const pg_info_t& pg_info,
                                      const pool_opts_t& pool_conf) const;
 
+  std::ostream& gen_prefix(std::ostream& out, std::string_view fn) const;
+
  public:
   void dump_scrubs(ceph::Formatter* f) const;