Skip to content

Commit a768156

Browse files
authored
Merge pull request ceph#65338 from ronen-fr/wip-rf-be-st3
osd/scrub: modify OMAP stats collection Reviewed-by: Jon Bailey <[email protected]> Reviewed-by: Samuel Just <[email protected]>
2 parents 990dba2 + 6b85e4d commit a768156

File tree

2 files changed

+44
-47
lines changed

2 files changed

+44
-47
lines changed

src/osd/scrubber/scrub_backend.cc

Lines changed: 34 additions & 46 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,31 @@ 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-
}
275249

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;
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+
257+
if (obj_in_smap.large_omap_object_found) {
258+
m_omap_stats.large_omap_objects++;
259+
if (!this_chunk->m_large_omap_warning_issued) {
260+
this_chunk->m_large_omap_warning_issued = true;
261+
std::string erm = fmt::format(
262+
"Large omap object found. Object: {} PG: {} Key count: {} Size "
263+
"(bytes): {}\n",
264+
ho, m_pg_id, obj_in_smap.large_omap_object_key_count,
265+
obj_in_smap.large_omap_object_value_size);
266+
267+
clog.do_log(CLOG_WARN, erm);
268+
dout(5) << __func__ << ": " << erm << dendl;
290269
}
291270
}
292-
293-
if (!wss.str().empty()) {
294-
dout(5) << __func__ << ": " << wss.str() << dendl;
295-
clog.warn(wss);
296-
}
297271
}
298272

273+
299274
/*
300275
* update_authoritative() updates:
301276
*
@@ -309,6 +284,16 @@ void ScrubBackend::update_authoritative()
309284
dout(10) << __func__ << dendl;
310285

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

@@ -932,9 +917,12 @@ std::optional<std::string> ScrubBackend::compare_obj_in_maps(
932917
auto& auth = auth_res.auth;
933918

934919
// an auth source was selected
920+
ScrubMap::object& auth_object = auth->second.objects[ho];
921+
922+
// collect some OMAP statistics based on the selected version of the object
923+
collect_omap_stats(ho, auth_object);
935924

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

940928
auto [auths, objerrs] =

src/osd/scrubber/scrub_backend.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@ struct scrub_chunk_t {
294294

295295
// EC-related:
296296
shard_id_map<bufferlist> m_ec_digest_map;
297+
298+
/// only one 'large OMAP' warning per chunk
299+
bool m_large_omap_warning_issued{false};
297300
};
298301

299302

@@ -435,7 +438,13 @@ class ScrubBackend {
435438
/// might return error messages to be cluster-logged
436439
std::optional<std::string> compare_obj_in_maps(const hobject_t& ho);
437440

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

440449
std::optional<auth_and_obj_errs_t> for_empty_auth_list(
441450
std::list<pg_shard_t>&& auths,

0 commit comments

Comments
 (0)