]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: move epoch_created, last_epoch_started into History
authorSage Weil <sage@newdream.net>
Fri, 16 May 2008 19:58:02 +0000 (12:58 -0700)
committerSage Weil <sage@newdream.net>
Fri, 16 May 2008 19:58:09 +0000 (12:58 -0700)
src/osd/OSD.cc
src/osd/PG.cc
src/osd/PG.h

index a49da183c8ce271a6dd3eda934f8b4c4430623a3..d21546806994e13531e70102fe15f9ca48400264 100644 (file)
@@ -520,9 +520,9 @@ PG * OSD::_create_lock_new_pg(pg_t pgid, vector<int>& acting, ObjectStore::Trans
   PG *pg = _create_lock_pg(pgid, t);
   pg->set_role(0);
   pg->acting.swap(acting);
-  pg->info.epoch_created = 
-    pg->last_epoch_started_any = 
-    pg->info.last_epoch_started = 
+  pg->last_epoch_started_any = 
+    pg->info.history.epoch_created = 
+    pg->info.history.last_epoch_started = 
     pg->info.history.same_since = 
     pg->info.history.same_primary_since = 
     pg->info.history.same_acker_since = osdmap->get_epoch();
@@ -1622,7 +1622,7 @@ void OSD::activate_map(ObjectStore::Transaction& t)
     pg->lock();
     if (pg->is_active()) {
       // update started counter
-      pg->info.last_epoch_started = osdmap->get_epoch();
+      pg->info.history.last_epoch_started = osdmap->get_epoch();
     } 
     else if (pg->get_role() == 0 && !pg->is_active()) {
       // i am (inactive) primary
@@ -2122,8 +2122,6 @@ void OSD::handle_pg_notify(MOSDPGNotify *m)
 
       assert(role == 0);  // otherwise, probably bug in project_pg_history.
       
-      epoch_t last_epoch_started = it->last_epoch_started;
-
       // DNE on source?
       if (it->dne()) {  
        // is there a creation pending on this pg?
@@ -2147,8 +2145,7 @@ void OSD::handle_pg_notify(MOSDPGNotify *m)
        pg->acting.swap(acting);
        pg->set_role(role);
        pg->info.history = history;
-       pg->info.epoch_created = it->epoch_created;
-       pg->last_epoch_started_any = last_epoch_started;  // _after_ clear_primary_state()
+       pg->last_epoch_started_any = history.last_epoch_started;  // _after_ clear_primary_state()
        pg->clear_primary_state();  // yep, notably, set hml=false
        pg->build_prior();      
        pg->write_log(t);
@@ -2179,7 +2176,7 @@ void OSD::handle_pg_notify(MOSDPGNotify *m)
 
     // stray?
     bool acting = pg->is_acting(from);
-    if (!acting && (*it).last_epoch_started > 0) {
+    if (!acting && (*it).history.last_epoch_started > 0) {
       dout(10) << *pg << " osd" << from << " has stray content: " << *it << dendl;
       pg->stray_set.insert(from);
       pg->state_clear(PG_STATE_CLEAN);
@@ -2203,7 +2200,7 @@ void OSD::handle_pg_notify(MOSDPGNotify *m)
       if (pg->is_all_uptodate()) 
        pg->finish_recovery();
     } else {
-      if (it->last_epoch_started > pg->last_epoch_started_any) 
+      if (it->history.last_epoch_started > pg->last_epoch_started_any) 
         pg->adjust_prior();
       pg->peer(t, query_map, &info_map);
     }
index 72276aca7caf8cde5439200cc55e373da1d18401..4367f7b0a8bd5ac4d4462c41f9f4cc890bcdf6cc 100644 (file)
@@ -544,8 +544,8 @@ void PG::adjust_prior()
   for (map<int,Info>::iterator it = peer_info.begin();
        it != peer_info.end();
        it++) {
-    if (it->second.last_epoch_started > max)
-      max = it->second.last_epoch_started;
+    if (it->second.history.last_epoch_started > max)
+      max = it->second.history.last_epoch_started;
   }
 
   dout(10) << "adjust_prior last_epoch_started_any " 
@@ -574,7 +574,7 @@ void PG::clear_primary_state()
   
   stat_object_temp_rd.clear();
 
-  last_epoch_started_any = info.last_epoch_started;
+  last_epoch_started_any = info.history.last_epoch_started;
 }
 
 void PG::peer(ObjectStore::Transaction& t, 
@@ -661,7 +661,7 @@ void PG::peer(ObjectStore::Transaction& t,
     } else {
       dout(10) << " still active from last started: " << last_started << dendl;
     }
-  } else if (osd->osdmap->get_epoch() > info.epoch_created) {  // FIXME hrm is htis right?
+  } else if (osd->osdmap->get_epoch() > info.history.epoch_created) {  // FIXME hrm is htis right?
     dout(10) << " crashed since epoch " << last_epoch_started_any << dendl;
     state_set(PG_STATE_CRASHED);
   }    
@@ -844,7 +844,7 @@ void PG::activate(ObjectStore::Transaction& t,
     state_clear(PG_STATE_CRASHED);
     state_clear(PG_STATE_REPLAY);
   }
-  last_epoch_started_any = info.last_epoch_started = osd->osdmap->get_epoch();
+  last_epoch_started_any = info.history.last_epoch_started = osd->osdmap->get_epoch();
   
   if (role == 0) {    // primary state
     peers_complete_thru = eversion_t(0,0);  // we don't know (yet)!
index adacf86dfa88eebf20ff63926e25a0d1da70fe56..1707c298d49fe6cca81bd1b2f4153e9a8678912c 100644 (file)
@@ -66,20 +66,27 @@ public:
     eversion_t log_bottom;     // oldest log entry.
     bool       log_backlog;    // do we store a complete log?
 
-    epoch_t epoch_created;       // epoch in which it was created
-    epoch_t last_epoch_started;  // last epoch started.
-
     struct History {
+      epoch_t epoch_created;       // epoch in which it was created
+      epoch_t last_epoch_started;  // last epoch started.
+
       epoch_t same_since;          // same acting set since
       epoch_t same_primary_since;  // same primary at least back through this epoch.
       epoch_t same_acker_since;    // same acker at least back through this epoch.
-      History() : same_since(0), same_primary_since(0), same_acker_since(0) {}
+      History() :            
+       epoch_created(0),
+       last_epoch_started(0),
+       same_since(0), same_primary_since(0), same_acker_since(0) {}
       void encode(bufferlist &bl) const {
+       ::encode(epoch_created, bl);
+       ::encode(last_epoch_started, bl);
        ::encode(same_since, bl);
        ::encode(same_primary_since, bl);
        ::encode(same_acker_since, bl);
       }
       void decode(bufferlist::iterator &bl) {
+       ::decode(epoch_created, bl);
+       ::decode(last_epoch_started, bl);
        ::decode(same_since, bl);
        ::decode(same_primary_since, bl);
        ::decode(same_acker_since, bl);
@@ -87,13 +94,11 @@ public:
     } history;
     
     Info(pg_t p=0) : pgid(p), 
-                     log_backlog(false),
-                    epoch_created(0),
-                     last_epoch_started(0)
+                     log_backlog(false)
     { }
     bool is_uptodate() const { return last_update == last_complete; }
     bool is_empty() const { return last_update.version == 0; }
-    bool dne() const { return epoch_created == 0; }
+    bool dne() const { return history.epoch_created == 0; }
 
     void encode(bufferlist &bl) const {
       ::encode(pgid, bl);
@@ -101,8 +106,6 @@ public:
       ::encode(last_complete, bl);
       ::encode(log_bottom, bl);
       ::encode(log_backlog, bl);
-      ::encode(epoch_created, bl);
-      ::encode(last_epoch_started, bl);
       history.encode(bl);
     }
     void decode(bufferlist::iterator &bl) {
@@ -111,8 +114,6 @@ public:
       ::decode(last_complete, bl);
       ::decode(log_bottom, bl);
       ::decode(log_backlog, bl);
-      ::decode(epoch_created, bl);
-      ::decode(last_epoch_started, bl);
       history.decode(bl);
     }
   };
@@ -708,7 +709,9 @@ WRITE_CLASS_ENCODER(PG::Log)
 
 inline ostream& operator<<(ostream& out, const PG::Info::History& h) 
 {
-  return out << h.same_since << "/" << h.same_primary_since << "/" << h.same_acker_since;
+  return out << " ec " << h.epoch_created
+            << " les " << h.last_epoch_started
+            << h.same_since << "/" << h.same_primary_since << "/" << h.same_acker_since;
 }
 
 inline ostream& operator<<(ostream& out, const PG::Info& pgi) 
@@ -723,8 +726,7 @@ inline ostream& operator<<(ostream& out, const PG::Info& pgi)
         << " (" << pgi.log_bottom << "," << pgi.last_update << "]"
         << (pgi.log_backlog ? "+backlog":"");
   //out << " c " << pgi.epoch_created;
-  out << " e " << pgi.last_epoch_started
-      << " " << pgi.history
+  out << " " << pgi.history
       << ")";
   return out;
 }