]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: be smarter about calculating last_epoch_clean lower bound
authorSage Weil <sage@inktank.com>
Mon, 8 Jul 2013 22:57:48 +0000 (15:57 -0700)
committerSage Weil <sage@inktank.com>
Tue, 9 Jul 2013 20:42:34 +0000 (13:42 -0700)
We need to take PGs whose mapping has not changed in a long time into
account.  For them, the pg state will indicate it was clean at the time of
the report, in which case we can use that as a lower-bound on their actual
latest epoch clean.  If they are not currently clean (at report time), use
the last_epoch_clean value.

Fixes: #5519
Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/PGMap.cc
src/osd/osd_types.h

index 8be36c857bd7ffd1a6d9b729dce0d2128d868629..c405b403f3951c8fa3e1a1cdb989e7af9d2d6892 100644 (file)
@@ -409,10 +409,11 @@ 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;
+  epoch_t min = p->second.get_effective_last_epoch_clean();
   for (++p; p != pg_stat.end(); ++p) {
-    if (p->second.last_epoch_clean < min)
-      min = p->second.last_epoch_clean;
+    epoch_t lec = p->second.get_effective_last_epoch_clean();
+    if (lec < min)
+      min = lec;
   }
   return min;
 }
index a039a3dd5801ee58826d74bcc6d28ee9e9aec138..8e30bb14e1dde983a3f915d613c8fb6acca881d7 100644 (file)
@@ -947,6 +947,16 @@ struct pg_stat_t {
       mapping_epoch(0)
   { }
 
+  epoch_t get_effective_last_epoch_clean() const {
+    if (state & PG_STATE_CLEAN) {
+      // we are clean as of this report, and should thus take the
+      // reported epoch
+      return reported.epoch;
+    } else {
+      return last_epoch_clean;
+    }
+  }
+
   void add(const pg_stat_t& o) {
     stats.add(o.stats);
     log_size += o.log_size;