]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: clean up mkfs seed data
authorSage Weil <sage@newdream.net>
Fri, 11 Nov 2011 19:40:02 +0000 (11:40 -0800)
committerSage Weil <sage@newdream.net>
Fri, 11 Nov 2011 19:41:42 +0000 (11:41 -0800)
And make sure the monmap/latest gets written properly.

Signed-off-by: Sage Weil <sage@newdream.net>
src/mon/AuthMonitor.cc
src/mon/Monitor.cc
src/mon/MonmapMonitor.cc
src/mon/OSDMonitor.cc

index 7acc13a16b3c44ca1f631160abf3f4a497932726..41b37d79046cd9cc462af6c4c52b36a684580472 100644 (file)
@@ -117,7 +117,7 @@ bool AuthMonitor::update_from_paxos()
   if (paxosv == keys_ver) return true;
   assert(paxosv >= keys_ver);
 
-  if (keys_ver == 0 && paxosv > 1) {
+  if (keys_ver == 0 && paxosv > 0) {
     // startup: just load latest full map
     bufferlist latest;
     version_t v = paxos->get_latest(latest);
@@ -167,6 +167,10 @@ bool AuthMonitor::update_from_paxos()
 
     keys_ver++;
     mon->key_server.set_ver(keys_ver);
+
+    if (keys_ver == 1) {
+      mon->store->erase_ss("mkfs", "keyring");
+    }
   }
 
   if (last_allocated_id == 0)
index b85529a7814689623029aa742cf410f8d57f802e..31735fb47da113b7bffd44b7a28117a2f9afc486 100644 (file)
@@ -1525,6 +1525,7 @@ int Monitor::mkfs(bufferlist& osdmapbl)
   // save monmap, osdmap, keyring.
   bufferlist monmapbl;
   monmap->encode(monmapbl);
+  monmap->set_epoch(0);     // must be 0 to avoid confusing first MonmapMonitor::update_from_paxos()
   store->put_bl_ss(monmapbl, "mkfs", "monmap");
 
   store->put_bl_ss(osdmapbl, "mkfs", "osdmap");
index 1af65061a849658b9151434eaffca8174419de1b..b180fcbee26e2e9ded8e62b4f32f849ee4845544 100644 (file)
@@ -40,28 +40,42 @@ void MonmapMonitor::create_initial()
   bufferlist bl;
   mon->store->get_bl_ss(bl, "mkfs", "monmap");
   pending_map.decode(bl);
-  dout(10) << "create_initial was fed epoch " << pending_map.epoch << dendl;
+  dout(10) << "create_initial set fed epoch " << pending_map.epoch << dendl;
+  assert(pending_map.epoch == 0);   // fix mkfs()
+  pending_map.epoch = 1;
 }
 
 bool MonmapMonitor::update_from_paxos()
 {
-  //check versions to see if there's an update
   version_t paxosv = paxos->get_version();
-  if (paxosv <= mon->monmap->epoch) return true;
-  //assert(paxosv >= mon->monmap->epoch);
+  if (paxosv <= mon->monmap->epoch)
+    return true;
 
   dout(10) << "update_from_paxos paxosv " << paxosv
           << ", my v " << mon->monmap->epoch << dendl;
 
-  //read and decode
-  monmap_bl.clear();
-  bool success = paxos->read(paxosv, monmap_bl);
-  assert(success);
-  dout(10) << "update_from_paxos got " << paxosv << dendl;
-  mon->monmap->decode(monmap_bl);
+  if (mon->monmap->get_epoch() == 0 && paxosv > 0) {
+    bufferlist latest;
+    version_t v = paxos->get_latest(latest);
+    if (v) {
+      mon->monmap->decode(latest);
+    }
+  }
+
+  while (paxosv > mon->monmap->get_epoch()) {
+    // read and decode
+    monmap_bl.clear();
+    bool success = paxos->read(paxosv, monmap_bl);
+    assert(success);
+    dout(10) << "update_from_paxos got " << paxosv << dendl;
+    mon->monmap->decode(monmap_bl);
+
+    // save the bufferlist version in the paxos instance as well
+    paxos->stash_latest(paxosv, monmap_bl);
 
-  //save the bufferlist version in the paxos instance as well
-  paxos->stash_latest(paxosv, monmap_bl);
+    if (mon->monmap->get_epoch() == 1)
+      mon->store->erase_ss("mkfs", "monmap");
+  }
 
   int rank = mon->monmap->get_rank(mon->name);
   if (rank < 0) {
index 4ffd657bfb8b3e4c474716f365ab93b9f4930133..34942392050461b2283b21985d0b1f5209f7a09c 100644 (file)
@@ -116,6 +116,9 @@ bool OSDMonitor::update_from_paxos()
 
     // share
     dout(1) << osdmap << dendl;
+
+    if (osdmap.epoch == 1)
+      mon->store->erase_ss("mkfs", "osdmap");
   }
 
   // save latest