From: Samuel Just Date: Tue, 18 Mar 2014 19:09:05 +0000 (-0700) Subject: PG::find_best_info: fix log_tail component X-Git-Tag: v0.78~3^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b4420ffbf807e691a9f0f3eed69e1d505aa55ddd;p=ceph.git PG::find_best_info: fix log_tail component The previous logic should have kept the current best info if it found a replica which best could log-recover, but p couldn't. However, the continue in that loop advanced the inner loop instead of the outer loop allowing the primary case to take over in cases where best had a longer tail. Instead, we will prefer the longer tail regardless of the other infos to simplify the logic. Fixes: #7755 Signed-off-by: Samuel Just --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index a4029f82a0bc8..7829e8495fc9d 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -895,24 +895,15 @@ map::const_iterator PG::find_best_info( continue; } } - // Prefer longer tail if it brings another peer into contiguity - for (map::const_iterator q = infos.begin(); - q != infos.end(); - ++q) { - if (q->second.is_incomplete()) - continue; // don't care about log contiguity - if (q->second.last_update < best->second.log_tail && - q->second.last_update >= p->second.log_tail) { - dout(10) << "calc_acting prefer osd." << p->first - << " because it brings osd." << q->first << " into log contiguity" << dendl; - best = p; - continue; - } - if (q->second.last_update < p->second.log_tail && - q->second.last_update >= best->second.log_tail) { - continue; - } + + // Prefer longer tail + if (p->second.log_tail > best->second.log_tail) { + continue; + } else if (p->second.log_tail < best->second.log_tail) { + best = p; + continue; } + // prefer current primary (usually the caller), all things being equal if (p->first == pg_whoami) { dout(10) << "calc_acting prefer osd." << p->first