]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Add new object_location_counts to pg_stat_t
authorDavid Zafman <dzafman@redhat.com>
Tue, 16 Apr 2019 21:44:07 +0000 (14:44 -0700)
committerDavid Zafman <dzafman@redhat.com>
Thu, 25 Apr 2019 20:53:27 +0000 (13:53 -0700)
Signed-off-by: David Zafman <dzafman@redhat.com>
src/osd/PG.cc
src/osd/osd_types.cc
src/osd/osd_types.h

index aaeeb158275ffc406b7be34219d16e8fbf4ac853..6133e5be04acbfc2322fd052f91c9bad109f43d4 100644 (file)
@@ -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.
index 58848a399375cf3fca82d84cb2764da9f1b48495..e41765a5dd8dad5122b168196bdd806bc8ec4aae 100644 (file)
@@ -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<pg_stat_t*>& 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<pg_shard_t> 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 &&
index 9b9bdd23062de97a17dd7bdbc97ec83e2cdaa901..b050f318113abd8581a35c70669037682b154e1b 100644 (file)
@@ -2091,6 +2091,7 @@ struct pg_stat_t {
 
   std::vector<int32_t> up, acting;
   std::vector<pg_shard_t> avail_no_missing;
+  std::map< std::set<pg_shard_t>, int32_t > object_location_counts;
   epoch_t mapping_epoch;
 
   std::vector<int32_t> blocked_by;  ///< osds on which the pg is blocked