From: Sage Weil Date: Fri, 14 Oct 2011 04:26:13 +0000 (-0700) Subject: paxos: trim extra state dirs X-Git-Tag: v0.37~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=502fbba56beedd004854bda2ffc0e4b69e6e1937;p=ceph.git paxos: trim extra state dirs OSDMonitor, for instance, stores both an "osdmap" and "osdmap_full" for each state. Trim them both. Signed-off-by: Sage Weil --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 7dc7d1bd433b..682d57d8982a 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -53,6 +53,12 @@ static ostream& _prefix(std::ostream *_dout, Monitor *mon, OSDMap& osdmap) { /************ MAPS ****************/ +OSDMonitor::OSDMonitor(Monitor *mn, Paxos *p) + : PaxosService(mn, p) +{ + // we need to trim this too + p->add_extra_state_dir("osdmap_full"); +} void OSDMonitor::create_initial(bufferlist& bl) @@ -1126,14 +1132,8 @@ void OSDMonitor::tick() epoch_t floor = mon->pgmon()->pg_map.calc_min_last_epoch_clean(); dout(10) << " min_last_epoch_clean " << floor << dendl; unsigned min = 100; - if (floor + min < paxos->get_version()) { - epoch_t of = paxos->get_first_committed(); + if (floor + min < paxos->get_version()) paxos->trim_to(floor); - while (of < floor) { - mon->store->erase_sn("osdmap_full", of); - of++; - } - } } } diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index e33172aca6fc..173eceaf4389 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -155,8 +155,7 @@ private: bool prepare_remove_snaps(class MRemoveSnaps *m); public: - OSDMonitor(Monitor *mn, Paxos *p) : - PaxosService(mn, p) { } + OSDMonitor(Monitor *mn, Paxos *p); void tick(); // check state, take actions diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index ff1dcb70f71d..c7a6a1329760 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -728,6 +728,10 @@ void Paxos::trim_to(version_t first) first_committed < last_consumed) { dout(10) << "trim " << first_committed << dendl; mon->store->erase_sn(machine_name, first_committed); + for (list::iterator p = extra_state_dirs.begin(); + p != extra_state_dirs.end(); + ++p) + mon->store->erase_sn(p->c_str(), first_committed); first_committed++; } mon->store->put_int(first_committed, machine_name, "first_committed"); diff --git a/src/mon/Paxos.h b/src/mon/Paxos.h index 68e0de432b52..53a3dac90bcd 100644 --- a/src/mon/Paxos.h +++ b/src/mon/Paxos.h @@ -77,7 +77,7 @@ class Paxos { friend class PaxosService; friend class PaxosObserver; - + list extra_state_dirs; // LEADER+PEON @@ -258,6 +258,9 @@ public: void share_state(MMonPaxos *m, version_t first_committed, version_t last_committed); void store_state(MMonPaxos *m); + void add_extra_state_dir(string s) { + extra_state_dirs.push_back(s); + } // -- service interface -- void wait_for_active(Context *c) {