]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/scrub: add dout() capability to the ScrubStore
authorRonen Friedman <rfriedma@redhat.com>
Mon, 23 Sep 2024 10:15:57 +0000 (05:15 -0500)
committerRonen Friedman <rfriedma@redhat.com>
Thu, 10 Oct 2024 16:29:20 +0000 (11:29 -0500)
now that the ScrubSTore object is directly created by the
scrubber, (and has a lifetime that does not extend beyond
the scrubber object), we can add the same dout()
mechanism used by the other scrubber sub-objects.

Note: that mechanism will be changed shortly, so that the
sub-objects would use one prefix() creator supplied by
the Scrubber object.

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

index 0c36be6b66b0278aa1a2ae406fc7da0116c9184f..dd141d1c38ca42a1d6aa27d032dfaa20a7ebe90b 100644 (file)
@@ -1,11 +1,13 @@
 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
 // vim: ts=8 sw=2 smarttab
 
-#include "ScrubStore.h"
+#include "./ScrubStore.h"
 #include "osd/osd_types.h"
 #include "common/scrub_types.h"
 #include "include/rados/rados_types.hpp"
 
+#include "pg_scrubber.h"
+
 using std::ostringstream;
 using std::string;
 using std::vector;
@@ -95,16 +97,31 @@ string last_snap_key(int64_t pool)
   hoid.build_hash_cache();
   return "SCRUB_SS_" + hoid.to_str();
 }
+
+}  // namespace
+
+#undef dout_context
+#define dout_context (m_scrubber.get_pg_cct())
+#define dout_subsys ceph_subsys_osd
+#undef dout_prefix
+#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);
 }
 
 namespace Scrub {
 
 Store::Store(
+    PgScrubber& scrubber,
     ObjectStore& osd_store,
     ObjectStore::Transaction* t,
     const spg_t& pgid,
     const coll_t& coll)
-    : object_store{osd_store}
+    : m_scrubber{scrubber}
+    , object_store{osd_store}
     , coll{coll}
 {
   ceph_assert(t);
@@ -120,6 +137,18 @@ Store::~Store()
   ceph_assert(!errors_db || errors_db->results.empty());
 }
 
+
+std::ostream& Store::gen_prefix(std::ostream& out, std::string_view fn) const
+{
+  if (fn.starts_with("operator")) {
+    // it's a lambda, and __func__ is not available
+    return m_scrubber.gen_prefix(out) << "Store::";
+  } else {
+    return m_scrubber.gen_prefix(out) << "Store::" << fn << ": ";
+  }
+}
+
+
 void Store::add_error(int64_t pool, const inconsistent_obj_wrapper& e)
 {
   add_object_error(pool, e);
@@ -163,8 +192,11 @@ void Store::flush(ObjectStore::Transaction* t)
 
 void Store::clear_level_db(
     ObjectStore::Transaction* t,
-    at_level_t& db)
+    at_level_t& db,
+    std::string_view db_name)
 {
+  dout(20) << fmt::format("removing (omap) entries for {} error DB", db_name)
+          << dendl;
   // easiest way to guarantee that the object representing the DB exists
   t->touch(coll, db.errors_hoid);
 
@@ -176,19 +208,27 @@ void Store::clear_level_db(
 }
 
 
-void Store::reinit(ObjectStore::Transaction* t, [[maybe_unused]] scrub_level_t level)
+void Store::reinit(
+    ObjectStore::Transaction* t,
+    [[maybe_unused]] scrub_level_t level)
 {
+  dout(20) << fmt::format(
+                 "re-initializing the Scrub::Store (for {} scrub)",
+                 (level == scrub_level_t::deep ? "deep" : "shallow"))
+          << dendl;
+
   // Note: only one caller, and it creates the transaction passed to reinit().
   // No need to assert on 't'
 
   if (errors_db) {
-    clear_level_db(t, *errors_db);
+    clear_level_db(t, *errors_db, "scrub");
   }
 }
 
 
 void Store::cleanup(ObjectStore::Transaction* t)
 {
+  dout(20) << "discarding error DBs" << dendl;
   ceph_assert(t);
   if (errors_db)
     t->remove(coll, errors_db->errors_hoid);
index 600905e85e8a286af309680db4c3daccd785213b..a83841e2cfbb2368345f1c323a7f9771607d4475 100644 (file)
@@ -14,6 +14,7 @@ struct object_id_t;
 
 struct inconsistent_obj_wrapper;
 struct inconsistent_snapset_wrapper;
+class PgScrubber;
 
 namespace Scrub {
 
@@ -21,10 +22,12 @@ class Store {
  public:
   ~Store();
 
-  Store(ObjectStore& osd_store,
-    ObjectStore::Transaction* t,
-    const spg_t& pgid,
-    const coll_t& coll);
+  Store(
+      PgScrubber& scrubber,
+      ObjectStore& osd_store,
+      ObjectStore::Transaction* t,
+      const spg_t& pgid,
+      const coll_t& coll);
 
 
   /// mark down detected errors, either shallow or deep
@@ -64,6 +67,8 @@ class Store {
     const librados::object_id_t& start,
     uint64_t max_return) const;
 
+  std::ostream& gen_prefix(std::ostream& out, std::string_view fn) const;
+
  private:
   /**
    * at_level_t
@@ -95,6 +100,10 @@ class Store {
   std::vector<ceph::buffer::list> get_errors(const std::string& start,
                                             const std::string& end,
                                             uint64_t max_return) const;
+
+  /// access to the owning Scrubber object, for logging mostly
+  PgScrubber& m_scrubber;
+
   /// the OSD's storage backend
   ObjectStore& object_store;
 
@@ -116,7 +125,8 @@ class Store {
    */
   void clear_level_db(
       ObjectStore::Transaction* t,
-      at_level_t& db);
+      at_level_t& db,
+      std::string_view db_name);
 
 };
 }  // namespace Scrub
index a085481f477acd525dbcffa006f3cf597f21e017..81093666f91c8d762a91dc9d6ebfbd4db9d7e62d 100644 (file)
@@ -1223,7 +1223,7 @@ void PgScrubber::reinit_scrub_store()
   } else {
     dout(10) << __func__ << " creating new store" << dendl;
     m_store = std::make_unique<Scrub::Store>(
-       *m_pg->osd->store, &t, m_pg->info.pgid, m_pg->coll);
+       *this, *m_pg->osd->store, &t, m_pg->info.pgid, m_pg->coll);
   }
 
   // regardless of whether the ScrubStore object was recreated or reused, we need to