Skip to content

Commit 5e59c52

Browse files
committed
osd/scrub: modify OMAP stats collection
Replace the separate all-chunk loop with object-by-object handling. Use the selected authoritative version of the object as the info source. Signed-off-by: Ronen Friedman <[email protected]>
1 parent 7848045 commit 5e59c52

File tree

2 files changed

+38
-48
lines changed

2 files changed

+38
-48
lines changed

src/osd/scrubber/scrub_backend.cc

Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,6 @@ objs_fix_list_t ScrubBackend::scrub_compare_maps(
234234
m_cleaned_meta_map.insert(my_map());
235235
merge_to_authoritative_set();
236236

237-
// collect some omap statistics into m_omap_stats
238-
omap_checks();
239-
240237
update_authoritative();
241238
auto for_meta_scrub = clean_meta_map(m_cleaned_meta_map, max_reached);
242239

@@ -249,53 +246,27 @@ objs_fix_list_t ScrubBackend::scrub_compare_maps(
249246
scan_snaps(for_meta_scrub, snaps_getter)};
250247
}
251248

252-
void ScrubBackend::omap_checks()
253-
{
254-
const bool needs_omap_check = std::any_of(
255-
this_chunk->received_maps.begin(),
256-
this_chunk->received_maps.end(),
257-
[](const auto& m) -> bool {
258-
return m.second.has_large_omap_object_errors || m.second.has_omap_keys;
259-
});
260-
261-
if (!needs_omap_check) {
262-
return; // Nothing to do
263-
}
264-
265-
stringstream wss;
266-
const auto& smap = this_chunk->received_maps.at(m_pg_whoami);
267-
268-
// Iterate through objects and update omap stats
269-
for (const auto& ho : this_chunk->authoritative_set) {
270-
271-
const auto it = smap.objects.find(ho);
272-
if (it == smap.objects.end()) {
273-
continue;
274-
}
275-
276-
const ScrubMap::object& smap_obj = it->second;
277-
m_omap_stats.omap_bytes += smap_obj.object_omap_bytes;
278-
m_omap_stats.omap_keys += smap_obj.object_omap_keys;
279-
if (smap_obj.large_omap_object_found) {
280-
auto osdmap = m_scrubber.get_osdmap();
281-
pg_t pg;
282-
osdmap->map_to_pg(ho.pool, ho.oid.name, ho.get_key(), ho.nspace, &pg);
283-
pg_t mpg = osdmap->raw_pg_to_pg(pg);
284-
m_omap_stats.large_omap_objects++;
285-
wss << "Large omap object found. Object: " << ho << " PG: " << pg << " ("
286-
<< mpg << ")"
287-
<< " Key count: " << smap_obj.large_omap_object_key_count
288-
<< " Size (bytes): " << smap_obj.large_omap_object_value_size << '\n';
289-
break;
290-
}
291-
}
292249

293-
if (!wss.str().empty()) {
294-
dout(5) << __func__ << ": " << wss.str() << dendl;
295-
clog.warn(wss);
250+
void ScrubBackend::collect_omap_stats(
251+
const hobject_t& ho,
252+
const ScrubMap::object& obj_in_smap)
253+
{
254+
m_omap_stats.omap_bytes += obj_in_smap.object_omap_bytes;
255+
m_omap_stats.omap_keys += obj_in_smap.object_omap_keys;
256+
if (obj_in_smap.large_omap_object_found) {
257+
m_omap_stats.large_omap_objects++;
258+
std::string erm = fmt::format(
259+
"Large omap object found. Object: {} PG: {} ({}) Key count: {} Size "
260+
"(bytes): {}\n",
261+
ho, m_pg_id, m_pg_id, obj_in_smap.large_omap_object_key_count,
262+
obj_in_smap.large_omap_object_value_size);
263+
264+
clog.do_log(CLOG_WARN, erm);
265+
dout(5) << __func__ << ": " << erm << dendl;
296266
}
297267
}
298268

269+
299270
/*
300271
* update_authoritative() updates:
301272
*
@@ -309,6 +280,16 @@ void ScrubBackend::update_authoritative()
309280
dout(10) << __func__ << dendl;
310281

311282
if (m_acting_but_me.empty()) {
283+
// nothing to fix. Just count OMAP stats
284+
// (temporary code - to be removed once scrub_compare_maps()
285+
// is modified to process object-by-object)
286+
for (const auto& ho : this_chunk->authoritative_set) {
287+
const auto it = my_map().objects.find(ho);
288+
// all objects in the authoritative set should be there, in the
289+
// map of the sole OSD
290+
ceph_assert(it != my_map().objects.end());
291+
collect_omap_stats(ho, it->second);
292+
}
312293
return;
313294
}
314295

@@ -932,9 +913,12 @@ std::optional<std::string> ScrubBackend::compare_obj_in_maps(
932913
auto& auth = auth_res.auth;
933914

934915
// an auth source was selected
916+
ScrubMap::object& auth_object = auth->second.objects[ho];
917+
918+
// collect some OMAP statistics based on the selected version of the object
919+
collect_omap_stats(ho, auth_object);
935920

936921
object_error.set_version(auth_res.auth_oi.user_version);
937-
ScrubMap::object& auth_object = auth->second.objects[ho];
938922
ceph_assert(!m_current_obj.fix_digest);
939923

940924
auto [auths, objerrs] =

src/osd/scrubber/scrub_backend.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,13 @@ class ScrubBackend {
435435
/// might return error messages to be cluster-logged
436436
std::optional<std::string> compare_obj_in_maps(const hobject_t& ho);
437437

438-
void omap_checks();
438+
/**
439+
* add the OMAP stats for the handled object to the m_omap_stats info.
440+
* Also warn if the object has large omap keys or values.
441+
*/
442+
void collect_omap_stats(
443+
const hobject_t& ho,
444+
const ScrubMap::object& auth_object);
439445

440446
std::optional<auth_and_obj_errs_t> for_empty_auth_list(
441447
std::list<pg_shard_t>&& auths,

0 commit comments

Comments
 (0)