From: Samuel Just Date: Fri, 4 Jan 2013 04:16:50 +0000 (-0800) Subject: PG: move auth replica selection to helper in scrub X-Git-Tag: v0.57~188^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=39bc65492af1bf1da481a8ea0a70fe7d0b4b17a3;p=ceph.git PG: move auth replica selection to helper in scrub Signed-off-by: Samuel Just --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 7b2a0ec5a100..5eeb868ccbec 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -4099,6 +4099,28 @@ bool PG::_compare_scrub_objects(ScrubMap::object &auth, return ok; } + + +map::const_iterator PG::_select_auth_object( + const hobject_t &obj, + const map &maps) +{ + map::const_iterator auth = maps.end(); + // Select first present replica + for (map::const_iterator j = maps.begin(); + j != maps.end(); + ++j) { + if (!j->second->objects.count(obj)) { + continue; + } + if (auth == maps.end()) { + auth = j; + continue; + } + } + return auth; +} + void PG::_compare_scrubmaps(const map &maps, map > &missing, map > &inconsistent, @@ -4120,25 +4142,21 @@ void PG::_compare_scrubmaps(const map &maps, for (set::const_iterator k = master_set.begin(); k != master_set.end(); k++) { - map::const_iterator auth = maps.end(); + map::const_iterator auth = _select_auth_object(*k, maps); + assert(auth != maps.end()); set cur_missing; set cur_inconsistent; for (j = maps.begin(); j != maps.end(); j++) { if (j->second->objects.count(*k)) { - if (auth == maps.end()) { - // Take first osd to have it as authoritative - auth = j; - } else { - // Compare - stringstream ss; - if (!_compare_scrub_objects(auth->second->objects[*k], - j->second->objects[*k], - ss)) { - cur_inconsistent.insert(j->first); - ++scrubber.errors; - errorstream << info.pgid << " osd." << acting[j->first] - << ": soid " << *k << " " << ss.str() << std::endl; - } + // Compare + stringstream ss; + if (!_compare_scrub_objects(auth->second->objects[*k], + j->second->objects[*k], + ss)) { + cur_inconsistent.insert(j->first); + ++scrubber.errors; + errorstream << info.pgid << " osd." << acting[j->first] + << ": soid " << *k << " " << ss.str() << std::endl; } } else { cur_missing.insert(j->first); diff --git a/src/osd/PG.h b/src/osd/PG.h index 5d9b620089e4..9c2ae13495ce 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -956,6 +956,9 @@ public: int active_pushes; void repair_object(const hobject_t& soid, ScrubMap::object *po, int bad_peer, int ok_peer); + map::const_iterator _select_auth_object( + const hobject_t &obj, + const map &maps); bool _compare_scrub_objects(ScrubMap::object &auth, ScrubMap::object &candidate, ostream &errorstream);