From 36f58131e7470e173c8df0c07f7dec645892e5e9 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 9 Dec 2008 14:55:00 -0800 Subject: [PATCH] mon: use 'latest' for latest osd, mds maps Mainly for benefit of PaxosObserver, but it also cleans things up a bit. --- src/mon/MDSMonitor.cc | 3 +++ src/mon/OSDMonitor.cc | 19 ++++++++++--------- src/mon/mon_types.h | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 4a75dc1fef4e9..99e69203d7b79 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -84,6 +84,9 @@ bool MDSMonitor::update_from_paxos() dout(10) << "update_from_paxos got " << paxosv << dendl; mdsmap.decode(mdsmap_bl); + // save as 'latest', too. + paxos->stash_latest(paxosv, mdsmap_bl); + // new map dout(4) << "new map" << dendl; print_map(mdsmap, 0); diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 25b03bf9c6546..9a4f37e0cfd5a 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -138,18 +138,17 @@ bool OSDMonitor::update_from_paxos() if (osdmap.epoch == 0 && paxosv > 1) { // startup: just load latest full map - epoch_t lastfull = mon->store->get_int("osdmap_full","last_epoch"); - if (lastfull) { - dout(7) << "update_from_paxos startup: loading latest full map e" << lastfull << dendl; - bufferlist bl; - mon->store->get_bl_sn(bl, "osdmap_full", lastfull); - osdmap.decode(bl); + 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); } } // walk through incrementals + bufferlist bl; while (paxosv > osdmap.epoch) { - bufferlist bl; bool success = paxos->read(osdmap.epoch+1, bl); assert(success); @@ -157,7 +156,7 @@ bool OSDMonitor::update_from_paxos() OSDMap::Incremental inc(bl); osdmap.apply_incremental(inc); - // write out the full map, too. + // write out the full map for all past epochs bl.clear(); osdmap.encode(bl); mon->store->put_bl_sn(bl, "osdmap_full", osdmap.epoch); @@ -165,7 +164,9 @@ bool OSDMonitor::update_from_paxos() // share dout(1) << osdmap << dendl; } - mon->store->put_int(osdmap.epoch, "osdmap_full","last_epoch"); + + // save latest + paxos->stash_latest(paxosv, bl); if (mon->is_leader()) { // kick pgmon, make sure it's seen the latest map diff --git a/src/mon/mon_types.h b/src/mon/mon_types.h index 34315d261426f..f404fa1b09849 100644 --- a/src/mon/mon_types.h +++ b/src/mon/mon_types.h @@ -33,6 +33,6 @@ inline const char *get_paxos_name(int p) { } } -#define CEPH_MON_ONDISK_MAGIC "ceph mon volume v006" +#define CEPH_MON_ONDISK_MAGIC "ceph mon volume v007" #endif -- 2.39.5