pg_t pgid = it->first;
PG *pg = it->second;
+ vector<int> newup, newacting;
+ osdmap->pg_to_up_acting_osds(pg->info.pgid, newup, newacting);
+
pg->lock();
dout(10) << "Scanning pg " << *pg << dendl;
- pg->handle_advance_map(*osdmap, *lastmap, 0);
+ pg->handle_advance_map(*osdmap, *lastmap, newup, newacting, 0);
pg->unlock();
}
}
}
}
-bool PG::acting_up_affected(OSDMap &osdmap,
- const OSDMap &lastmap)
+bool PG::acting_up_affected(const vector<int>& newup, const vector<int>& newacting)
{
- // get new acting set
- vector<int> tup, tacting;
- osdmap.pg_to_up_acting_osds(info.pgid, tup, tacting);
-
- if (acting != tacting || up != tup) {
+ if (acting != newacting || up != newup) {
return true;
} else {
return false;
}
/* Called before initializing peering during advance_map */
-void PG::warm_restart()
+void PG::warm_restart(const OSDMap& lastmap, const vector<int>& newup, const vector<int>& newacting)
{
- OSDMap &lastmap = *osd->get_map(osd->osdmap->get_epoch() - 1);
- OSDMap &osdmap = *osd->osdmap;
+ const OSDMap &osdmap = *osd->osdmap;
+
// -- there was a change! --
kick();
+ vector<int> oldacting, oldup;
int oldrole = get_role();
int oldprimary = get_primary();
-
- vector<int> oldacting, oldup; //About to get swapped with current (old)
- osdmap.pg_to_up_acting_osds(info.pgid, oldup, oldacting);
-
- // update PG
acting.swap(oldacting);
up.swap(oldup);
+ up = newup;
+ acting = newacting;
+
int role = osdmap.calc_pg_role(osd->whoami, acting, acting.size());
set_role(role);
PG::RecoveryState::Started::react(const AdvMap& advmap) {
dout(10) << "Started advmap" << dendl;
PG *pg = context< RecoveryMachine >().pg;
- if (pg->acting_up_affected(advmap.osdmap, advmap.lastmap)) {
+ if (pg->acting_up_affected(advmap.newup, advmap.newacting)) {
dout(10) << "up or acting affected, transitioning to Reset" << dendl;
+ post_event(advmap);
return transit< Reset >();
}
return discard_event();
PG::RecoveryState::Reset::react(const AdvMap& advmap) {
PG *pg = context< RecoveryMachine >().pg;
dout(10) << "Reset advmap" << dendl;
- if (pg->acting_up_affected(advmap.osdmap, advmap.lastmap)) {
+ if (pg->acting_up_affected(advmap.newup, advmap.newacting)) {
dout(10) << "up or acting affected, calling warm_restart again" << dendl;
- pg->warm_restart();
+ pg->warm_restart(advmap.lastmap, advmap.newup, advmap.newacting);
}
return discard_event();
}
}
return transit< Started >();
}
-
-PG::RecoveryState::Reset::Reset(my_context ctx) : my_base(ctx) {
- PG *pg = context< RecoveryMachine >().pg;
- dout(10) << "Reseting" << dendl;
- pg->warm_restart();
- post_event(Initialize());
-}
/*-------Start---------*/
PG::RecoveryState::Start::Start(my_context ctx) : my_base(ctx) {
dout(10) << "Peering advmap" << dendl;
if (pg->prior_set_affected(*prior_set.get(), &advmap.osdmap)) {
dout(1) << "Peering, priors_set_affected, going to Reset" << dendl;
+ post_event(advmap);
return transit< Reset >();
}
return forward_event();
}
void PG::RecoveryState::handle_advance_map(OSDMap &osdmap, OSDMap &lastmap,
+ vector<int>& newup, vector<int>& newacting,
RecoveryCtx *rctx)
{
start_handle(rctx);
- machine.process_event(AdvMap(osdmap, lastmap));
+ machine.process_event(AdvMap(osdmap, lastmap, newup, newacting));
end_handle();
}
struct AdvMap : boost::statechart::event< AdvMap > {
OSDMap &osdmap;
OSDMap &lastmap;
- AdvMap(OSDMap &osdmap, OSDMap &lastmap):
- osdmap(osdmap), lastmap(lastmap) {}
+ vector<int> newup, newacting;
+ AdvMap(OSDMap &osdmap, OSDMap &lastmap, vector<int>& newup, vector<int>& newacting):
+ osdmap(osdmap), lastmap(lastmap), newup(newup), newacting(newacting) {}
};
struct BacklogComplete : boost::statechart::event< BacklogComplete > {};
};
struct Reset :
- boost::statechart::state< Reset, RecoveryMachine > {
+ boost::statechart::simple_state< Reset, RecoveryMachine > {
typedef boost::mpl::list <
boost::statechart::custom_reaction< AdvMap >,
boost::statechart::custom_reaction< ActMap >
> reactions;
-
- /* Entry function for RecoveryMachine. Should initialize relevant peering
- * state */
- Reset(my_context ctx);
boost::statechart::result react(const AdvMap&);
boost::statechart::result react(const ActMap&);
};
MOSDPGLog *msg,
RecoveryCtx *ctx);
void handle_query(int from, const PG::Query& q, RecoveryCtx *ctx);
- void handle_advance_map(OSDMap &osdmap, OSDMap &lastmap, RecoveryCtx *ctx);
+ void handle_advance_map(OSDMap &osdmap, OSDMap &lastmap,
+ vector<int>& newup, vector<int>& newacting,
+ RecoveryCtx *ctx);
void handle_activate_map(RecoveryCtx *ctx);
void handle_backlog_generated(RecoveryCtx *ctx);
void handle_create(RecoveryCtx *ctx);
void share_pg_info();
void share_pg_log(const eversion_t &oldver);
- void warm_restart();
+ void warm_restart(const OSDMap& lastmap, const vector<int>& newup, const vector<int>& newacting);
void fulfill_info(int from, const Query &query,
pair<int, Info> ¬ify_info);
void fulfill_log(int from, const Query &query);
- bool acting_up_affected(OSDMap &osdmap,
- const OSDMap &lastmap);
+ bool acting_up_affected(const vector<int>& newup, const vector<int>& newacting);
// recovery bits
void handle_notify(int from, PG::Info& i, RecoveryCtx *rctx) {
recovery_state.handle_query(from, q, rctx);
}
void handle_advance_map(OSDMap &osdmap, OSDMap &lastmap,
+ vector<int>& newup, vector<int>& newacting,
RecoveryCtx *rctx) {
- recovery_state.handle_advance_map(osdmap, lastmap, rctx);
+ recovery_state.handle_advance_map(osdmap, lastmap, newup, newacting, rctx);
}
void handle_activate_map(RecoveryCtx *rctx) {
recovery_state.handle_activate_map(rctx);