]> 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)
committerSmith Farm <smithfarm@vanguard2.suse.cz>
Tue, 30 Apr 2019 15:57:41 +0000 (17:57 +0200)
Signed-off-by: David Zafman <dzafman@redhat.com>
(cherry picked from commit 796794b38b49e44dc9112d684a76e87272697043)

Conflicts:
src/osd/osd_types.h
- nautilus does not have 75014ceb1437c5bb48293574ec6f991e4bec64bb

src/osd/PG.cc
src/osd/osd_types.cc
src/osd/osd_types.h

index b6d3244e18735e41312b7178481966288c4c4ce3..8b0e31296a1128d9dfb40227bf06df531d40bdc5 100644 (file)
@@ -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.
index ba00dd54ba4f040f1bc6f8c7a6aaf67d14f5a316..7a42f566a069066ea5fe558cc9a7e12e7d8e5d2f 100644 (file)
@@ -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<int32_t>::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<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));
 
@@ -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 &&
index 2ed7e1cfa71cee50673f0505d79f10f531c80b5b..3457d5baa2c8a097f7ecf80db107288601224d5f 100644 (file)
@@ -2093,6 +2093,7 @@ struct pg_stat_t {
 
   vector<int32_t> up, acting;
   vector<pg_shard_t> avail_no_missing;
+  map< std::set<pg_shard_t>, int32_t > object_location_counts;
   epoch_t mapping_epoch;
 
   vector<int32_t> blocked_by;  ///< osds on which the pg is blocked