From 796794b38b49e44dc9112d684a76e87272697043 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 --- 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 aaeeb158275..6133e5be04a 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -3230,6 +3230,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 " @@ -3306,6 +3307,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 58848a39937..e41765a5dd8 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -2671,6 +2671,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 (auto p = blocked_by.cbegin(); p != blocked_by.cend(); ++p) f->dump_int("osd", *p); @@ -2751,6 +2759,7 @@ void pg_stat_t::encode(ceph::buffer::list &bl) const encode(purged_snaps, bl); encode(manifest_stats_invalid, bl); encode(avail_no_missing, bl); + encode(object_location_counts, bl); ENCODE_FINISH(bl); } @@ -2823,6 +2832,7 @@ void pg_stat_t::decode(ceph::buffer::list::const_iterator &bl) } if (struct_v >= 26) { decode(avail_no_missing, bl); + decode(object_location_counts, bl); } } DECODE_FINISH(bl); @@ -2866,6 +2876,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)); @@ -2911,6 +2925,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 9b9bdd23062..b050f318113 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -2091,6 +2091,7 @@ struct pg_stat_t { std::vector up, acting; std::vector avail_no_missing; + std::map< std::set, int32_t > object_location_counts; epoch_t mapping_epoch; std::vector blocked_by; ///< osds on which the pg is blocked -- 2.39.5