From: Sage Weil Date: Sat, 28 Jul 2012 16:17:34 +0000 (-0700) Subject: osd: replace STRAY bit with bool X-Git-Tag: v0.51~57^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f9ff8dd3b2743ea43ab44fcf10e4821610ced792;p=ceph.git osd: replace STRAY bit with bool 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 --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index c9e5045e6bb8..031cdbd3b8c2 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -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(), diff --git a/src/osd/PG.h b/src/osd/PG.h index 721d6b7935d7..564588eda19f 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -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); } diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 6bc433662361..f909dc599181 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -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) diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index d3f3776a7022..97c86587555a 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -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