Skip to content

Commit ce58c88

Browse files
committed
osd/scrub: add dout() capability to the ScrubStore
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 <[email protected]>
1 parent 571e2f3 commit ce58c88

File tree

3 files changed

+61
-11
lines changed

3 files changed

+61
-11
lines changed

src/osd/scrubber/ScrubStore.cc

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
22
// vim: ts=8 sw=2 smarttab
33

4-
#include "ScrubStore.h"
4+
#include "./ScrubStore.h"
55
#include "osd/osd_types.h"
66
#include "common/scrub_types.h"
77
#include "include/rados/rados_types.hpp"
88

9+
#include "pg_scrubber.h"
10+
911
using std::ostringstream;
1012
using std::string;
1113
using std::vector;
@@ -95,16 +97,31 @@ string last_snap_key(int64_t pool)
9597
hoid.build_hash_cache();
9698
return "SCRUB_SS_" + hoid.to_str();
9799
}
100+
101+
} // namespace
102+
103+
#undef dout_context
104+
#define dout_context (m_scrubber.get_pg_cct())
105+
#define dout_subsys ceph_subsys_osd
106+
#undef dout_prefix
107+
#define dout_prefix _prefix_fn(_dout, this, __func__)
108+
109+
template <class T>
110+
static std::ostream& _prefix_fn(std::ostream* _dout, T* t, std::string fn = "")
111+
{
112+
return t->gen_prefix(*_dout, fn);
98113
}
99114

100115
namespace Scrub {
101116

102117
Store::Store(
118+
PgScrubber& scrubber,
103119
ObjectStore& osd_store,
104120
ObjectStore::Transaction* t,
105121
const spg_t& pgid,
106122
const coll_t& coll)
107-
: object_store{osd_store}
123+
: m_scrubber{scrubber}
124+
, object_store{osd_store}
108125
, coll{coll}
109126
{
110127
ceph_assert(t);
@@ -120,6 +137,18 @@ Store::~Store()
120137
ceph_assert(!errors_db || errors_db->results.empty());
121138
}
122139

140+
141+
std::ostream& Store::gen_prefix(std::ostream& out, std::string_view fn) const
142+
{
143+
if (fn.starts_with("operator")) {
144+
// it's a lambda, and __func__ is not available
145+
return m_scrubber.gen_prefix(out) << "Store::";
146+
} else {
147+
return m_scrubber.gen_prefix(out) << "Store::" << fn << ": ";
148+
}
149+
}
150+
151+
123152
void Store::add_error(int64_t pool, const inconsistent_obj_wrapper& e)
124153
{
125154
add_object_error(pool, e);
@@ -163,8 +192,11 @@ void Store::flush(ObjectStore::Transaction* t)
163192

164193
void Store::clear_level_db(
165194
ObjectStore::Transaction* t,
166-
at_level_t& db)
195+
at_level_t& db,
196+
std::string_view db_name)
167197
{
198+
dout(20) << fmt::format("removing (omap) entries for {} error DB", db_name)
199+
<< dendl;
168200
// easiest way to guarantee that the object representing the DB exists
169201
t->touch(coll, db.errors_hoid);
170202

@@ -176,19 +208,27 @@ void Store::clear_level_db(
176208
}
177209

178210

179-
void Store::reinit(ObjectStore::Transaction* t, [[maybe_unused]] scrub_level_t level)
211+
void Store::reinit(
212+
ObjectStore::Transaction* t,
213+
[[maybe_unused]] scrub_level_t level)
180214
{
215+
dout(20) << fmt::format(
216+
"re-initializing the Scrub::Store (for {} scrub)",
217+
(level == scrub_level_t::deep ? "deep" : "shallow"))
218+
<< dendl;
219+
181220
// Note: only one caller, and it creates the transaction passed to reinit().
182221
// No need to assert on 't'
183222

184223
if (errors_db) {
185-
clear_level_db(t, *errors_db);
224+
clear_level_db(t, *errors_db, "scrub");
186225
}
187226
}
188227

189228

190229
void Store::cleanup(ObjectStore::Transaction* t)
191230
{
231+
dout(20) << "discarding error DBs" << dendl;
192232
ceph_assert(t);
193233
if (errors_db)
194234
t->remove(coll, errors_db->errors_hoid);

src/osd/scrubber/ScrubStore.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,20 @@ struct object_id_t;
1414

1515
struct inconsistent_obj_wrapper;
1616
struct inconsistent_snapset_wrapper;
17+
class PgScrubber;
1718

1819
namespace Scrub {
1920

2021
class Store {
2122
public:
2223
~Store();
2324

24-
Store(ObjectStore& osd_store,
25-
ObjectStore::Transaction* t,
26-
const spg_t& pgid,
27-
const coll_t& coll);
25+
Store(
26+
PgScrubber& scrubber,
27+
ObjectStore& osd_store,
28+
ObjectStore::Transaction* t,
29+
const spg_t& pgid,
30+
const coll_t& coll);
2831

2932

3033
/// mark down detected errors, either shallow or deep
@@ -64,6 +67,8 @@ class Store {
6467
const librados::object_id_t& start,
6568
uint64_t max_return) const;
6669

70+
std::ostream& gen_prefix(std::ostream& out, std::string_view fn) const;
71+
6772
private:
6873
/**
6974
* at_level_t
@@ -95,6 +100,10 @@ class Store {
95100
std::vector<ceph::buffer::list> get_errors(const std::string& start,
96101
const std::string& end,
97102
uint64_t max_return) const;
103+
104+
/// access to the owning Scrubber object, for logging mostly
105+
PgScrubber& m_scrubber;
106+
98107
/// the OSD's storage backend
99108
ObjectStore& object_store;
100109

@@ -116,7 +125,8 @@ class Store {
116125
*/
117126
void clear_level_db(
118127
ObjectStore::Transaction* t,
119-
at_level_t& db);
128+
at_level_t& db,
129+
std::string_view db_name);
120130

121131
};
122132
} // namespace Scrub

src/osd/scrubber/pg_scrubber.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ void PgScrubber::reinit_scrub_store()
12231223
} else {
12241224
dout(10) << __func__ << " creating new store" << dendl;
12251225
m_store = std::make_unique<Scrub::Store>(
1226-
*m_pg->osd->store, &t, m_pg->info.pgid, m_pg->coll);
1226+
*this, *m_pg->osd->store, &t, m_pg->info.pgid, m_pg->coll);
12271227
}
12281228

12291229
// regardless of whether the ScrubStore object was recreated or reused, we need to

0 commit comments

Comments
 (0)