]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-monstore-tool: rebuild creating_pgs
authorSage Weil <sage@redhat.com>
Tue, 9 Oct 2018 23:06:18 +0000 (18:06 -0500)
committerSage Weil <sage@redhat.com>
Wed, 10 Oct 2018 13:47:22 +0000 (08:47 -0500)
In particular, we need to rebuild the created_pools set or else the mon
will try to recreate every PG in the system.  On an aged cluster, that
is extremely expensive, and will break things.

Fixes: http://tracker.ceph.com/issues/36306
Signed-off-by: Sage Weil <sage@redhat.com>
src/tools/ceph_monstore_tool.cc

index 20db4db2658766e31f136e306b80f88e6f5dddf8..29c38080d3371ed6020a571fae9e9b3cdf248351 100644 (file)
@@ -33,6 +33,7 @@
 #include "mon/MgrMap.h"
 #include "osd/OSDMap.h"
 #include "crush/CrushCompiler.h"
+#include "mon/CreatingPGs.h"
 
 namespace po = boost::program_options;
 
@@ -590,6 +591,35 @@ static int update_monitor(MonitorDBStore& st)
   return 0;
 }
 
+// rebuild
+//  - creating_pgs
+static int update_creating_pgs(MonitorDBStore& st)
+{
+  bufferlist bl;
+  auto last_osdmap_epoch = st.get("osdmap", "last_committed");
+  int r = st.get("osdmap", st.combine_strings("full", last_osdmap_epoch), bl);
+  if (r < 0) {
+    cerr << "unable to losd osdmap e" << last_osdmap_epoch << std::endl;
+    return r;
+  }
+
+  OSDMap osdmap;
+  osdmap.decode(bl);
+  creating_pgs_t creating;
+  for (auto& i : osdmap.get_pools()) {
+    creating.created_pools.insert(i.first);
+  }
+  creating.last_scan_epoch = last_osdmap_epoch;
+
+  bufferlist newbl;
+  ::encode(creating, newbl);
+
+  auto t = make_shared<MonitorDBStore::Transaction>();
+  t->put("osd_pg_creating", "creating", newbl);
+  st.apply_transaction(t);
+  return 0;
+}
+
 // rebuild
 //  - mgr
 //  - mgr_command_desc
@@ -676,6 +706,9 @@ int rebuild_monstore(const char* progname,
   }
   if (!keyring_path.empty())
     update_auth(st, keyring_path);
+  if ((r = update_creating_pgs(st))) {
+    return r;
+  }
   if ((r = update_mgrmap(st))) {
     return r;
   }