From: Sage Weil Date: Tue, 4 Aug 2015 15:32:52 +0000 (-0400) Subject: osd: re-sort object_contects when the sort order changes X-Git-Tag: v9.1.0~346^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=eaa2312eb1bca0612c55a2a736a8d3fbdf9d5b14;p=ceph.git osd: re-sort object_contects when the sort order changes 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 --- diff --git a/src/common/hobject.h b/src/common/hobject.h index 01f0f2dc10e3..6ee37c612860 100644 --- a/src/common/hobject.h +++ b/src/common/hobject.h @@ -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) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index a4c8c42dea61..f4a7af0665d6 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -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) diff --git a/src/osd/PG.h b/src/osd/PG.h index 733df0e3c593..fcc6ec12d7ef 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -2205,6 +2205,7 @@ public: const vector& newacting, int acting_primary, ObjectStore::Transaction *t); void on_new_interval(); + virtual void _on_new_interval() = 0; void start_flush(ObjectStore::Transaction *t, list *on_applied, list *on_safe); diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 34684ddabd47..e810d48d23e8 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -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; diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 206e09c54423..6df8db74d490 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -992,7 +992,7 @@ protected: } // projected object info - SharedLRU object_contexts; + SharedLRU object_contexts; // map from oid.snapdir() to SnapSetContext * map 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();