From a3be6651a2eeb43cdf3e43a1ceb053a09ff99b7b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 13 Oct 2011 12:48:41 -0700 Subject: [PATCH] osd: fix share_pg_log() We need to handle a log message in the ReplicaActive state. And set the epoch properly when we send it. Signed-off-by: Sage Weil --- src/osd/PG.cc | 16 +++++++++++++++- src/osd/PG.h | 4 +++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index b82fd4752ab8a..fc20e21e45c75 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -3343,7 +3343,7 @@ void PG::share_pg_log(const eversion_t &oldver) vector::const_iterator end = acting.end(); while (++a != end) { int peer(*a); - MOSDPGLog *m = new MOSDPGLog(info.last_update.version, info); + MOSDPGLog *m = new MOSDPGLog(info.last_update.epoch, info); m->log.head = log.head; m->log.tail = log.tail; for (list::const_reverse_iterator i = log.log.rbegin(); @@ -4213,6 +4213,20 @@ PG::RecoveryState::ReplicaActive::react(const MInfoRec& infoevt) { return discard_event(); } +boost::statechart::result +PG::RecoveryState::ReplicaActive::react(const MLogRec& logevt) { + PG *pg = context< RecoveryMachine >().pg; + MOSDPGLog *msg = logevt.msg; + dout(10) << "received log from " << logevt.from << dendl; + pg->merge_log(*context().get_cur_transaction(), + msg->info, msg->log, logevt.from); + + assert(pg->log.tail <= pg->info.last_complete || pg->log.backlog); + assert(pg->log.head == pg->info.last_update); + + return discard_event(); +} + boost::statechart::result PG::RecoveryState::ReplicaActive::react(const ActMap&) { PG *pg = context< RecoveryMachine >().pg; diff --git a/src/osd/PG.h b/src/osd/PG.h index 0a562630c2459..709d94063376c 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1207,9 +1207,11 @@ public: typedef boost::mpl::list < boost::statechart::custom_reaction< ActMap >, boost::statechart::custom_reaction< MQuery >, - boost::statechart::custom_reaction< MInfoRec > + boost::statechart::custom_reaction< MInfoRec >, + boost::statechart::custom_reaction< MLogRec > > reactions; boost::statechart::result react(const MInfoRec& infoevt); + boost::statechart::result react(const MLogRec& logevt); boost::statechart::result react(const ActMap&); boost::statechart::result react(const MQuery&); }; -- 2.39.5