]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: PG::Info::History -> pg_history_t
authorSage Weil <sage.weil@dreamhost.com>
Wed, 1 Feb 2012 20:43:17 +0000 (12:43 -0800)
committerSage Weil <sage.weil@dreamhost.com>
Wed, 1 Feb 2012 20:43:17 +0000 (12:43 -0800)
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/osd/OSD.cc
src/osd/OSD.h
src/osd/PG.cc
src/osd/PG.h
src/osd/osd_types.cc
src/osd/osd_types.h

index 64b6e59f248bf269bdbd6ea2fbec02772d660c0f..d40ddb2dfda4841385aba3ee9a88a08e214327ce 100644 (file)
@@ -1085,7 +1085,7 @@ PG *OSD::_create_lock_pg(pg_t pgid, ObjectStore::Transaction& t)
 }
 
 PG *OSD::_create_lock_new_pg(pg_t pgid, vector<int>& acting, ObjectStore::Transaction& t,
-                             PG::Info::History history)
+                             pg_history_t history)
 {
   assert(osd_lock.is_locked());
   dout(20) << "_create_lock_new_pg pgid " << pgid << " -> " << acting << dendl;
@@ -1219,7 +1219,7 @@ PG *OSD::get_or_create_pg(const PG::Info& info, epoch_t epoch, int from, int& cr
     osdmap->pg_to_up_acting_osds(info.pgid, up, acting);
     int role = osdmap->calc_pg_role(whoami, acting, acting.size());
 
-    PG::Info::History history = info.history;
+    pg_history_t history = info.history;
     project_pg_history(info.pgid, history, epoch, up, acting);
 
     if (epoch < history.same_interval_since) {
@@ -1330,7 +1330,7 @@ void OSD::calc_priors_during(pg_t pgid, epoch_t start, epoch_t end, set<int>& ps
  * Fill in the passed history so you know same_interval_since, same_up_since,
  * and same_primary_since.
  */
-void OSD::project_pg_history(pg_t pgid, PG::Info::History& h, epoch_t from,
+void OSD::project_pg_history(pg_t pgid, pg_history_t& h, epoch_t from,
                             vector<int>& currentup, vector<int>& currentacting)
 {
   dout(15) << "project_pg_history " << pgid
@@ -4000,7 +4000,7 @@ void OSD::kick_pg_split_queue()
     for (set<pg_t>::iterator q = p->second.begin();
         q != p->second.end();
         q++) {
-      PG::Info::History history;
+      pg_history_t history;
       history.epoch_created = history.same_up_since =
           history.same_interval_since = history.same_primary_since =
           osdmap->get_epoch();
@@ -4212,7 +4212,7 @@ void OSD::handle_pg_create(MOSDPGCreate *m)
     }
 
     // figure history
-    PG::Info::History history;
+    pg_history_t history;
     history.epoch_created = created;
     history.last_epoch_clean = created;
     project_pg_history(pgid, history, created, up, acting);
@@ -4656,7 +4656,7 @@ void OSD::handle_pg_query(MOSDPGQuery *m)
       int role = osdmap->calc_pg_role(whoami, acting, acting.size());
 
       // same primary?
-      PG::Info::History history = it->second.history;
+      pg_history_t history = it->second.history;
       project_pg_history(pgid, history, m->get_epoch(), up, acting);
 
       if (m->get_epoch() < history.same_interval_since) {
index 55521e40cfe87ff9473a3fa3366de61dea50ec89..1fad6389ce8971a9846ab66fa1a1bb96924cdc51 100644 (file)
@@ -431,7 +431,7 @@ protected:
   PG   *_open_lock_pg(pg_t pg, bool no_lockdep_check=false);  // create new PG (in memory)
   PG   *_create_lock_pg(pg_t pg, ObjectStore::Transaction& t); // create new PG
   PG   *_create_lock_new_pg(pg_t pgid, vector<int>& acting, ObjectStore::Transaction& t,
-                            PG::Info::History history);
+                            pg_history_t history);
   //void  _remove_unlock_pg(PG *pg);         // remove from store and memory
 
   PG *lookup_lock_raw_pg(pg_t pgid);
@@ -442,7 +442,7 @@ protected:
   
   void load_pgs();
   void calc_priors_during(pg_t pgid, epoch_t start, epoch_t end, set<int>& pset);
-  void project_pg_history(pg_t pgid, PG::Info::History& h, epoch_t from,
+  void project_pg_history(pg_t pgid, pg_history_t& h, epoch_t from,
                          vector<int>& lastup, vector<int>& lastacting);
 
   void wake_pg_waiters(pg_t pgid) {
@@ -462,7 +462,7 @@ protected:
 
   // -- pg creation --
   struct create_pg_info {
-    PG::Info::History history;
+    pg_history_t history;
     vector<int> acting;
     set<int> prior;
     pg_t parent;
index f0b49fca0ca59f5338a1ee361d3e2f29f2b398b5..221681a5cf6d4103a24a401976340af4ac881e49 100644 (file)
@@ -96,8 +96,8 @@ void PG::Info::generate_test_instances(list<PG::Info*>& o)
 {
   o.push_back(new Info);
   o.push_back(new Info);
-  list<History*> h;
-  History::generate_test_instances(h);
+  list<pg_history_t*> h;
+  pg_history_t::generate_test_instances(h);
   o.back()->history = *h.back();
   o.back()->pgid = pg_t(1, 2, -1);
   o.back()->last_update = eversion_t(3, 4);
@@ -109,35 +109,6 @@ void PG::Info::generate_test_instances(list<PG::Info*>& o)
   o.back()->stats = *s.back();
 }
 
-/******* PG::Info::History *******/
-
-void PG::Info::History::dump(Formatter *f) const
-{
-  f->dump_int("epoch_created", epoch_created);
-  f->dump_int("last_epoch_started", last_epoch_started);
-  f->dump_int("last_epoch_clean", last_epoch_clean);
-  f->dump_int("last_epoch_split", last_epoch_split);
-  f->dump_int("same_up_since", same_up_since);
-  f->dump_int("same_interval_since", same_interval_since);
-  f->dump_int("same_primary_since", same_primary_since);
-  f->dump_stream("last_scrub") << last_scrub;
-  f->dump_stream("last_scrub_stamp") << last_scrub_stamp;
-}
-
-void PG::Info::History::generate_test_instances(list<PG::Info::History*>& o)
-{
-  o.push_back(new History);
-  o.push_back(new History);
-  o.back()->epoch_created = 1;
-  o.back()->last_epoch_started = 2;
-  o.back()->last_epoch_clean = 3;
-  o.back()->last_epoch_split = 4;
-  o.back()->same_up_since = 5;
-  o.back()->same_interval_since = 6;
-  o.back()->same_primary_since = 7;
-  o.back()->last_scrub = eversion_t(8, 9);
-  o.back()->last_scrub_stamp = utime_t(10, 11);  
-}
 
 /******* PG::Log ********/
 
index 20c89607d667e696b5acecaa7d5614e98cb4d31b..12db39687dd42e7a351c55a54a4815f83a33db76 100644 (file)
@@ -181,75 +181,8 @@ public:
 
     pg_stat_t stats;
 
-    struct History {
-      epoch_t epoch_created;       // epoch in which PG was created
-      epoch_t last_epoch_started;  // lower bound on last epoch started (anywhere, not necessarily locally)
-      epoch_t last_epoch_clean;    // lower bound on last epoch the PG was completely clean.
-      epoch_t last_epoch_split;    // as parent
-
-      epoch_t same_up_since;       // same acting set since
-      epoch_t same_interval_since;   // same acting AND up set since
-      epoch_t same_primary_since;  // same primary at least back through this epoch.
-
-      eversion_t last_scrub;
-      utime_t last_scrub_stamp;
-
-      History() :            
-       epoch_created(0),
-       last_epoch_started(0), last_epoch_clean(0), last_epoch_split(0),
-       same_up_since(0), same_interval_since(0), same_primary_since(0) {}
-
-      void merge(const History &other) {
-       // Here, we only update the fields which cannot be calculated from the OSDmap.
-       if (epoch_created < other.epoch_created)
-         epoch_created = other.epoch_created;
-       if (last_epoch_started < other.last_epoch_started)
-         last_epoch_started = other.last_epoch_started;
-       if (last_epoch_clean < other.last_epoch_clean)
-         last_epoch_clean = other.last_epoch_clean;
-       if (last_epoch_split < other.last_epoch_started)
-         last_epoch_split = other.last_epoch_started;
-       if (other.last_scrub > last_scrub)
-         last_scrub = other.last_scrub;
-       if (other.last_scrub_stamp > last_scrub_stamp)
-         last_scrub_stamp = other.last_scrub_stamp;
-      }
+    pg_history_t history;
 
-      void encode(bufferlist &bl) const {
-       __u8 struct_v = 3;
-       ::encode(struct_v, bl);
-       ::encode(epoch_created, bl);
-       ::encode(last_epoch_started, bl);
-       ::encode(last_epoch_clean, bl);
-       ::encode(last_epoch_split, bl);
-       ::encode(same_interval_since, bl);
-       ::encode(same_up_since, bl);
-       ::encode(same_primary_since, bl);
-       ::encode(last_scrub, bl);
-       ::encode(last_scrub_stamp, bl);
-      }
-      void decode(bufferlist::iterator &bl) {
-       __u8 struct_v;
-       ::decode(struct_v, bl);
-       ::decode(epoch_created, bl);
-       ::decode(last_epoch_started, bl);
-       if (struct_v >= 3)
-         ::decode(last_epoch_clean, bl);
-       else
-         last_epoch_clean = last_epoch_started;  // careful, it's a lie!
-       ::decode(last_epoch_split, bl);
-       ::decode(same_interval_since, bl);
-       ::decode(same_up_since, bl);
-       ::decode(same_primary_since, bl);
-       if (struct_v >= 2) {
-         ::decode(last_scrub, bl);
-         ::decode(last_scrub_stamp, bl);
-       }
-      }
-      void dump(Formatter *f) const;
-      static void generate_test_instances(list<History*>& o);
-    } history;
-    
     Info()
       : last_backfill(hobject_t::get_max())
     { }
@@ -308,7 +241,6 @@ public:
     void dump(Formatter *f) const;
     static void generate_test_instances(list<Info*>& o);
   };
-  //WRITE_CLASS_ENCODER(Info::History)
   WRITE_CLASS_ENCODER(Info)
 
   
@@ -336,12 +268,12 @@ public:
 
     __s32 type;
     eversion_t since;
-    Info::History history;
+    pg_history_t history;
 
     Query() : type(-1) {}
-    Query(int t, const Info::History& h) :
+    Query(int t, const pg_history_t& h) :
       type(t), history(h) { assert(t != LOG); }
-    Query(int t, eversion_t s, const Info::History& h) :
+    Query(int t, eversion_t s, const pg_history_t& h) :
       type(t), since(s), history(h) { assert(t == LOG); }
 
     void encode(bufferlist &bl) const {
@@ -1861,7 +1793,6 @@ public:
                                    utime_t expire) = 0;
 };
 
-WRITE_CLASS_ENCODER(PG::Info::History)
 WRITE_CLASS_ENCODER(PG::Info)
 WRITE_CLASS_ENCODER(PG::Query)
 WRITE_CLASS_ENCODER(PG::Missing::item)
@@ -1871,13 +1802,6 @@ WRITE_CLASS_ENCODER(PG::Log)
 WRITE_CLASS_ENCODER(PG::Interval)
 WRITE_CLASS_ENCODER(PG::OndiskLog)
 
-inline ostream& operator<<(ostream& out, const PG::Info::History& h) 
-{
-  return out << "ec=" << h.epoch_created
-            << " les/c " << h.last_epoch_started << "/" << h.last_epoch_clean
-            << " " << h.same_up_since << "/" << h.same_interval_since << "/" << h.same_primary_since;
-}
-
 inline ostream& operator<<(ostream& out, const PG::Info& pgi) 
 {
   out << pgi.pgid << "(";
index c262a23910393b0e98fd4f28a35b66583b90e394..788f97db858d9d47f6a6f7897543027af5e93555 100644 (file)
@@ -931,6 +931,72 @@ void pool_stat_t::generate_test_instances(list<pool_stat_t*>& o)
 }
 
 
+// -- pg_history_t --
+
+void pg_history_t::encode(bufferlist &bl) const
+{
+  __u8 struct_v = 3;
+  ::encode(struct_v, bl);
+  ::encode(epoch_created, bl);
+  ::encode(last_epoch_started, bl);
+  ::encode(last_epoch_clean, bl);
+  ::encode(last_epoch_split, bl);
+  ::encode(same_interval_since, bl);
+  ::encode(same_up_since, bl);
+  ::encode(same_primary_since, bl);
+  ::encode(last_scrub, bl);
+  ::encode(last_scrub_stamp, bl);
+}
+
+void pg_history_t::decode(bufferlist::iterator &bl)
+{
+  __u8 struct_v;
+  ::decode(struct_v, bl);
+  ::decode(epoch_created, bl);
+  ::decode(last_epoch_started, bl);
+  if (struct_v >= 3)
+    ::decode(last_epoch_clean, bl);
+  else
+    last_epoch_clean = last_epoch_started;  // careful, it's a lie!
+  ::decode(last_epoch_split, bl);
+  ::decode(same_interval_since, bl);
+  ::decode(same_up_since, bl);
+  ::decode(same_primary_since, bl);
+  if (struct_v >= 2) {
+    ::decode(last_scrub, bl);
+    ::decode(last_scrub_stamp, bl);
+  }
+}
+
+void pg_history_t::dump(Formatter *f) const
+{
+  f->dump_int("epoch_created", epoch_created);
+  f->dump_int("last_epoch_started", last_epoch_started);
+  f->dump_int("last_epoch_clean", last_epoch_clean);
+  f->dump_int("last_epoch_split", last_epoch_split);
+  f->dump_int("same_up_since", same_up_since);
+  f->dump_int("same_interval_since", same_interval_since);
+  f->dump_int("same_primary_since", same_primary_since);
+  f->dump_stream("last_scrub") << last_scrub;
+  f->dump_stream("last_scrub_stamp") << last_scrub_stamp;
+}
+
+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()->last_epoch_started = 2;
+  o.back()->last_epoch_clean = 3;
+  o.back()->last_epoch_split = 4;
+  o.back()->same_up_since = 5;
+  o.back()->same_interval_since = 6;
+  o.back()->same_primary_since = 7;
+  o.back()->last_scrub = eversion_t(8, 9);
+  o.back()->last_scrub_stamp = utime_t(10, 11);  
+}
+
+
 // -- OSDSuperblock --
 
 void OSDSuperblock::encode(bufferlist &bl) const
index 2a62a422cfb1f83e12f2be8f14afbba13d91098f..43fe6119f9e472f5c1dee4c495ec5e11d1597ce7 100644 (file)
@@ -844,6 +844,53 @@ WRITE_CLASS_ENCODER(pool_stat_t)
 
 
 
+struct pg_history_t {
+  epoch_t epoch_created;       // epoch in which PG was created
+  epoch_t last_epoch_started;  // lower bound on last epoch started (anywhere, not necessarily locally)
+  epoch_t last_epoch_clean;    // lower bound on last epoch the PG was completely clean.
+  epoch_t last_epoch_split;    // as parent
+  
+  epoch_t same_up_since;       // same acting set since
+  epoch_t same_interval_since;   // same acting AND up set since
+  epoch_t same_primary_since;  // same primary at least back through this epoch.
+
+  eversion_t last_scrub;
+  utime_t last_scrub_stamp;
+
+  pg_history_t()
+    : epoch_created(0),
+      last_epoch_started(0), last_epoch_clean(0), last_epoch_split(0),
+      same_up_since(0), same_interval_since(0), same_primary_since(0) {}
+  
+  void merge(const pg_history_t &other) {
+    // Here, we only update the fields which cannot be calculated from the OSDmap.
+    if (epoch_created < other.epoch_created)
+      epoch_created = other.epoch_created;
+    if (last_epoch_started < other.last_epoch_started)
+      last_epoch_started = other.last_epoch_started;
+    if (last_epoch_clean < other.last_epoch_clean)
+      last_epoch_clean = other.last_epoch_clean;
+    if (last_epoch_split < other.last_epoch_started)
+      last_epoch_split = other.last_epoch_started;
+    if (other.last_scrub > last_scrub)
+      last_scrub = other.last_scrub;
+    if (other.last_scrub_stamp > last_scrub_stamp)
+      last_scrub_stamp = other.last_scrub_stamp;
+  }
+
+  void encode(bufferlist& bl) const;
+  void decode(bufferlist::iterator& p);
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<pg_history_t*>& o);
+};
+WRITE_CLASS_ENCODER(pg_history_t)
+
+inline ostream& operator<<(ostream& out, const pg_history_t& h) {
+  return out << "ec=" << h.epoch_created
+            << " les/c " << h.last_epoch_started << "/" << h.last_epoch_clean
+            << " " << h.same_up_since << "/" << h.same_interval_since << "/" << h.same_primary_since;
+}
+