From: Sage Weil Date: Fri, 12 Jul 2013 00:40:45 +0000 (-0700) Subject: mon: factor out stashing latest monmap X-Git-Tag: v0.67-rc1~59^2~20^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=96c48835d19923b467ced3032948af6c2b7959f2;p=ceph.git mon: factor out stashing latest monmap Signed-off-by: Sage Weil --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index fb22f8d0dcef..888e7c4a13c9 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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; diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 310a75ecf39e..35bff4207add 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -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 *