]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: request proper log extent for missing
authorSage Weil <sage.weil@dreamhost.com>
Fri, 20 May 2011 16:29:10 +0000 (09:29 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Fri, 20 May 2011 16:29:10 +0000 (09:29 -0700)
We can't blinding ask for everything since last_epoch_started because that
may mean we get some fragment of a backlog.  Look at the peer's log
ranges and request the correct thing.  Also, in fulfill_log, infer what
the primary should have asked for if they make a bad request.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/osd/PG.cc

index a3fb79a1d2d210464289261bfd876a61c57dfd6d..812f6baa21add6f2db163e35481de6320c5ec5d6 100644 (file)
@@ -3437,7 +3437,13 @@ void PG::fulfill_log(int from, const Query &query)
     if (query.type == PG::Query::LOG) {
       dout(10) << " sending info+missing+log since " << query.since
               << dendl;
-      mlog->log.copy_after(log, query.since);
+      if (query.since != eversion_t() && query.since < log.tail) {
+       osd->clog.error() << info.pgid << " got broken Query::LOG since " << query.since
+                         << " when my log.tail is " << log.tail
+                         << ", sending full log instead\n";
+       mlog->log = log;           // primary should not have requested this!!
+      } else
+       mlog->log.copy_after(log, query.since);
     }
        
     if (query.type == PG::Query::BACKLOG) {
@@ -4565,11 +4571,22 @@ PG::RecoveryState::GetMissing::GetMissing(my_context ctx) : my_base(ctx)
 
     // We pull the log from the peer's last_epoch_started to ensure we
     // get enough log to detect divergent updates.
-    dout(10) << " requesting missing from osd" << *i << dendl;
-    context< RecoveryMachine >().send_query(*i,
-      Query(Query::LOG,
-           eversion_t(pi.history.last_epoch_started, 0),
-           pg->info.history));
+    eversion_t since(pi.history.last_epoch_started, 0);
+    if (pi.log_tail <= since) {
+      dout(10) << " requesting log+missing since " << since << " from osd" << *i << dendl;
+      context< RecoveryMachine >().send_query(*i, Query(Query::LOG, since, pg->info.history));
+    } else if (pi.log_backlog) {
+      dout(10) << " requesting backlog+missing from osd" << *i
+              << " (want since " << since << " < log.tail " << pi.log_tail << ")"
+              << dendl;
+      context< RecoveryMachine >().send_query(*i, Query(Query::BACKLOG, pg->info.history));
+    } else {
+      // hmm, is this case valid?
+      dout(10) << " requesting fulllog+missing from osd" << *i
+              << " (want since " << since << " < log.tail " << pi.log_tail << ")"
+              << dendl;
+      context< RecoveryMachine >().send_query(*i, Query(Query::FULLLOG, pg->info.history));
+    }
     peer_missing_requested.insert(*i);
   }