// -*- 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;
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);
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);
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);
}
-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);
struct inconsistent_obj_wrapper;
struct inconsistent_snapset_wrapper;
+class PgScrubber;
namespace Scrub {
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
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
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;
*/
void clear_level_db(
ObjectStore::Transaction* t,
- at_level_t& db);
+ at_level_t& db,
+ std::string_view db_name);
};
} // namespace Scrub