]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: add epoch_pool_created to pg_history_t
authorSage Weil <sage@redhat.com>
Mon, 8 May 2017 02:46:06 +0000 (22:46 -0400)
committerSage Weil <sage@redhat.com>
Mon, 8 May 2017 02:46:06 +0000 (22:46 -0400)
The epoch_created property is the *pg* creation epoch; we want to know the
pool creation epoch too.  Unfortunately that is not part of the pg_pool_t.
Add a pg_history_t member that sits alongside epoch_created.

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc
src/osd/osd_types.cc
src/osd/osd_types.h

index d61ad10497555f4b5e173cbc5d414607e4e52d7b..c2cbd87cad3f5b6d0bcd293caabb82baede8c175 100644 (file)
@@ -4163,6 +4163,7 @@ void OSD::build_initial_pg_history(
 {
   dout(10) << __func__ << " " << pgid << " created " << created << dendl;
   h->epoch_created = created;
+  h->epoch_pool_created = created;
   h->same_interval_since = created;
   h->same_up_since = created;
   h->same_primary_since = created;
@@ -4305,7 +4306,7 @@ bool OSD::project_pg_history(spg_t pgid, pg_history_t& h, epoch_t from,
       break;
   }
 
-  // base case: these floors should be the creation epoch if we didn't
+  // base case: these floors should be the pg creation epoch if we didn't
   // find any changes.
   if (e == h.epoch_created) {
     if (!h.same_interval_since)
index b17670cb4515e686599019ed25b5b3de86226844..e46ed926bee4235b21dac78bbe94e4add071c66e 100644 (file)
@@ -2539,7 +2539,7 @@ void pool_stat_t::generate_test_instances(list<pool_stat_t*>& o)
 
 void pg_history_t::encode(bufferlist &bl) const
 {
-  ENCODE_START(8, 4, bl);
+  ENCODE_START(9, 4, bl);
   ::encode(epoch_created, bl);
   ::encode(last_epoch_started, bl);
   ::encode(last_epoch_clean, bl);
@@ -2555,12 +2555,13 @@ void pg_history_t::encode(bufferlist &bl) const
   ::encode(last_epoch_marked_full, bl);
   ::encode(last_interval_started, bl);
   ::encode(last_interval_clean, bl);
+  ::encode(epoch_pool_created, bl);
   ENCODE_FINISH(bl);
 }
 
 void pg_history_t::decode(bufferlist::iterator &bl)
 {
-  DECODE_START_LEGACY_COMPAT_LEN(8, 4, 4, bl);
+  DECODE_START_LEGACY_COMPAT_LEN(9, 4, 4, bl);
   ::decode(epoch_created, bl);
   ::decode(last_epoch_started, bl);
   if (struct_v >= 3)
@@ -2600,12 +2601,18 @@ void pg_history_t::decode(bufferlist::iterator &bl)
       last_interval_clean = last_epoch_clean; // best guess
     }
   }
+  if (struct_v >= 9) {
+    ::decode(epoch_pool_created, bl);
+  } else {
+    epoch_pool_created = epoch_created;
+  }
   DECODE_FINISH(bl);
 }
 
 void pg_history_t::dump(Formatter *f) const
 {
   f->dump_int("epoch_created", epoch_created);
+  f->dump_int("epoch_pool_created", epoch_pool_created);
   f->dump_int("last_epoch_started", last_epoch_started);
   f->dump_int("last_interval_started", last_interval_started);
   f->dump_int("last_epoch_clean", last_epoch_clean);
@@ -2627,6 +2634,7 @@ void pg_history_t::generate_test_instances(list<pg_history_t*>& o)
   o.push_back(new pg_history_t);
   o.push_back(new pg_history_t);
   o.back()->epoch_created = 1;
+  o.back()->epoch_pool_created = 1;
   o.back()->last_epoch_started = 2;
   o.back()->last_interval_started = 2;
   o.back()->last_epoch_clean = 3;
index dcbce601dd02f17ad999d7074045725635ec356d..4bbfb5426741999ed0b313f9078e20530c28052e 100644 (file)
@@ -2091,12 +2091,15 @@ WRITE_CLASS_ENCODER(pg_hit_set_history_t)
  * history they need to worry about.
  */
 struct pg_history_t {
-  epoch_t epoch_created;       // epoch in which PG was created
+  epoch_t epoch_created;       // epoch in which *pg* was created (pool or pg)
+  epoch_t epoch_pool_created;  // epoch in which *pool* was created
+                              // (note: may be pg creation epoch for
+                              // pre-luminous clusters)
   epoch_t last_epoch_started;  // lower bound on last epoch started (anywhere, not necessarily locally)
   epoch_t last_interval_started; // first epoch of last_epoch_started interval
   epoch_t last_epoch_clean;    // lower bound on last epoch the PG was completely clean.
   epoch_t last_interval_clean; // first epoch of last_epoch_clean interval
-  epoch_t last_epoch_split;    // as parent
+  epoch_t last_epoch_split;    // as parent or child
   epoch_t last_epoch_marked_full;  // pool or cluster
   
   /**
@@ -2119,6 +2122,7 @@ struct pg_history_t {
   friend bool operator==(const pg_history_t& l, const pg_history_t& r) {
     return
       l.epoch_created == r.epoch_created &&
+      l.epoch_pool_created == r.epoch_pool_created &&
       l.last_epoch_started == r.last_epoch_started &&
       l.last_interval_started == r.last_interval_started &&
       l.last_epoch_clean == r.last_epoch_clean &&
@@ -2137,6 +2141,7 @@ struct pg_history_t {
 
   pg_history_t()
     : epoch_created(0),
+      epoch_pool_created(0),
       last_epoch_started(0),
       last_interval_started(0),
       last_epoch_clean(0),
@@ -2152,6 +2157,12 @@ struct pg_history_t {
       epoch_created = other.epoch_created;
       modified = true;
     }
+    if (epoch_pool_created < other.epoch_pool_created) {
+      // FIXME: for jewel compat only; this should either be 0 or always the
+      // same value across all pg instances.
+      epoch_pool_created = other.epoch_pool_created;
+      modified = true;
+    }
     if (last_epoch_started < other.last_epoch_started) {
       last_epoch_started = other.last_epoch_started;
       modified = true;
@@ -2207,7 +2218,7 @@ struct pg_history_t {
 WRITE_CLASS_ENCODER(pg_history_t)
 
 inline ostream& operator<<(ostream& out, const pg_history_t& h) {
-  return out << "ec=" << h.epoch_created
+  return out << "ec=" << h.epoch_created << "/" << h.epoch_pool_created
             << " lis/c " << h.last_interval_started
             << "/" << h.last_interval_clean
             << " les/c/f " << h.last_epoch_started << "/" << h.last_epoch_clean