]> git.apps.os.sepia.ceph.com Git - ceph.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)
committerSmith Farm <smithfarm@vanguard2.suse.cz>
Tue, 30 Apr 2019 15:57:41 +0000 (17:57 +0200)
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>
(cherry picked from commit 69eaaaadd00f190f3013abbf8c713b47c0b3e7bc)

src/mgr/DaemonServer.cc
src/mon/PGMap.cc
src/mon/PGMap.h

index e9a868f0abc4817043465b215162c318f2cb0991..4b9ee4b301ff592cc54b589437a629c04d0c2f7c 100644 (file)
@@ -1383,9 +1383,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;
            }
          }
@@ -1437,7 +1438,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 78731fd707911339e9043d95620f5bba820b03c3..b970eac9ef6b5f63bd88648850b4173fd712dcf1 100644 (file)
@@ -159,7 +159,7 @@ void PGMapDigest::dump(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();
@@ -1296,8 +1296,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) {
@@ -1357,7 +1360,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())
@@ -1371,9 +1376,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 fdc7cb87f6567836671df0a9d2d3694cb9d6a16f..550560064eacfc97062c14267c0c3fdda8f3fdce 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(bufferlist& bl) const {
       using ceph::encode;
       encode(acting, bl);
-      encode(up, bl);
+      encode(up_not_acting, bl);
       encode(primary, bl);
     }
     void decode(bufferlist::const_iterator& p) {
       using ceph::decode;
       decode(acting, p);
-      decode(up, p);
+      decode(up_not_acting, p);
       decode(primary, p);
     }
   };