]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon, mgr: Improve PG count by changing up to up_no_acting in pg_count
authorDavid Zafman <dzafman@redhat.com>
Thu, 18 Apr 2019 00:11:02 +0000 (17:11 -0700)
committerDavid Zafman <dzafman@redhat.com>
Thu, 25 Apr 2019 20:53:27 +0000 (13:53 -0700)
By not adding a field to pg_count, we don't have to worry about
versioning or backwards compatibility.  A mixed cluster won't
be any worse than before.

Signed-off-by: David Zafman <dzafman@redhat.com>
src/mgr/DaemonServer.cc
src/mon/PGMap.cc
src/mon/PGMap.h

index 141d9b9776128ffe6cbcbecca4a91e6f30261ed5..0dd24c270e6cce551919da18101f74280d14d5b3 100644 (file)
@@ -1379,9 +1379,10 @@ bool DaemonServer::_handle_command(
          }
          auto q = pg_map.num_pg_by_osd.find(osd);
          if (q != pg_map.num_pg_by_osd.end()) {
-           if (q->second.acting > 0 || q->second.up > 0) {
+           if (q->second.acting > 0 || q->second.up_not_acting > 0) {
              active_osds.insert(osd);
-             affected_pgs += q->second.acting + q->second.up;
+             // XXX: For overlapping PGs, this counts them again
+             affected_pgs += q->second.acting + q->second.up_not_acting;
              continue;
            }
          }
@@ -1433,7 +1434,6 @@ bool DaemonServer::_handle_command(
       if (!r) {
         ss << "OSD(s) " << osds << " are safe to destroy without reducing data"
            << " durability.";
-        safe_to_destroy.swap(osds);
       }
       if (f) {
         f->open_object_section("osd_status");
index 49c9013335faf4954c01c539102a02edf6e654dc..8487926516718551e174a18a2aa81a18dc21f8cf 100644 (file)
@@ -172,7 +172,7 @@ void PGMapDigest::dump(ceph::Formatter *f) const
     f->dump_unsigned("osd", p.first);
     f->dump_unsigned("num_primary_pg", p.second.primary);
     f->dump_unsigned("num_acting_pg", p.second.acting);
-    f->dump_unsigned("num_up_pg", p.second.up);
+    f->dump_unsigned("num_up_not_acting_pg", p.second.up_not_acting);
     f->close_section();
   }
   f->close_section();
@@ -1305,8 +1305,11 @@ void PGMap::stat_pg_add(const pg_t &pgid, const pg_stat_t &s,
     num_pg_by_osd[*p].acting++;
   }
   for (auto p = s.up.begin(); p != s.up.end(); ++p) {
-    pg_by_osd[*p].insert(pgid);
-    num_pg_by_osd[*p].up++;
+    auto& t = pg_by_osd[*p];
+    if (t.find(pgid) == t.end()) {
+      t.insert(pgid);
+      num_pg_by_osd[*p].up_not_acting++;
+    }
   }
 
   if (s.up_primary >= 0) {
@@ -1366,7 +1369,9 @@ bool PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s,
       blocked_by_sum.erase(q);
   }
 
+  set<int32_t> actingset;
   for (auto p = s.acting.begin(); p != s.acting.end(); ++p) {
+    actingset.insert(*p);
     auto& oset = pg_by_osd[*p];
     oset.erase(pgid);
     if (oset.empty())
@@ -1380,9 +1385,11 @@ bool PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s,
     oset.erase(pgid);
     if (oset.empty())
       pg_by_osd.erase(*p);
+    if (actingset.count(*p))
+      continue;
     auto it = num_pg_by_osd.find(*p);
-    if (it != num_pg_by_osd.end() && it->second.up > 0)
-      it->second.up--;
+    if (it != num_pg_by_osd.end() && it->second.up_not_acting > 0)
+      it->second.up_not_acting--;
   }
 
   if (s.up_primary >= 0) {
index ecbe60bda05bbd1cca520a676128d3b1d1eb379a..6d1af6338699d2442f9ccaf7ebc53fd5ca8c03b9 100644 (file)
@@ -52,18 +52,18 @@ public:
   mempool::pgmap::unordered_map<uint64_t,int32_t> num_pg_by_state;
   struct pg_count {
     int32_t acting = 0;
-    int32_t up = 0;
+    int32_t up_not_acting = 0;
     int32_t primary = 0;
     void encode(ceph::buffer::list& bl) const {
       using ceph::encode;
       encode(acting, bl);
-      encode(up, bl);
+      encode(up_not_acting, bl);
       encode(primary, bl);
     }
     void decode(ceph::buffer::list::const_iterator& p) {
       using ceph::decode;
       decode(acting, p);
-      decode(up, p);
+      decode(up_not_acting, p);
       decode(primary, p);
     }
   };