]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
PG: move auth replica selection to helper in scrub
authorSamuel Just <sam.just@inktank.com>
Fri, 4 Jan 2013 04:16:50 +0000 (20:16 -0800)
committerSage Weil <sage@inktank.com>
Wed, 23 Jan 2013 14:21:48 +0000 (06:21 -0800)
Signed-off-by: Samuel Just <sam.just@inktank.com>
(cherry picked from commit 39bc65492af1bf1da481a8ea0a70fe7d0b4b17a3)

src/osd/PG.cc
src/osd/PG.h

index 0a5460b9fa5d02c01deeecc0d42b5c9d028be47e..1ce1899bb282a4231f42570fdcf4e8a4d5e0cef5 100644 (file)
@@ -4093,6 +4093,28 @@ bool PG::_compare_scrub_objects(ScrubMap::object &auth,
   return ok;
 }
 
+
+
+map<int, ScrubMap *>::const_iterator PG::_select_auth_object(
+  const hobject_t &obj,
+  const map<int,ScrubMap*> &maps)
+{
+  map<int, ScrubMap *>::const_iterator auth = maps.end();
+  // Select first present replica
+  for (map<int, ScrubMap *>::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<int,ScrubMap*> &maps,  
                            map<hobject_t, set<int> > &missing,
                            map<hobject_t, set<int> > &inconsistent,
@@ -4114,25 +4136,21 @@ void PG::_compare_scrubmaps(const map<int,ScrubMap*> &maps,
   for (set<hobject_t>::const_iterator k = master_set.begin();
        k != master_set.end();
        k++) {
-    map<int, ScrubMap *>::const_iterator auth = maps.end();
+    map<int, ScrubMap *>::const_iterator auth = _select_auth_object(*k, maps);
+    assert(auth != maps.end());
     set<int> cur_missing;
     set<int> 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);
index 58b9de78fd5b12366be4cccf2f5209ff365967c1..b2c99b9e3f62d927e60bd22fd4100ec6b41aafd5 100644 (file)
@@ -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<int, ScrubMap *>::const_iterator _select_auth_object(
+    const hobject_t &obj,
+    const map<int,ScrubMap*> &maps);
   bool _compare_scrub_objects(ScrubMap::object &auth,
                              ScrubMap::object &candidate,
                              ostream &errorstream);