From e6cc2360b88622dfbcaaf7011f618aa4c3853060 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Tue, 16 Apr 2019 14:44:07 -0700 Subject: [PATCH] osd: Add new object_location_counts to pg_stat_t Signed-off-by: David Zafman (cherry picked from commit 796794b38b49e44dc9112d684a76e87272697043) Conflicts: src/osd/osd_types.h - nautilus does not have 75014ceb1437c5bb48293574ec6f991e4bec64bb --- src/osd/PG.cc | 20 ++++++++++++++++++++ src/osd/osd_types.cc | 15 +++++++++++++++ src/osd/osd_types.h | 1 + 3 files changed, 36 insertions(+) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index b6d3244e18735..8b0e31296a112 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -3232,6 +3232,7 @@ void PG::_update_calc_stats() info.stats.stats.sum.num_objects_unfound = 0; info.stats.stats.sum.num_objects_misplaced = 0; info.stats.avail_no_missing.clear(); + info.stats.object_location_counts.clear(); if ((is_remapped() || is_undersized() || !is_clean()) && (is_peered() || is_activating())) { dout(20) << __func__ << " actingset " << actingset << " upset " @@ -3308,6 +3309,25 @@ void PG::_update_calc_stats() << dendl; } + // Compute object_location_counts + for (auto& ml: missing_loc.get_missing_locs()) { + info.stats.object_location_counts[ml.second]++; + dout(30) << __func__ << " " << ml.first << " object_location_counts[" + << ml.second << "]=" << info.stats.object_location_counts[ml.second] + << dendl; + } + int64_t not_missing = num_objects - missing_loc.get_missing_locs().size(); + if (not_missing) { + // During recovery we know upset == actingset and is being populated + // During backfill we know that all non-missing objects are in the actingset + info.stats.object_location_counts[actingset] = not_missing; + } + dout(30) << __func__ << " object_location_counts[" + << upset << "]=" << info.stats.object_location_counts[upset] + << dendl; + dout(20) << __func__ << " object_location_counts " + << info.stats.object_location_counts << dendl; + // A misplaced object is not stored on the correct OSD int64_t misplaced = 0; // a degraded objects has fewer replicas or EC shards than the pool specifies. diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index ba00dd54ba4f0..7a42f566a0690 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -2645,6 +2645,14 @@ void pg_stat_t::dump(Formatter *f) const for (auto p = avail_no_missing.cbegin(); p != avail_no_missing.cend(); ++p) f->dump_stream("shard") << *p; f->close_section(); + f->open_array_section("object_location_counts"); + for (auto p = object_location_counts.cbegin(); p != object_location_counts.cend(); ++p) { + f->open_object_section("entry"); + f->dump_stream("shards") << p->first; + f->dump_int("objects", p->second); + f->close_section(); + } + f->close_section(); f->open_array_section("blocked_by"); for (vector::const_iterator p = blocked_by.begin(); p != blocked_by.end(); ++p) @@ -2728,6 +2736,7 @@ void pg_stat_t::encode(bufferlist &bl) const encode(purged_snaps, bl); encode(manifest_stats_invalid, bl); encode(avail_no_missing, bl); + encode(object_location_counts, bl); ENCODE_FINISH(bl); } @@ -2800,6 +2809,7 @@ void pg_stat_t::decode(bufferlist::const_iterator &bl) } if (struct_v >= 26) { decode(avail_no_missing, bl); + decode(object_location_counts, bl); } } DECODE_FINISH(bl); @@ -2843,6 +2853,10 @@ void pg_stat_t::generate_test_instances(list& o) a.up_primary = 123; a.acting.push_back(456); a.avail_no_missing.push_back(pg_shard_t(456, shard_id_t::NO_SHARD)); + set sset = { pg_shard_t(0), pg_shard_t(1) }; + a.object_location_counts.insert(make_pair(sset, 10)); + sset.insert(pg_shard_t(2)); + a.object_location_counts.insert(make_pair(sset, 5)); a.acting_primary = 456; o.push_back(new pg_stat_t(a)); @@ -2888,6 +2902,7 @@ bool operator==(const pg_stat_t& l, const pg_stat_t& r) l.up == r.up && l.acting == r.acting && l.avail_no_missing == r.avail_no_missing && + l.object_location_counts == r.object_location_counts && l.mapping_epoch == r.mapping_epoch && l.blocked_by == r.blocked_by && l.last_became_active == r.last_became_active && diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 2ed7e1cfa71ce..3457d5baa2c8a 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -2093,6 +2093,7 @@ struct pg_stat_t { vector up, acting; vector avail_no_missing; + map< std::set, int32_t > object_location_counts; epoch_t mapping_epoch; vector blocked_by; ///< osds on which the pg is blocked -- 2.39.5