]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: replace STRAY bit with bool
authorSage Weil <sage@inktank.com>
Sat, 28 Jul 2012 16:17:34 +0000 (09:17 -0700)
committerSage Weil <sage@inktank.com>
Mon, 30 Jul 2012 17:49:15 +0000 (10:49 -0700)
We were setting a bit in pg->state that is private to the non-primary
PG.  The other bits get shared with the mon etc, but this one didn't.

Replace it with a simple bool.

Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/PG.cc
src/osd/PG.h
src/osd/osd_types.cc
src/osd/osd_types.h

index c9e5045e6bb854b583c68c41360adf3c7b3d7e09..031cdbd3b8c2546f925bbc83e20459991dce3106 100644 (file)
@@ -67,6 +67,7 @@ PG::PG(OSDService *o, OSDMapRef curmap,
   waiting_on_backfill(0),
   role(0),
   state(0),
+  send_notify(false),
   need_up_thru(false),
   need_flush(false),
   last_peering_reset(0),
@@ -1293,9 +1294,10 @@ void PG::activate(ObjectStore::Transaction& t,
 
   // twiddle pg state
   state_set(PG_STATE_ACTIVE);
-  state_clear(PG_STATE_STRAY);
   state_clear(PG_STATE_DOWN);
 
+  send_notify = false;
+
   if (is_primary()) {
     // If necessary, create might_have_unfound to help us find our unfound objects.
     // NOTE: It's important that we build might_have_unfound before trimming the
@@ -3849,21 +3851,15 @@ void PG::start_peering_interval(const OSDMapRef lastmap,
     // take active waiters
     requeue_ops(waiting_for_active);
 
-    // new primary?
-    if (role == 0) {
-      // i am new primary
-      state_clear(PG_STATE_STRAY);
-    } else {
-      // i am now replica|stray.  we need to send a notify.
-      state_set(PG_STATE_STRAY);
-    }
+    // should we tell the primary we are here?
+    send_notify = (role != 0);
       
   } else {
     // no role change.
     // did primary change?
     if (get_primary() != oldprimary) {    
       // we need to announce
-      state_set(PG_STATE_STRAY);
+      send_notify = true;
         
       dout(10) << *this << " " << oldacting << " -> " << acting 
               << ", acting primary " 
@@ -3893,7 +3889,6 @@ void PG::start_peering_interval(const OSDMapRef lastmap,
 void PG::proc_primary_info(ObjectStore::Transaction &t, const pg_info_t &oinfo)
 {
   assert(!is_primary());
-  assert(is_stray() || is_active());
 
   if (info.last_backfill.is_max()) {
     info.stats = oinfo.stats;
@@ -3973,6 +3968,8 @@ ostream& operator<<(ostream& out, const PG& pg)
   }
 
   out << " " << pg_state_string(pg.get_state());
+  if (pg.should_send_notify())
+    out << " NOTIFY";
 
   //out << " (" << pg.log.tail << "," << pg.log.head << "]";
   if (pg.missing.num_missing()) {
@@ -4410,7 +4407,7 @@ boost::statechart::result PG::RecoveryState::Reset::react(const AdvMap& advmap)
 boost::statechart::result PG::RecoveryState::Reset::react(const ActMap&)
 {
   PG *pg = context< RecoveryMachine >().pg;
-  if (pg->is_stray() && pg->get_primary() >= 0) {
+  if (pg->should_send_notify() && pg->get_primary() >= 0) {
     context< RecoveryMachine >().send_notify(pg->get_primary(),
                                             pg_notify_t(pg->get_osdmap()->get_epoch(),
                                                         pg->get_osdmap()->get_epoch(),
@@ -4852,7 +4849,7 @@ boost::statechart::result PG::RecoveryState::ReplicaActive::react(const MLogRec&
 boost::statechart::result PG::RecoveryState::ReplicaActive::react(const ActMap&)
 {
   PG *pg = context< RecoveryMachine >().pg;
-  if (pg->is_stray() && pg->get_primary() >= 0) {
+  if (pg->should_send_notify() && pg->get_primary() >= 0) {
     context< RecoveryMachine >().send_notify(pg->get_primary(),
                                             pg_notify_t(pg->get_osdmap()->get_epoch(),
                                                         pg->get_osdmap()->get_epoch(),
@@ -4971,7 +4968,7 @@ boost::statechart::result PG::RecoveryState::Stray::react(const MQuery& query)
 boost::statechart::result PG::RecoveryState::Stray::react(const ActMap&)
 {
   PG *pg = context< RecoveryMachine >().pg;
-  if (pg->is_stray() && pg->get_primary() >= 0) {
+  if (pg->should_send_notify() && pg->get_primary() >= 0) {
     context< RecoveryMachine >().send_notify(pg->get_primary(),
                                             pg_notify_t(pg->get_osdmap()->get_epoch(),
                                                         pg->get_osdmap()->get_epoch(),
index 721d6b7935d780fed3020a9d0332caabbd6cd948..564588eda19fd0aa9827f4c7cf71a9be9da63300 100644 (file)
@@ -432,6 +432,8 @@ protected:
   int         role;    // 0 = primary, 1 = replica, -1=none.
   unsigned    state;   // PG_STATE_*
 
+  bool send_notify;    ///< true if we are non-primary and should notify the primary
+
 public:
   eversion_t  last_update_ondisk;    // last_update that has committed; ONLY DEFINED WHEN is_active()
   eversion_t  last_complete_ondisk;  // last_complete that has committed.
@@ -1418,6 +1420,7 @@ public:
   void state_clear(int m) { state &= ~m; }
 
   bool is_complete() const { return info.last_complete == info.last_update; }
+  bool should_send_notify() const { return send_notify; }
 
   int get_state() const { return state; }
   bool       is_active() const { return state_test(PG_STATE_ACTIVE); }
@@ -1426,7 +1429,6 @@ public:
   bool       is_replay() const { return state_test(PG_STATE_REPLAY); }
   bool       is_clean() const { return state_test(PG_STATE_CLEAN); }
   bool       is_degraded() const { return state_test(PG_STATE_DEGRADED); }
-  bool       is_stray() const { return state_test(PG_STATE_STRAY); }
 
   bool       is_scrubbing() const { return state_test(PG_STATE_SCRUBBING); }
 
index 6bc433662361bb30552b30371cb58da4fd6c380d..f909dc599181b71c420a249486ffda365f479c29 100644 (file)
@@ -398,8 +398,6 @@ std::string pg_state_string(int state)
     oss << "down+";
   if (state & PG_STATE_REPLAY)
     oss << "replay+";
-  if (state & PG_STATE_STRAY)
-    oss << "stray+";
   if (state & PG_STATE_SPLITTING)
     oss << "splitting+";
   if (state & PG_STATE_DEGRADED)
index d3f3776a702233e54ec4f43b91228fbf108cd5be..97c86587555ac7a5c3859dee9879fd99e20e1ce9 100644 (file)
@@ -551,7 +551,7 @@ inline ostream& operator<<(ostream& out, const osd_stat_t& s) {
 #define PG_STATE_CLEAN        (1<<2)  // peers are complete, clean of stray replicas.
 #define PG_STATE_DOWN         (1<<4)  // a needed replica is down, PG offline
 #define PG_STATE_REPLAY       (1<<5)  // crashed, waiting for replay
-#define PG_STATE_STRAY        (1<<6)  // i must notify the primary i exist.
+//#define PG_STATE_STRAY      (1<<6)  // i must notify the primary i exist.
 #define PG_STATE_SPLITTING    (1<<7)  // i am splitting
 #define PG_STATE_SCRUBBING    (1<<8)  // scrubbing
 #define PG_STATE_SCRUBQ       (1<<9)  // queued for scrub