From 61af748a6272adb58e40bcbfa8805d8ef4cf1efa Mon Sep 17 00:00:00 2001 From: Ronen Friedman Date: Wed, 13 Sep 2023 02:09:14 -0500 Subject: [PATCH] osd/scrub: unify dout macros across scrub scheduling code to facilitate easy migration of code fragments between related classes. Signed-off-by: Ronen Friedman --- src/osd/scrubber/osd_scrub_sched.cc | 17 ++++++++++++++--- src/osd/scrubber/osd_scrub_sched.h | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/osd/scrubber/osd_scrub_sched.cc b/src/osd/scrubber/osd_scrub_sched.cc index 4fcca8e940aff..2bbef2a6fa53c 100644 --- a/src/osd/scrubber/osd_scrub_sched.cc +++ b/src/osd/scrubber/osd_scrub_sched.cc @@ -2,6 +2,7 @@ // vim: ts=8 sw=2 smarttab #include "./osd_scrub_sched.h" +#include #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 +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: diff --git a/src/osd/scrubber/osd_scrub_sched.h b/src/osd/scrubber/osd_scrub_sched.h index 90b5c9f400894..b5f4c5eca6889 100644 --- a/src/osd/scrubber/osd_scrub_sched.h +++ b/src/osd/scrubber/osd_scrub_sched.h @@ -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; -- 2.39.5