diff options
author | Sage Weil <sage.weil@dreamhost.com> | 2011-10-14 06:26:13 +0200 |
---|---|---|
committer | Sage Weil <sage.weil@dreamhost.com> | 2011-10-15 05:21:18 +0200 |
commit | 502fbba56beedd004854bda2ffc0e4b69e6e1937 (patch) | |
tree | c545ca443b095cbebc0823aae382368407e67c9a | |
parent | PG: call set_last_peering_reset in Started contructor (diff) | |
download | ceph-502fbba56beedd004854bda2ffc0e4b69e6e1937.tar.xz ceph-502fbba56beedd004854bda2ffc0e4b69e6e1937.zip |
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 <sage.weil@dreamhost.com>
-rw-r--r-- | src/mon/OSDMonitor.cc | 14 | ||||
-rw-r--r-- | src/mon/OSDMonitor.h | 3 | ||||
-rw-r--r-- | src/mon/Paxos.cc | 4 | ||||
-rw-r--r-- | src/mon/Paxos.h | 5 |
4 files changed, 16 insertions, 10 deletions
diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 7dc7d1bd433..682d57d8982 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 e33172aca6f..173eceaf438 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 ff1dcb70f71..c7a6a132976 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<string>::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 68e0de432b5..53a3dac90bc 100644 --- a/src/mon/Paxos.h +++ b/src/mon/Paxos.h @@ -77,7 +77,7 @@ class Paxos { friend class PaxosService; friend class PaxosObserver; - + list<std::string> 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) { |