/******* PG ***********/
-bool PG::is_all_uptodate() const
+bool PG::needs_recovery() const
{
assert(is_primary());
- bool uptodate = true;
-
- if (up != acting) {
- dout(10) << __func__ << ": the set of UP osds is not the same as the "
- << "set of ACTING osds." << dendl;
- uptodate = false;
- }
+ bool ret = false;
if (missing.num_missing()) {
- dout(10) << __func__ << ": primary has " << missing.num_missing() << dendl;
- uptodate = false;
+ dout(10) << __func__ << " primary has " << missing.num_missing() << dendl;
+ ret = true;
}
vector<int>::const_iterator end = acting.end();
int peer = *a;
map<int, pg_missing_t>::const_iterator pm = peer_missing.find(peer);
if (pm == peer_missing.end()) {
- dout(10) << __func__ << ": osd." << peer << " don't have missing set" << dendl;
- uptodate = false;
+ dout(10) << __func__ << " osd." << peer << " don't have missing set" << dendl;
+ ret = true;
continue;
}
if (pm->second.num_missing()) {
- dout(10) << __func__ << ": osd." << peer << " has " << pm->second.num_missing() << " missing" << dendl;
- uptodate = false;
+ dout(10) << __func__ << " osd." << peer << " has " << pm->second.num_missing() << " missing" << dendl;
+ ret = true;
}
map<int,pg_info_t>::const_iterator pi = peer_info.find(peer);
if (pi->second.last_backfill != hobject_t::get_max()) {
- dout(10) << __func__ << ": osd." << peer << " has last_backfill " << pi->second.last_backfill << dendl;
- uptodate = false;
+ dout(10) << __func__ << " osd." << peer << " has last_backfill " << pi->second.last_backfill << dendl;
+ ret = true;
}
}
- if (uptodate)
- dout(10) << __func__ << ": everyone is uptodate" << dendl;
- return uptodate;
+ if (!ret)
+ dout(10) << __func__ << " is recovered" << dendl;
+ return ret;
}
void PG::generate_past_intervals()
state_set(PG_STATE_DEGRADED);
// all clean?
- if (is_all_uptodate())
+ if (!needs_recovery()) {
finish_recovery(t, tfin);
- else {
+ } else {
dout(10) << "activate not all replicas are uptodate, queueing recovery" << dendl;
state_set(PG_STATE_RECOVERING);
osd->queue_for_recovery(this);
state_clear(PG_STATE_BACKFILL);
state_clear(PG_STATE_RECOVERING);
- // only clear DEGRADED (or mark CLEAN) if we have enough (or the
- // desired number of) replicas.
- if (acting.size() >= get_osdmap()->get_pg_size(info.pgid))
- state_clear(PG_STATE_DEGRADED);
+ // only mark CLEAN if we have the desired number of replicas.
if (acting.size() == get_osdmap()->get_pg_size(info.pgid))
state_set(PG_STATE_CLEAN);
pg->queue_snap_trim();
}
- if (pg->is_all_uptodate()) {
- dout(10) << "Active: all up to date, going clean" << dendl;
- pg->finish_recovery(*context< RecoveryMachine >().get_cur_transaction(),
- *context< RecoveryMachine >().get_context_list());
- }
-
return forward_event();
}
int newest_update_osd;
+ pg->state_clear(PG_STATE_BACKFILL);
+ pg->state_clear(PG_STATE_RECOVERING);
+
// adjust acting set? (e.g. because backfill completed...)
if (pg->acting != pg->up &&
!pg->choose_acting(newest_update_osd)) {
return discard_event();
}
- if (pg->is_all_uptodate()) {
- dout(10) << "recovery complete" << dendl;
- pg->log.reset_recovery_pointers();
- pg->finish_recovery(*context< RecoveryMachine >().get_cur_transaction(),
- *context< RecoveryMachine >().get_context_list());
- } else {
- dout(10) << "recovery not yet complete: some osds not up to date" << dendl;
- }
-
+ assert(!pg->needs_recovery());
+ pg->finish_recovery(*context< RecoveryMachine >().get_cur_transaction(),
+ *context< RecoveryMachine >().get_context_list());
return discard_event();
}