]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
paxos: trim extra state dirs
authorSage Weil <sage.weil@dreamhost.com>
Fri, 14 Oct 2011 04:26:13 +0000 (21:26 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Sat, 15 Oct 2011 03:21:18 +0000 (20:21 -0700)
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>
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h
src/mon/Paxos.cc
src/mon/Paxos.h

index 7dc7d1bd433bdac85982389052ddac25e5c73ad9..682d57d8982a5e4e72d9db0ea83cab738d8dae90 100644 (file)
@@ -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++;
-      }
-    }
   }    
 }
 
index e33172aca6fc0928d2f56b5769fcc00e0b206898..173eceaf4389a42f790075d70d630ab847f80082 100644 (file)
@@ -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
 
index ff1dcb70f71d82f66a5d3af5c575a2b29b806336..c7a6a1329760202b3c59e0c935261b63489b2228 100644 (file)
@@ -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");
index 68e0de432b521193ec7779b2234b1573d6e5f6e6..53a3dac90bcd820544f34df4cc6dcedf7bd00463 100644 (file)
@@ -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) {