]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: re-sort object_contects when the sort order changes
authorSage Weil <sage@redhat.com>
Tue, 4 Aug 2015 15:32:52 +0000 (11:32 -0400)
committerSage Weil <sage@redhat.com>
Fri, 7 Aug 2015 14:17:35 +0000 (10:17 -0400)
Scrub uses the object_contexts sort order to check whether it is
safe to extend the scrub interval (verifying there aren't ops in
flight).  For this to work we need to use the correct sort order
for the object_context map (as seen by SharedLRU<>::get_next()).

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

index 01f0f2dc10e3de09743eb6b66ea548c01737cf3e..6ee37c612860ceed62e4d872ec32ce92cc728761 100644 (file)
@@ -284,6 +284,16 @@ public:
        return cmp_nibblewise(l, r) < 0;
     }
   };
+  struct ComparatorWithDefault {
+    bool bitwise;
+    ComparatorWithDefault(bool b=true) : bitwise(b) {}
+    bool operator()(const hobject_t& l, const hobject_t& r) const {
+      if (bitwise)
+       return cmp_bitwise(l, r) < 0;
+      else
+       return cmp_nibblewise(l, r) < 0;
+    }
+  };
 };
 WRITE_CLASS_ENCODER(hobject_t)
 
index a4c8c42dea6196a7db8b3d8ef136b9fe33ffa47b..f4a7af0665d613c7cf01b775a2122a312ebe54c4 100644 (file)
@@ -4848,6 +4848,8 @@ void PG::on_new_interval()
   } else {
     randomly_sort_nibblewise = false;
   }
+
+  _on_new_interval();
 }
 
 void PG::proc_primary_info(ObjectStore::Transaction &t, const pg_info_t &oinfo)
index 733df0e3c593dd7139dd26c62db8db51d7b75f12..fcc6ec12d7ef4ffbe87d3f3e14fef0fb22808b96 100644 (file)
@@ -2205,6 +2205,7 @@ public:
     const vector<int>& newacting, int acting_primary,
     ObjectStore::Transaction *t);
   void on_new_interval();
+  virtual void _on_new_interval() = 0;
   void start_flush(ObjectStore::Transaction *t,
                   list<Context *> *on_applied,
                   list<Context *> *on_safe);
index 34684ddabd4722c0fcdb759e3b1f9ab5dcd6cca4..e810d48d23e8142ede3afb7cc61c683a31c2da70 100644 (file)
@@ -8873,6 +8873,16 @@ void ReplicatedPG::on_activate()
   agent_setup();
 }
 
+void ReplicatedPG::_on_new_interval()
+{
+  // re-sort obc map?
+  if (object_contexts.get_comparator().bitwise != get_sort_bitwise()) {
+    dout(20) << __func__ << " resorting object_contexts" << dendl;
+    object_contexts.reset_comparator(
+      hobject_t::ComparatorWithDefault(get_sort_bitwise()));
+  }
+}
+
 void ReplicatedPG::on_change(ObjectStore::Transaction *t)
 {
   dout(10) << "on_change" << dendl;
index 206e09c544236f42460b8e36848c97542c96c41f..6df8db74d49069b42330cd9dcb56dc9ac35911ab 100644 (file)
@@ -992,7 +992,7 @@ protected:
   }
 
   // projected object info
-  SharedLRU<hobject_t, ObjectContext, hobject_t::BitwiseComparator> object_contexts;
+  SharedLRU<hobject_t, ObjectContext, hobject_t::ComparatorWithDefault> object_contexts;
   // map from oid.snapdir() to SnapSetContext *
   map<hobject_t, SnapSetContext*, hobject_t::BitwiseComparator> snapset_contexts;
   Mutex snapset_contexts_lock;
@@ -1544,6 +1544,7 @@ public:
 
   void on_role_change();
   void on_pool_change();
+  void _on_new_interval();
   void on_change(ObjectStore::Transaction *t);
   void on_activate();
   void on_flushed();