]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix share_pg_log()
authorSage Weil <sage@newdream.net>
Thu, 13 Oct 2011 19:48:41 +0000 (12:48 -0700)
committerSage Weil <sage@newdream.net>
Sat, 15 Oct 2011 04:02:32 +0000 (21:02 -0700)
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 <sage@newdream.net>
src/osd/PG.cc
src/osd/PG.h

index b82fd4752ab8afa01916e8e3c3658049a4e9514d..fc20e21e45c75d8f492be794da5ddde2029e3979 100644 (file)
@@ -3343,7 +3343,7 @@ void PG::share_pg_log(const eversion_t &oldver)
   vector<int>::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<Log::Entry>::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<RecoveryMachine>().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;
index 0a562630c245995e95360e88a233310a6d9629ca..709d94063376c20d6310250efb0936ca7de50fbf 100644 (file)
@@ -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&);
     };