]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: factor out stashing latest monmap
authorSage Weil <sage@inktank.com>
Fri, 12 Jul 2013 00:40:45 +0000 (17:40 -0700)
committerSage Weil <sage@inktank.com>
Fri, 12 Jul 2013 18:28:09 +0000 (11:28 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/Monitor.cc
src/mon/Monitor.h

index fb22f8d0dcef00f3139fbb18621dcc870e047295..888e7c4a13c961a514b0a210cde30c8bba31867c 100644 (file)
@@ -834,20 +834,16 @@ void Monitor::sync_start(entity_inst_t &other, bool full)
   sync_full = full;
 
   if (sync_full) {
-    // mark that we are syncing
+    // stash key state, and mark that we are syncing
     MonitorDBStore::Transaction t;
-
-    bufferlist backup_monmap;
-    sync_obtain_latest_monmap(backup_monmap);
-    assert(backup_monmap.length() > 0);
+    sync_stash_critical_state(&t);
+    t.put("mon_sync", "in_sync", 1);
 
     sync_last_committed_floor = MAX(sync_last_committed_floor, paxos->get_version());
-    dout(10) << __func__ << " marking sync in progress, storing sync_last_commited_floor "
+    dout(10) << __func__ << " marking sync in progress, storing sync_last_committed_floor "
             << sync_last_committed_floor << dendl;
+    t->put("mon_sync", "last_committed_floor", sync_last_committed_floor);
 
-    t.put("mon_sync", "latest_monmap", backup_monmap);
-    t.put("mon_sync", "in_sync", 1);
-    t.put("mon_sync", "last_committed_floor", sync_last_committed_floor);
     store->apply_transaction(t);
 
     assert(g_conf->mon_sync_requester_kill_at != 1);
@@ -872,6 +868,15 @@ void Monitor::sync_start(entity_inst_t &other, bool full)
   messenger->send_message(m, sync_provider);
 }
 
+void Monitor::sync_stash_critical_state(MonitorDBStore::Transaction *t)
+{
+  dout(10) << __func__ << dendl;
+  bufferlist backup_monmap;
+  sync_obtain_latest_monmap(backup_monmap);
+  assert(backup_monmap.length() > 0);
+  t->put("mon_sync", "latest_monmap", backup_monmap);
+}
+
 void Monitor::sync_reset_timeout()
 {
   dout(10) << __func__ << dendl;
index 310a75ecf39e212cdba7ad768ca9d96d45f7c84b..35bff4207add8a3f40a45c4233b511dade32021c 100644 (file)
@@ -333,6 +333,14 @@ public:
   void sync_force(Formatter *f, ostream& ss);
 
 private:
+  /**
+   * store critical state for safekeeping during sync
+   *
+   * We store a few things on the side that we don't want to get clobbered by sync.  This
+   * includes the latest monmap and a lower bound on last_committed.
+   */
+  void sync_stash_critical_state(MonitorDBStore::Transaction *tx);
+
   /**
    * reset the sync timeout
    *