]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: dynamically vary sort order of BackfillInterval map
authorSage Weil <sage@redhat.com>
Thu, 23 Jul 2015 20:30:19 +0000 (16:30 -0400)
committerSage Weil <sage@redhat.com>
Fri, 7 Aug 2015 14:16:05 +0000 (10:16 -0400)
We initialize all BackfillIntervals when backfill starts.  At that point we
set the Comparator order via reset().

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/PG.h
src/osd/ReplicatedPG.cc

index e907ac7dda6272cc1a6adf5bee40afa3e2f17993..ad8d117910e3332faf00c7d1847c5cb9b684c22b 100644 (file)
@@ -652,17 +652,23 @@ public:
   struct BackfillInterval {
     // info about a backfill interval on a peer
     eversion_t version; /// version at which the scan occurred
-    map<hobject_t,eversion_t, hobject_t::BitwiseComparator> objects;
+    map<hobject_t,eversion_t,hobject_t::Comparator> objects;
+    bool sort_bitwise;
     hobject_t begin;
     hobject_t end;
+
+    BackfillInterval(bool bitwise=true)
+      : objects(hobject_t::Comparator(bitwise)),
+       sort_bitwise(bitwise)
+    {}
     
     /// clear content
-    void clear() {
-      *this = BackfillInterval();
+    void clear(bool bitwise=true) {
+      *this = BackfillInterval(bitwise);
     }
 
-    void reset(hobject_t start) {
-      clear();
+    void reset(hobject_t start, bool bitwise) {
+      clear(bitwise);
       begin = end = start;
     }
 
@@ -677,7 +683,7 @@ public:
     }
 
     /// removes items <= soid and adjusts begin to the first object
-    void trim_to(const hobject_t &soid, bool sort_bitwise) {
+    void trim_to(const hobject_t &soid) {
       trim();
       while (!objects.empty() &&
             cmp(objects.begin()->first, soid, sort_bitwise) <= 0) {
@@ -705,7 +711,8 @@ public:
       f->dump_stream("begin") << begin;
       f->dump_stream("end") << end;
       f->open_array_section("objects");
-      for (map<hobject_t, eversion_t, hobject_t::BitwiseComparator>::const_iterator i = objects.begin();
+      for (map<hobject_t, eversion_t, hobject_t::Comparator>::const_iterator i =
+            objects.begin();
           i != objects.end();
           ++i) {
        f->open_object_section("object");
index c89bc35b8e7c8881c2e5fb5cbf680c4be6d0fb42..6726328c5bdd94ead028f100d74c51f0e129760d 100644 (file)
@@ -9645,12 +9645,16 @@ int ReplicatedPG::recover_backfill(
     // on_activate() was called prior to getting here
     assert(last_backfill_started == earliest_backfill());
     new_backfill = false;
+
+    // initialize BackfillIntervals (with proper sort order)
     for (set<pg_shard_t>::iterator i = backfill_targets.begin();
         i != backfill_targets.end();
         ++i) {
-      peer_backfill_info[*i].reset(peer_info[*i].last_backfill);
+      peer_backfill_info[*i].reset(peer_info[*i].last_backfill,
+                                  get_sort_bitwise());
     }
-    backfill_info.reset(last_backfill_started);
+    backfill_info.reset(last_backfill_started,
+                       get_sort_bitwise());
   }
 
   for (set<pg_shard_t>::iterator i = backfill_targets.begin();
@@ -9679,10 +9683,9 @@ int ReplicatedPG::recover_backfill(
        ++i) {
     peer_backfill_info[*i].trim_to(
       MAX_HOBJ(peer_info[*i].last_backfill, last_backfill_started,
-              get_sort_bitwise()),
-      get_sort_bitwise());
+              get_sort_bitwise()));
   }
-  backfill_info.trim_to(last_backfill_started, get_sort_bitwise());
+  backfill_info.trim_to(last_backfill_started);
 
   hobject_t backfill_pos = MIN_HOBJ(backfill_info.begin,
                                    earliest_peer_backfill(),