]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Changes to handle sharding for EC in missing_by_count
authorDavid Zafman <dzafman@redhat.com>
Wed, 14 Mar 2018 16:50:06 +0000 (09:50 -0700)
committerDavid Zafman <dzafman@redhat.com>
Wed, 14 Mar 2018 17:07:11 +0000 (10:07 -0700)
Signed-off-by: David Zafman <dzafman@redhat.com>
src/osd/PG.h

index ca89dcff038a545edc7a686811bd63507afbb0a6..a89eb3004d9d8ce50f541e341903592c94beb8c6 100644 (file)
@@ -649,16 +649,38 @@ protected:
     // for every entry in missing_loc, we count how many of each type of shard we have,
     // and maintain totals here.  The sum of the values for this map will always equal
     // missing_loc.size().
-    map<loc_count_t,int> missing_by_count;
+    map < shard_id_t, map<loc_count_t,int> > missing_by_count;
+
+   void pgs_by_shard_id(const set<pg_shard_t>& s, map< shard_id_t, set<pg_shard_t> >& pgsbs) {
+      if (pg->get_osdmap()->pg_is_ec(pg->info.pgid.pgid)) {
+        int num_shards = pg->get_osdmap()->get_pg_size(pg->info.pgid.pgid);
+        // For completely missing shards initialize with empty set<pg_shard_t>
+       for (int i = 0 ; i < num_shards ; ++i) {
+         shard_id_t shard(i);
+         pgsbs[shard];
+       }
+       for (auto pgs: s)
+         pgsbs[pgs.shard].insert(pgs);
+      } else {
+        pgsbs[shard_id_t::NO_SHARD] = s;
+      }
+    }
 
     void _inc_count(const set<pg_shard_t>& s) {
-      ++missing_by_count[_get_count(s)];
+      map< shard_id_t, set<pg_shard_t> > pgsbs;
+      pgs_by_shard_id(s, pgsbs);
+      for (auto shard: pgsbs)
+        ++missing_by_count[shard.first][_get_count(shard.second)];
     }
     void _dec_count(const set<pg_shard_t>& s) {
-      auto p = missing_by_count.find(_get_count(s));
-      assert(p != missing_by_count.end());
-      if (--p->second == 0) {
-       missing_by_count.erase(p);
+      map< shard_id_t, set<pg_shard_t> > pgsbs;
+      pgs_by_shard_id(s, pgsbs);
+      for (auto shard: pgsbs) {
+        auto p = missing_by_count[shard.first].find(_get_count(shard.second));
+        assert(p != missing_by_count[shard.first].end());
+        if (--p->second == 0) {
+         missing_by_count[shard.first].erase(p);
+        }
       }
     }
 
@@ -874,7 +896,7 @@ protected:
     const map<hobject_t, pg_missing_item> &get_needs_recovery() const {
       return needs_recovery_map;
     }
-    const map<loc_count_t,int> &get_missing_by_count() const {
+    const map < shard_id_t, map<loc_count_t,int> > &get_missing_by_count() const {
       return missing_by_count;
     }
   } missing_loc;