]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: trim old osdmaps
authorSage Weil <sage@newdream.net>
Tue, 4 Oct 2011 20:34:59 +0000 (13:34 -0700)
committerSage Weil <sage@newdream.net>
Tue, 4 Oct 2011 20:44:54 +0000 (13:44 -0700)
Trakc the oldest clean pg, and trim osdmaps that are older than that.

Signed-off-by: Sage Weil <sage@newdream.net>
src/mon/OSDMonitor.cc
src/mon/PGMap.cc
src/mon/PGMap.h
src/mon/Paxos.h

index 6c47d4508ab4dca9c6c373ebb6c5b2d8996a342d..53b7ae1b9338fda43864f245a3869e21dc794ec9 100644 (file)
@@ -1080,6 +1080,20 @@ void OSDMonitor::tick()
   if (do_propose ||
       !pending_inc.new_pg_temp.empty())  // also propose if we adjusted pg_temp
     propose_pending();
+
+  if (mon->pgmon()->paxos->is_readable() &&
+      mon->pgmon()->pg_map.creating_pgs.empty()) {
+    epoch_t floor = mon->pgmon()->pg_map.calc_min_last_epoch_clean();
+    dout(10) << " min_last_epoch_clean " << floor << dendl;
+    if (floor < paxos->get_version() - 10) {
+      epoch_t of = paxos->get_first_committed();
+      paxos->trim_to(floor);
+      while (of < floor) {
+       mon->store->erase_sn("osdmap_full", of);
+       of++;
+      }
+    }
+  }    
 }
 
 
index 1d2345c0d897d1c7abba8ad3f44197378ab83fdc..0e0e28bbcd9d2905a3544ffe53346644b44415a6 100644 (file)
@@ -154,6 +154,19 @@ void PGMap::stat_osd_sub(const osd_stat_t &s)
   osd_sum.sub(s);
 }
 
+epoch_t PGMap::calc_min_last_epoch_clean() const
+{
+  if (pg_stat.empty())
+    return 0;
+  hash_map<pg_t,pg_stat_t>::const_iterator p = pg_stat.begin();
+  epoch_t min = p->second.last_epoch_clean;
+  for (++p; p != pg_stat.end(); ++p) {
+    if (p->second.last_epoch_clean < min)
+      min = p->second.last_epoch_clean;
+  }
+  return min;
+}
+
 void PGMap::encode(bufferlist &bl)
 {
   __u8 v = 3;
@@ -395,3 +408,4 @@ void PGMap::print_summary(ostream& out) const
   if (ssr.str().length())
     out << "; " << ssr.str();
 }
+
index e075a5a242991da7e9e2efa5e2ab2869771f9514..2a09373faee81ce8f5a2d4373a3bbf1f3eedb6b3 100644 (file)
@@ -147,6 +147,7 @@ public:
   void recovery_summary(ostream& out) const;
   void print_summary(ostream& out) const;
 
+  epoch_t calc_min_last_epoch_clean() const;
 };
 
 inline ostream& operator<<(ostream& out, const PGMap& m) {
index 6f255bd3a4d871d03cd35e7572b45c1d85566b97..68e0de432b521193ec7779b2234b1573d6e5f6e6 100644 (file)
@@ -297,6 +297,8 @@ public:
   void stash_latest(version_t v, bufferlist& bl);
   version_t get_latest(bufferlist& bl);
 
+  version_t get_first_committed() { return first_committed; }
+
   void register_observer(entity_inst_t inst, version_t v);
   void update_observers();
 };