diff options
author | Loic Dachary <loic@dachary.org> | 2013-08-13 16:40:06 +0200 |
---|---|---|
committer | Loic Dachary <loic@dachary.org> | 2013-08-22 02:10:59 +0200 |
commit | 833a225008115ef87884791dafa3797dbae9f9fd (patch) | |
tree | d8e57b557f599d07f8692813a40068926f9e3176 | |
parent | 8c745944c9984414a3787c044ebd62c6efbd9e30 (diff) | |
download | ceph-833a225008115ef87884791dafa3797dbae9f9fd.tar.gz |
ReplicatedPG: replace map iterators with SharedPtrRegistry::get_next
SharedPtrRegistry does not provide an iterator equivalent to
map<hobject_t, ObjectContext*>::iterator i
It is replaced with a thread safe get_next method roughly used
as follows:
pair<hobject_t, ObjectContextRef> i;
while (object_contexts.get_next(i.first, &i))
All occurences of the iterator are replaced with get_next style
traversal.
http://tracker.ceph.com/issues/5510 refs #5510
Signed-off-by: Loic Dachary <loic@dachary.org>
-rw-r--r-- | src/osd/ReplicatedPG.cc | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 54d5d3a2265..6c81997c931 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4329,11 +4329,10 @@ void ReplicatedPG::repop_ack(RepGather *repop, int result, int ack_type, void ReplicatedPG::get_watchers(list<obj_watch_item_t> &pg_watchers) { - for (map<hobject_t, ObjectContext*>::iterator i = object_contexts.begin(); - i != object_contexts.end(); - ++i) { - i->second->get(); - get_obc_watchers(i->second, pg_watchers); + pair<hobject_t, ObjectContextRef> i; + while (object_contexts.get_next(i.first, &i)) { + ObjectContextRef obc(i.second); + get_obc_watchers(obc, pg_watchers); } } @@ -4361,12 +4360,9 @@ void ReplicatedPG::get_obc_watchers(ObjectContextRef obc, list<obj_watch_item_t> void ReplicatedPG::check_blacklisted_watchers() { dout(20) << "ReplicatedPG::check_blacklisted_watchers for pg " << get_pgid() << dendl; - for (map<hobject_t, ObjectContext*>::iterator i = object_contexts.begin(); - i != object_contexts.end(); - ++i) { - i->second->get(); - check_blacklisted_obc_watchers(i->second); - } + pair<hobject_t, ObjectContextRef> i; + while (object_contexts.get_next(i.first, &i)) + check_blacklisted_obc_watchers(i.second); } void ReplicatedPG::check_blacklisted_obc_watchers(ObjectContextRef obc) @@ -4546,23 +4542,18 @@ ObjectContextRef ReplicatedPG::get_object_context(const hobject_t& soid, void ReplicatedPG::context_registry_on_change() { - list<ObjectContext *> contexts; - for (map<hobject_t, ObjectContext*>::iterator i = object_contexts.begin(); - i != object_contexts.end(); - ++i) { - i->second->get(); - contexts.push_back(i->second); - for (map<pair<uint64_t, entity_name_t>, WatchRef>::iterator j = - i->second->watchers.begin(); - j != i->second->watchers.end(); - i->second->watchers.erase(j++)) { - j->second->discard(); + pair<hobject_t, ObjectContextRef> i; + while (object_contexts.get_next(i.first, &i)) { + ObjectContextRef obc(i.second); + if (obc) { + for (map<pair<uint64_t, entity_name_t>, WatchRef>::iterator j = + obc->watchers.begin(); + j != obc->watchers.end(); + obc->watchers.erase(j++)) { + j->second->discard(); + } } } - for (list<ObjectContext *>::iterator i = contexts.begin(); - i != contexts.end(); - contexts.erase(i++)) { - } } |