waiting_on_backfill(0),
role(0),
state(0),
+ send_notify(false),
need_up_thru(false),
need_flush(false),
last_peering_reset(0),
// 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
// 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 "
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;
}
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()) {
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(),
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(),
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(),
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.
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); }
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); }
#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