From 01ce583d53ef12eeed84028269244f82dffc09f4 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 16 May 2008 12:58:02 -0700 Subject: [PATCH] osd: move epoch_created, last_epoch_started into History --- src/osd/OSD.cc | 17 +++++++---------- src/osd/PG.cc | 10 +++++----- src/osd/PG.h | 32 +++++++++++++++++--------------- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index a49da183c8ce2..d21546806994e 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -520,9 +520,9 @@ PG * OSD::_create_lock_new_pg(pg_t pgid, vector& 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); } diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 72276aca7caf8..4367f7b0a8bd5 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -544,8 +544,8 @@ void PG::adjust_prior() for (map::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)! diff --git a/src/osd/PG.h b/src/osd/PG.h index adacf86dfa88e..1707c298d49fe 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -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; } -- 2.39.5