]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
PG: do not use role == 0 as a determinant of primacy
authorGreg Farnum <greg@inktank.com>
Fri, 13 Dec 2013 22:48:51 +0000 (14:48 -0800)
committerGreg Farnum <greg@inktank.com>
Thu, 16 Jan 2014 00:33:04 +0000 (16:33 -0800)
We already have an is_primary() function to use instead.

Signed-off-by: Greg Farnum <greg@inktank.com>
src/osd/OSD.cc
src/osd/PG.cc

index e922402e6951320f2e3861216b02c85fb1bc2237..6d46a91cb1abf2d37ff26f2a19b7a5bc74a9492f 100644 (file)
@@ -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();
       }
index 17f63921b9770083d3c6ba39ec1e652dc25a6e09..545aaa6ad7b688fe8922aa453880f75fea8f6a06 100644 (file)
@@ -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<int> new_peers;
-  if (role == 0) {
+  if (is_primary()) {
     for (unsigned i=0; i<acting.size(); i++)
       new_peers.insert(acting[i]);
     for (unsigned i=0; i<up.size(); i++)
@@ -4529,6 +4529,7 @@ void PG::start_peering_interval(const OSDMapRef lastmap,
   vector<int> 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 >();
 }