]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd_types,PG: force the map used in _scrub to be sorted correctly
authorDavid Zafman <dzafman@redhat.com>
Mon, 3 Oct 2016 21:34:19 +0000 (14:34 -0700)
committerDavid Zafman <dzafman@redhat.com>
Tue, 4 Oct 2016 04:43:34 +0000 (21:43 -0700)
Previously, ScrubMap::objects was always sorted bitwise (nibblewise
before the comparator change was made.  It didn't matter because we
always scrubbed whole hash values.  Now, we need the objects in the
objectstore ordering because we may be missing objects at the tail of
the scanned range and need them to show up at the tail of the
ScrubMap::objects mapping.  We don't need to do anything else to handle
the upgrade process since the actual objects *in* the map were
determined by the objectstore ordering.

Signed-off-by: Samuel Just <sjust@redhat.com>
(cherry picked from commit 6d410e97232afdad4f226151333b209d8b50f4ed)

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

index 597f456fadd50abd8948f30b158be40fad00cf1b..c5b73247251d68e09280f1eb7c24d79820063074 100644 (file)
@@ -4078,6 +4078,8 @@ void PG::chunky_scrub(ThreadPool::TPHandle &handle)
       case PG::Scrubber::INACTIVE:
         dout(10) << "scrub start" << dendl;
 
+       scrubber.cleaned_meta_map.reset_bitwise(get_sort_bitwise());
+
         publish_stats_to_osd();
         scrubber.epoch_start = info.history.same_interval_since;
         scrubber.active = true;
@@ -4407,7 +4409,7 @@ void PG::scrub_compare_maps()
     }
   }
 
-  ScrubMap for_meta_scrub;
+  ScrubMap for_meta_scrub(get_sort_bitwise());
   if (scrubber.end.is_max() ||
       scrubber.cleaned_meta_map.objects.empty()) {
     scrubber.cleaned_meta_map.swap(for_meta_scrub);
index 7ff99cbd23b22cfb31967b0e576ec80b842ddf5c..2334b70ed33b9bfd0c98668381d7d6784adb2d3c 100644 (file)
@@ -5292,9 +5292,9 @@ void ScrubMap::decode(bufferlist::iterator& bl, int64_t pool)
 
   // handle hobject_t upgrade
   if (struct_v < 3) {
-    map<hobject_t, object, hobject_t::BitwiseComparator> tmp;
+    map<hobject_t, object, hobject_t::ComparatorWithDefault> tmp;
     tmp.swap(objects);
-    for (map<hobject_t, object, hobject_t::BitwiseComparator>::iterator i = tmp.begin();
+    for (map<hobject_t, object, hobject_t::ComparatorWithDefault>::iterator i = tmp.begin();
         i != tmp.end();
         ++i) {
       hobject_t first(i->first);
@@ -5310,7 +5310,7 @@ void ScrubMap::dump(Formatter *f) const
   f->dump_stream("valid_through") << valid_through;
   f->dump_stream("incremental_since") << incr_since;
   f->open_array_section("objects");
-  for (map<hobject_t,object, hobject_t::BitwiseComparator>::const_iterator p = objects.begin(); p != objects.end(); ++p) {
+  for (map<hobject_t,object, hobject_t::ComparatorWithDefault>::const_iterator p = objects.begin(); p != objects.end(); ++p) {
     f->open_object_section("object");
     f->dump_string("name", p->first.oid.name);
     f->dump_unsigned("hash", p->first.get_hash());
index 3ebff3dfb7955b67710ace7d6d49c71dc5714ad0..1c5d71db308bea26439589c9aaaae99cf2644b7a 100644 (file)
@@ -4056,10 +4056,15 @@ struct ScrubMap {
   };
   WRITE_CLASS_ENCODER(object)
 
-  map<hobject_t,object, hobject_t::BitwiseComparator> objects;
+  bool bitwise; // ephemeral, not encoded
+  map<hobject_t,object, hobject_t::ComparatorWithDefault> objects;
   eversion_t valid_through;
   eversion_t incr_since;
 
+  ScrubMap() : bitwise(true) {}
+  ScrubMap(bool bitwise)
+    : bitwise(bitwise), objects(hobject_t::ComparatorWithDefault(bitwise)) {}
+
   void merge_incr(const ScrubMap &l);
   void insert(const ScrubMap &r) {
     objects.insert(r.objects.begin(), r.objects.end());
@@ -4073,6 +4078,16 @@ struct ScrubMap {
   void encode(bufferlist& bl) const;
   void decode(bufferlist::iterator& bl, int64_t pool=-1);
   void dump(Formatter *f) const;
+  void reset_bitwise(bool new_bitwise) {
+    if (bitwise == new_bitwise)
+      return;
+    map<hobject_t, object, hobject_t::ComparatorWithDefault> new_objects(
+      objects.begin(),
+      objects.end(),
+      hobject_t::ComparatorWithDefault(new_bitwise));
+    ::swap(new_objects, objects);
+    bitwise = new_bitwise;
+  }
   static void generate_test_instances(list<ScrubMap*>& o);
 };
 WRITE_CLASS_ENCODER(ScrubMap::object)