]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/ceph_monstore_tool: update pgmap_meta also when rebuilding store.db
authorKefu Chai <kchai@redhat.com>
Fri, 30 Sep 2016 09:58:14 +0000 (17:58 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 22 Nov 2016 03:47:00 +0000 (11:47 +0800)
we should rebuild pgmap_meta table from the collected osdmaps

Fixes: http://tracker.ceph.com/issues/17400
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit cdfa7a69f63d047205dcfccd63b5d58ab0d4695b)
Conflicts:
src/tools/ceph_monstore_tool.cc: remove C++11-ism

src/tools/ceph_monstore_tool.cc
src/tools/rebuild_mondb.cc

index 32db81a71f8766a9b20a348eda41c1812ac0311d..5699ec4c919772fa810ddb0240edeb815f314850 100644 (file)
@@ -594,7 +594,8 @@ static int update_paxos(MonitorDBStore& st)
   bufferlist pending_proposal;
   {
     MonitorDBStore::Transaction t;
-    const char* prefixes[] = {"auth", "osdmap", "pgmap", "pgmap_pg"};
+    const char* prefixes[] = {"auth", "osdmap",
+           "pgmap", "pgmap_pg", "pgmap_meta"};
     for (const char** prefix = &prefixes[0]; prefix != prefixes + sizeof(prefixes); prefix++) {
       for (KeyValueDB::Iterator i = st.get_iterator(*prefix); i->valid(); i->next()) {
        bufferlist value = i->value();
@@ -615,6 +616,52 @@ static int update_paxos(MonitorDBStore& st)
   return 0;
 }
 
+// rebuild
+//  - pgmap_meta/version
+//  - pgmap_meta/last_osdmap_epoch
+//  - pgmap_meta/last_pg_scan
+//  - pgmap_meta/full_ratio
+//  - pgmap_meta/nearfull_ratio
+//  - pgmap_meta/stamp
+static int update_pgmap_meta(MonitorDBStore& st)
+{
+  const string prefix("pgmap_meta");
+  MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction);
+  // stolen from PGMonitor::create_pending()
+  // the first pgmap_meta
+  t->put(prefix, "version", 1);
+  {
+    utime_t stamp = ceph_clock_now(g_ceph_context);
+    bufferlist bl;
+    ::encode(stamp, bl);
+    t->put(prefix, "stamp", bl);
+  }
+  {
+    version_t last_osdmap_epoch = st.get("osdmap", "last_committed");
+    t->put(prefix, "last_osdmap_epoch", last_osdmap_epoch);
+  }
+  // be conservative, so PGMonitor will scan the all pools for pg changes
+  t->put(prefix, "last_pg_scan", 1);
+  {
+    float full_ratio = g_ceph_context->_conf->mon_osd_full_ratio;
+    if (full_ratio > 1.0)
+      full_ratio /= 100.0;
+    bufferlist bl;
+    ::encode(full_ratio, bl);
+    t->put(prefix, "full_ratio", bl);
+  }
+  {
+    float nearfull_ratio = g_ceph_context->_conf->mon_osd_nearfull_ratio;
+    if (nearfull_ratio > 1.0)
+      nearfull_ratio /= 100.0;
+    bufferlist bl;
+    ::encode(nearfull_ratio, bl);
+    t->put(prefix, "nearfull_ratio", bl);
+  }
+  st.apply_transaction(t);
+  return 0;
+}
+
 int rebuild_monstore(const char* progname,
                     vector<string>& subcmds,
                     MonitorDBStore& st)
@@ -635,6 +682,9 @@ int rebuild_monstore(const char* progname,
   }
   if (!keyring_path.empty())
     update_auth(st, keyring_path);
+  if ((r = update_pgmap_meta(st))) {
+    return r;
+  }
   if ((r = update_paxos(st))) {
     return r;
   }
index 859ceac1d7b7e750e3ceb5aa01a9567830c6cabd..364dc69d6fd05e1c202467682451b2d9aa5611ac 100644 (file)
@@ -331,52 +331,6 @@ int update_osdmap(ObjectStore& fs, OSDSuperblock& sb, MonitorDBStore& ms)
   return 0;
 }
 
-// rebuild
-//  - pgmap_meta/version
-//  - pgmap_meta/last_osdmap_epoch
-//  - pgmap_meta/last_pg_scan
-//  - pgmap_meta/full_ratio
-//  - pgmap_meta/nearfull_ratio
-//  - pgmap_meta/stamp
-int update_pgmap_meta(MonitorDBStore& st)
-{
-  const string prefix("pgmap_meta");
-  MonitorDBStore::TransactionRef t(new MonitorDBStore::Transaction);
-  // stolen from PGMonitor::create_pending()
-  // the first pgmap_meta
-  t->put(prefix, "version", 1);
-  {
-    utime_t stamp = ceph_clock_now(g_ceph_context);
-    bufferlist bl;
-    ::encode(stamp, bl);
-    t->put(prefix, "stamp", bl);
-  }
-  {
-    version_t last_osdmap_epoch = st.get("osdmap", "last_committed");
-    t->put(prefix, "last_osdmap_epoch", last_osdmap_epoch);
-  }
-  // be conservative, so PGMonitor will scan the all pools for pg changes
-  t->put(prefix, "last_pg_scan", 1);
-  {
-    float full_ratio = g_ceph_context->_conf->mon_osd_full_ratio;
-    if (full_ratio > 1.0)
-      full_ratio /= 100.0;
-    bufferlist bl;
-    ::encode(full_ratio, bl);
-    t->put(prefix, "full_ratio", bl);
-  }
-  {
-    float nearfull_ratio = g_ceph_context->_conf->mon_osd_nearfull_ratio;
-    if (nearfull_ratio > 1.0)
-      nearfull_ratio /= 100.0;
-    bufferlist bl;
-    ::encode(nearfull_ratio, bl);
-    t->put(prefix, "nearfull_ratio", bl);
-  }
-  st.apply_transaction(t);
-  return 0;
-}
-
 // rebuild
 //  - pgmap_pg/${pgid}
 int update_pgmap_pg(ObjectStore& fs, MonitorDBStore& ms)