Skip to content

Commit

Permalink
Merge pull request ceph#6117 from athanatos/wip-12990
Browse files Browse the repository at this point in the history
Wip 12990

Reviewed-by: Sage Weil <[email protected]>
  • Loading branch information
Samuel Just committed Sep 30, 2015
2 parents 142cfc1 + 930d8eb commit a1760b4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/osd/OSDMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ class OSDMap {
return exists(osd) && (osd_state[osd] & CEPH_OSD_UP);
}

bool has_been_up_since(int osd, epoch_t epoch) const {
return is_up(osd) && get_up_from(osd) <= epoch;
}

bool is_down(int osd) const {
return !is_up(osd);
}
Expand Down
24 changes: 18 additions & 6 deletions src/osd/PG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,21 @@ void PG::proc_replica_log(
peer_missing[from].swap(omissing);
}

bool PG::proc_replica_info(pg_shard_t from, const pg_info_t &oinfo)
bool PG::proc_replica_info(
pg_shard_t from, const pg_info_t &oinfo, epoch_t send_epoch)
{
map<pg_shard_t, pg_info_t>::iterator p = peer_info.find(from);
if (p != peer_info.end() && p->second.last_update == oinfo.last_update) {
dout(10) << " got dup osd." << from << " info " << oinfo << ", identical to ours" << dendl;
return false;
}

if (!get_osdmap()->has_been_up_since(from.osd, send_epoch)) {
dout(10) << " got info " << oinfo << " from down osd." << from
<< " discarding" << dendl;
return false;
}

dout(10) << " got osd." << from << " " << oinfo << dendl;
assert(is_primary());
peer_info[from] = oinfo;
Expand Down Expand Up @@ -5348,7 +5355,8 @@ boost::statechart::result PG::RecoveryState::Initial::react(const Load& l)
boost::statechart::result PG::RecoveryState::Initial::react(const MNotifyRec& notify)
{
PG *pg = context< RecoveryMachine >().pg;
pg->proc_replica_info(notify.from, notify.notify.info);
pg->proc_replica_info(
notify.from, notify.notify.info, notify.notify.epoch_sent);
pg->update_heartbeat_peers();
pg->set_last_peering_reset();
return transit< Primary >();
Expand Down Expand Up @@ -5584,7 +5592,8 @@ boost::statechart::result PG::RecoveryState::Primary::react(const MNotifyRec& no
dout(10) << *pg << " got dup osd." << notevt.from << " info " << notevt.notify.info
<< ", identical to ours" << dendl;
} else {
pg->proc_replica_info(notevt.from, notevt.notify.info);
pg->proc_replica_info(
notevt.from, notevt.notify.info, notevt.notify.epoch_sent);
}
return discard_event();
}
Expand Down Expand Up @@ -6427,7 +6436,8 @@ boost::statechart::result PG::RecoveryState::Active::react(const MNotifyRec& not
dout(10) << "Active: got notify from " << notevt.from
<< ", calling proc_replica_info and discover_all_missing"
<< dendl;
pg->proc_replica_info(notevt.from, notevt.notify.info);
pg->proc_replica_info(
notevt.from, notevt.notify.info, notevt.notify.epoch_sent);
if (pg->have_unfound()) {
pg->discover_all_missing(*context< RecoveryMachine >().get_query_map());
}
Expand Down Expand Up @@ -6864,7 +6874,8 @@ boost::statechart::result PG::RecoveryState::GetInfo::react(const MNotifyRec& in
}

epoch_t old_start = pg->info.history.last_epoch_started;
if (pg->proc_replica_info(infoevt.from, infoevt.notify.info)) {
if (pg->proc_replica_info(
infoevt.from, infoevt.notify.info, infoevt.notify.epoch_sent)) {
// we got something new ...
unique_ptr<PriorSet> &prior_set = context< Peering >().prior_set;
if (old_start < pg->info.history.last_epoch_started) {
Expand Down Expand Up @@ -7221,7 +7232,8 @@ boost::statechart::result PG::RecoveryState::Incomplete::react(const MNotifyRec&
<< ", identical to ours" << dendl;
return discard_event();
} else {
pg->proc_replica_info(notevt.from, notevt.notify.info);
pg->proc_replica_info(
notevt.from, notevt.notify.info, notevt.notify.epoch_sent);
// try again!
return transit< GetLog >();
}
Expand Down
3 changes: 2 additions & 1 deletion src/osd/PG.h
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,8 @@ class PG {
pg_missing_t& omissing, pg_shard_t from);
void proc_master_log(ObjectStore::Transaction& t, pg_info_t &oinfo, pg_log_t &olog,
pg_missing_t& omissing, pg_shard_t from);
bool proc_replica_info(pg_shard_t from, const pg_info_t &info);
bool proc_replica_info(
pg_shard_t from, const pg_info_t &info, epoch_t send_epoch);


struct LogEntryTrimmer : public ObjectModDesc::Visitor {
Expand Down

0 comments on commit a1760b4

Please sign in to comment.