From 88ee86d0bf85a5517314b6048cdb05a8c4a2eac0 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 5 Dec 2011 15:35:34 -0800 Subject: [PATCH] osd: keep backfill targets in acting set Signed-off-by: Sage Weil --- src/osd/PG.cc | 20 +++++++------------- src/osd/PG.h | 12 ++++++------ src/osd/ReplicatedPG.cc | 21 ++++++++++++--------- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index f02e1fee83682..c8d8c005861ac 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -805,7 +805,6 @@ void PG::clear_primary_state() // clear peering state stray_set.clear(); - backfill.clear(); peer_log_requested.clear(); peer_missing_requested.clear(); peer_info.clear(); @@ -842,7 +841,7 @@ void PG::clear_primary_state() * incomplete, or another osd has a longer tail that allows us to * bring other up nodes up to date. */ -void PG::calc_acting(int& newest_update_osd_id, vector& want, set& backfill) const +void PG::calc_acting(int& newest_update_osd_id, vector& want) const { map all_info(peer_info.begin(), peer_info.end()); all_info[osd->whoami] = info; @@ -960,8 +959,8 @@ void PG::calc_acting(int& newest_update_osd_id, vector& want, set& bac continue; const Info &cur_info = all_info.find(*i)->second; if (cur_info.is_incomplete() || cur_info.last_update < primary->second.log_tail) { - dout(10) << " osd." << *i << " (up) REJECTED " << cur_info << dendl; - backfill.insert(*i); + dout(10) << " osd." << *i << " (up) accepted (backfill) " << cur_info << dendl; + want.push_back(*i); } else { want.push_back(*i); dout(10) << " osd." << *i << " (up) accepted " << cur_info << dendl; @@ -996,10 +995,10 @@ void PG::calc_acting(int& newest_update_osd_id, vector& want, set& bac * calculate the desired acting, and request a change with the monitor * if it differs from the current acting. */ -bool PG::choose_acting(int& newest_update_osd, set& backfill) +bool PG::choose_acting(int& newest_update_osd) { vector want; - calc_acting(newest_update_osd, want, backfill); + calc_acting(newest_update_osd, want); if (want != acting) { dout(10) << "choose_acting want " << want << " != acting " << acting @@ -3438,9 +3437,6 @@ ostream& operator<<(ostream& out, const PG& pg) out << " r=" << pg.get_role(); out << " lpr=" << pg.get_last_peering_reset(); - if (pg.backfill.size()) - out << " backfill=" << pg.backfill; - if (pg.is_active() && pg.last_update_ondisk != pg.info.last_update) out << " luod=" << pg.last_update_ondisk; @@ -3862,10 +3858,8 @@ boost::statechart::result PG::RecoveryState::Active::react(const BackfillComplet PG *pg = context< RecoveryMachine >().pg; int newest_update_osd; - if (!pg->choose_acting(newest_update_osd, pg->backfill)) { + if (!pg->choose_acting(newest_update_osd)) { post_event(NeedNewMap()); - } else { - assert(0 == "we shouldn't get here"); } return discard_event(); @@ -4105,7 +4099,7 @@ PG::RecoveryState::GetLog::GetLog(my_context ctx) : PG *pg = context< RecoveryMachine >().pg; // adjust acting? - if (!pg->choose_acting(newest_update_osd, pg->backfill)) { + if (!pg->choose_acting(newest_update_osd)) { post_event(NeedNewMap()); return; } diff --git a/src/osd/PG.h b/src/osd/PG.h index 149c087a0ca82..9e252966752b5 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -870,7 +870,6 @@ public: // primary state public: vector up, acting; - set backfill; // up - acting map peer_last_complete_ondisk; eversion_t min_last_complete_ondisk; // up: min over last_complete_ondisk, peer_last_complete_ondisk eversion_t pg_trim_to; @@ -1359,6 +1358,9 @@ protected: // primary-only, recovery-only state set might_have_unfound; // These osds might have objects on them // which are unfound on the primary + + epoch_t last_peering_reset; + struct BackfillInterval { // info about a backfill interval on a peer map objects; @@ -1386,10 +1388,8 @@ protected: }; BackfillInterval backfill_info; - int backfill_target; BackfillInterval peer_backfill_info; - - epoch_t last_peering_reset; + int backfill_target; friend class OSD; @@ -1479,8 +1479,8 @@ public: void trim_write_ahead(); - void calc_acting(int& newest_update_osd, vector& want, set& backfill) const; - bool choose_acting(int& newest_update_osd, set& backfill); + void calc_acting(int& newest_update_osd, vector& want) const; + bool choose_acting(int& newest_update_osd); void build_might_have_unfound(); void replay_queued_ops(); void activate(ObjectStore::Transaction& t, list& tfin, diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 09172247aa818..51ca7b7072329 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4959,7 +4959,15 @@ int ReplicatedPG::start_recovery_ops(int max) // second chance to recovery replicas started = recover_replicas(max); } - if (!backfill.empty() && started < max) { + if (backfill_target < 0) { + for (unsigned i = 1; i= 0 && started < max) { started += recover_backfill(max - started); } @@ -4971,7 +4979,7 @@ int ReplicatedPG::start_recovery_ops(int max) assert(recovery_ops_active == 0); - if (backfill.size()) { + if (acting != up) { PG::RecoveryCtx rctx(0, 0, 0, 0, 0); handle_backfill_complete(&rctx); return 0; @@ -5265,13 +5273,8 @@ int ReplicatedPG::recover_replicas(int max) int ReplicatedPG::recover_backfill(int max) { dout(10) << "recover_backfill (" << max << ")" << dendl; - assert(!backfill.empty()); + assert(backfill_target >= 0); - // backfill one peer at a time. - if (backfill_target < 0) { - backfill_target = *backfill.begin(); - dout(10) << " chose backfill target osd." << backfill_target << dendl; - } Info& pinfo = peer_info[backfill_target]; BackfillInterval& pbi = peer_backfill_info; @@ -5395,7 +5398,7 @@ int ReplicatedPG::recover_backfill(int max) } hobject_t bound = pbi.begin; - bound.back_up_to_bounding_key; + bound.back_up_to_bounding_key(); if (pinfo.last_backfill < bound) { pinfo.last_backfill = bound; -- 2.39.5