]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: always load stashed version when version doesn't match
authorSage Weil <sage@newdream.net>
Wed, 16 Nov 2011 18:54:59 +0000 (10:54 -0800)
committerSage Weil <sage@newdream.net>
Wed, 16 Nov 2011 18:54:59 +0000 (10:54 -0800)
The slurp process can happen after the monitor has started and has some
in-memory version of the state, and that process may wipe out old
incrementals and change the stashed version.  That means that in
update_from_paxos, we need to pull the stashed version if it doesn't
match what we currently have or else we may not have the incrementals we
need to get up to date.

This simplifies and cleans up that code a bit so it is not specific to
monitor startup.

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

index 001a2c4ac2e25a76f532611c4c011c9e9750296d..6f572565322f782b4fcee8b5c79bb46577b00534 100644 (file)
@@ -111,25 +111,22 @@ void AuthMonitor::create_initial()
 
 bool AuthMonitor::update_from_paxos()
 {
-  dout(10) << "AuthMonitor::update_from_paxos()" << dendl;
+  dout(10) << "update_from_paxos()" << dendl;
   version_t paxosv = paxos->get_version();
   version_t keys_ver = mon->key_server.get_ver();
   if (paxosv == keys_ver)
     return true;
   assert(paxosv >= keys_ver);
 
-  if (keys_ver == 0 && paxosv > 0) {
-    // startup: just load latest full map
+  if (keys_ver != paxos->get_latest_version()) {
     bufferlist latest;
     version_t v = paxos->get_latest(latest);
-    if (v) {
-      dout(7) << "update_from_paxos startup: loading summary e" << v << dendl;
-      bufferlist::iterator p = latest.begin();
-      __u8 v;
-      ::decode(v, p);
-      ::decode(max_global_id, p);
-      ::decode(mon->key_server, p);
-    }
+    dout(7) << "update_from_paxos loading summary e" << v << dendl;
+    bufferlist::iterator p = latest.begin();
+    __u8 struct_v;
+    ::decode(struct_v, p);
+    ::decode(max_global_id, p);
+    ::decode(mon->key_server, p);
   } 
 
   // walk through incrementals
index 5983e497d8c4c7f9031037d6639349ef1d5965af..17608e9609244bc11ea4b769e2dbc06923df0df3 100644 (file)
@@ -104,15 +104,12 @@ bool LogMonitor::update_from_paxos()
   bufferlist blogerr;
   bufferlist blogsec;
 
-  if (summary.version == 0 && paxosv > 0) {
-    // startup: just load latest full map
+  if (summary.version != paxos->get_latest_version()) {
     bufferlist latest;
     version_t v = paxos->get_latest(latest);
-    if (v) {
-      dout(7) << "update_from_paxos startup: loading summary e" << v << dendl;
-      bufferlist::iterator p = latest.begin();
-      ::decode(summary, p);
-    }
+    dout(7) << "update_from_paxos loading summary e" << v << dendl;
+    bufferlist::iterator p = latest.begin();
+    ::decode(summary, p);
   } 
 
   // walk through incrementals
index 226c7575c237bb9c39e76bfa485f55f6482006aa..843d93973bf4cdbde0a682f2d9ee2a2e2105d8e7 100644 (file)
@@ -95,14 +95,11 @@ bool OSDMonitor::update_from_paxos()
   dout(15) << "update_from_paxos paxos e " << paxosv 
           << ", my e " << osdmap.epoch << dendl;
 
-  if (osdmap.epoch == 0 && paxosv > 0) {
-    // startup: just load latest full map
+  if (osdmap.epoch != paxos->get_latest_version()) {
     bufferlist latest;
     version_t v = paxos->get_latest(latest);
-    if (v) {
-      dout(7) << "update_from_paxos startup: loading latest full map e" << v << dendl;
-      osdmap.decode(latest);
-    }
+    dout(7) << "update_from_paxos loading latest full map e" << v << dendl;
+    osdmap.decode(latest);
   } 
   
   // walk through incrementals
index 5d4fbaf04406591cee10cfca6b563f9c24d07ba8..fcf9c64e80af6abb3236a45694567d9d88242beb 100644 (file)
@@ -118,23 +118,20 @@ bool PGMonitor::update_from_paxos()
     return true;
   assert(paxosv >= pg_map.version);
 
-  if (pg_map.version == 0 && paxosv > 0) {
-    // starting up: load latest
+  if (pg_map.version != paxos->get_latest_version()) {
     bufferlist latest;
     version_t v = paxos->get_latest(latest);
-    if (v) {
-      dout(7) << "update_from_paxos startup: got latest latest full pgmap v" << v << dendl;
-      try {
-       PGMap tmp_pg_map;
-       bufferlist::iterator p = latest.begin();
-       tmp_pg_map.decode(p);
-       pg_map = tmp_pg_map;
-      }
-      catch (const std::exception &e) {
-       dout(0) << "update_from_paxos: error parsing update: "
-               << e.what() << dendl;
-       return false;
-      }
+    dout(7) << "update_from_paxos loading latest full pgmap v" << v << dendl;
+    try {
+      PGMap tmp_pg_map;
+      bufferlist::iterator p = latest.begin();
+      tmp_pg_map.decode(p);
+      pg_map = tmp_pg_map;
+    }
+    catch (const std::exception &e) {
+      dout(0) << "update_from_paxos: error parsing update: "
+             << e.what() << dendl;
+      return false;
     }
   }