]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Move creation of 'master_set' to scrub_compare_maps
authorBrad Hubbard <bhubbard@redhat.com>
Mon, 9 Oct 2017 07:24:17 +0000 (17:24 +1000)
committerNathan Cutler <ncutler@suse.com>
Thu, 3 May 2018 16:46:29 +0000 (18:46 +0200)
Moving it to scrub_compare_maps allows us to pass it to multiple
subsequently called functions.

Signed-off-by: Brad Hubbard <bhubbard@redhat.com>
(cherry picked from commit 63ef97b3db81c0c725119943c8594a4a0d12154e)

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

index 1b5107f7be71ed0fac08af3c460f0a16307021d5..70eed0fc23cdbd10a0f9b399956204d91715b9bc 100644 (file)
@@ -4859,6 +4859,30 @@ void PG::scrub_compare_maps()
   scrubber.cleaned_meta_map.insert(scrubber.primary_scrubmap);
   map<hobject_t, pair<uint32_t, uint32_t>> missing_digest;
 
+  map<pg_shard_t, ScrubMap *> maps;
+  maps[pg_whoami] = &scrubber.primary_scrubmap;
+
+  for (set<pg_shard_t>::iterator i = actingbackfill.begin();
+       i != actingbackfill.end();
+       ++i) {
+    if (*i == pg_whoami) continue;
+    dout(2) << __func__ << " replica " << *i << " has "
+            << scrubber.received_maps[*i].objects.size()
+            << " items" << dendl;
+    maps[*i] = &scrubber.received_maps[*i];
+  }
+
+  map<hobject_t,ScrubMap::object>::const_iterator i;
+  map<pg_shard_t, ScrubMap *>::const_iterator j;
+  set<hobject_t> master_set;
+
+  // Construct master set
+  for (j = maps.begin(); j != maps.end(); ++j) {
+    for (i = j->second->objects.begin(); i != j->second->objects.end(); ++i) {
+      master_set.insert(i->first);
+    }
+  }
+
   if (acting.size() > 1) {
     dout(10) << __func__ << "  comparing replica scrub maps" << dendl;
 
@@ -4866,24 +4890,13 @@ void PG::scrub_compare_maps()
 
     // Map from object with errors to good peer
     map<hobject_t, list<pg_shard_t>> authoritative;
-    map<pg_shard_t, ScrubMap *> maps;
 
     dout(2) << __func__ << "   osd." << acting[0] << " has "
            << scrubber.primary_scrubmap.objects.size() << " items" << dendl;
-    maps[pg_whoami] = &scrubber.primary_scrubmap;
-
-    for (set<pg_shard_t>::iterator i = actingbackfill.begin();
-        i != actingbackfill.end();
-        ++i) {
-      if (*i == pg_whoami) continue;
-      dout(2) << __func__ << " replica " << *i << " has "
-             << scrubber.received_maps[*i].objects.size()
-             << " items" << dendl;
-      maps[*i] = &scrubber.received_maps[*i];
-    }
 
     get_pgbackend()->be_compare_scrubmaps(
       maps,
+      master_set,
       state_test(PG_STATE_REPAIR),
       scrubber.missing,
       scrubber.inconsistent,
index 673ff89390382f0f9e190d18819ed9359f0db56d..07433d68f56706cb181a7be0c6acf4a2a50168c5 100644 (file)
@@ -934,6 +934,7 @@ out:
 
 void PGBackend::be_compare_scrubmaps(
   const map<pg_shard_t,ScrubMap*> &maps,
+  const set<hobject_t> &master_set,
   bool repair,
   map<hobject_t, set<pg_shard_t>> &missing,
   map<hobject_t, set<pg_shard_t>> &inconsistent,
@@ -945,18 +946,8 @@ void PGBackend::be_compare_scrubmaps(
   const vector<int> &acting,
   ostream &errorstream)
 {
-  map<hobject_t,ScrubMap::object>::const_iterator i;
-  map<pg_shard_t, ScrubMap *>::const_iterator j;
-  set<hobject_t> master_set;
   utime_t now = ceph_clock_now();
 
-  // Construct master set
-  for (j = maps.begin(); j != maps.end(); ++j) {
-    for (i = j->second->objects.begin(); i != j->second->objects.end(); ++i) {
-      master_set.insert(i->first);
-    }
-  }
-
   // Check maps against master set and each other
   for (set<hobject_t>::const_iterator k = master_set.begin();
        k != master_set.end();
@@ -989,7 +980,7 @@ void PGBackend::be_compare_scrubmaps(
     set<pg_shard_t> cur_missing;
     set<pg_shard_t> cur_inconsistent;
 
-    for (j = maps.begin(); j != maps.end(); ++j) {
+    for (auto  j = maps.cbegin(); j != maps.cend(); ++j) {
       if (j == auth)
        shard_map[auth->first].selected_oi = true;
       if (j->second->objects.count(*k)) {
index cb8a1115c06f6e7892930f71934c5cc205ec1a0a..d0ff7296478d41af7e931d85bfc3fb2ae9f691e4 100644 (file)
@@ -577,6 +577,7 @@ typedef ceph::shared_ptr<const OSDMap> OSDMapRef;
      inconsistent_obj_wrapper &object_error);
    void be_compare_scrubmaps(
      const map<pg_shard_t,ScrubMap*> &maps,
+     const set<hobject_t> &master_set,
      bool repair,
      map<hobject_t, set<pg_shard_t>> &missing,
      map<hobject_t, set<pg_shard_t>> &inconsistent,