From a09d4f171ee7084281484fcbd56dda561ced9138 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Fri, 13 Dec 2013 14:48:51 -0800 Subject: [PATCH] PG: do not use role == 0 as a determinant of primacy We already have an is_primary() function to use instead. Signed-off-by: Greg Farnum --- src/osd/OSD.cc | 2 +- src/osd/PG.cc | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index e922402e695..6d46a91cb1a 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -6751,7 +6751,7 @@ void OSD::check_replay_queue() dout(10) << "check_replay_queue " << *pg << dendl; if (pg->is_active() && pg->is_replay() && - pg->get_role() == 0 && + pg->is_primary() && pg->replay_until == p->second) { pg->replay_queued_ops(); } diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 17f63921b97..545aaa6ad7b 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1191,7 +1191,7 @@ void PG::activate(ObjectStore::Transaction& t, } } - if (role == 0) { // primary state + if (is_primary()) { last_update_ondisk = info.last_update; min_last_complete_ondisk = eversion_t(0,0); // we don't know (yet)! } @@ -1852,7 +1852,7 @@ void PG::update_heartbeat_peers() assert(is_locked()); set new_peers; - if (role == 0) { + if (is_primary()) { for (unsigned i=0; i oldacting, oldup; int oldrole = get_role(); int oldprimary = get_primary(); + bool was_old_primary = is_primary(); acting.swap(oldacting); up.swap(oldup); @@ -4604,7 +4605,7 @@ void PG::start_peering_interval(const OSDMapRef lastmap, actingbackfill.clear(); // reset primary state? - if (oldrole == 0 || get_role() == 0) + if (was_old_primary || is_primary()) clear_primary_state(); @@ -4613,9 +4614,10 @@ void PG::start_peering_interval(const OSDMapRef lastmap, assert(!deleting); - if (role != oldrole) { - // old primary? - if (oldrole == 0) { + if (role != oldrole || + was_old_primary != is_primary()) { + // did primary change? + if (was_old_primary != is_primary()) { state_clear(PG_STATE_CLEAN); clear_publish_stats(); @@ -4635,7 +4637,7 @@ void PG::start_peering_interval(const OSDMapRef lastmap, requeue_ops(waiting_for_active); // should we tell the primary we are here? - send_notify = (role != 0); + send_notify = !is_primary(); } else { // no role change. @@ -4754,7 +4756,7 @@ ostream& operator<<(ostream& out, const PG& pg) if (pg.last_complete_ondisk != pg.info.last_complete) out << " lcod " << pg.last_complete_ondisk; - if (pg.get_role() == 0) { + if (pg.is_primary()) { out << " mlcod " << pg.min_last_complete_ondisk; } @@ -5124,7 +5126,7 @@ boost::statechart::result PG::RecoveryState::Initial::react(const Load& l) PG *pg = context< RecoveryMachine >().pg; // do we tell someone we're here? - pg->send_notify = (pg->role != 0); + pg->send_notify = (!pg->is_primary()); return transit< Reset >(); }