summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Dachary <loic@dachary.org>2013-08-13 17:28:31 +0200
committerLoic Dachary <loic@dachary.org>2013-08-22 02:10:59 +0200
commitd980f581e3530d28f3f690b3f4c099995d8d8ec5 (patch)
tree9204c3c485428a81516a2c9098e7850c309ee4e6
parentbd9f73d8bcd5377093845dc6cc6388af652a9081 (diff)
downloadceph-d980f581e3530d28f3f690b3f4c099995d8d8ec5.tar.gz
ReplicatedPG: create ObjectContext with SharedPtrRegistry
All new ObjectContext are replaced with calls to SharedPtrRegistry::lookup_or_create to ensure that they are all registered. Because the constructor is invoked with no argument, care is taken to always initialize the destructor_callback data member immediately afterwards. ReplicatedPG::get_object_context contains a redundant call to get_snapset_context that is removed. http://tracker.ceph.com/issues/5510 refs #5510 Signed-off-by: Loic Dachary <loic@dachary.org>
-rw-r--r--src/osd/ReplicatedPG.cc29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc
index 0998416dbb2..fcdbb182d52 100644
--- a/src/osd/ReplicatedPG.cc
+++ b/src/osd/ReplicatedPG.cc
@@ -3553,8 +3553,10 @@ void ReplicatedPG::make_writeable(OpContext *ctx)
object_info_t static_snap_oi(coid);
object_info_t *snap_oi;
if (is_primary()) {
- ctx->clone_obc = new ObjectContext(static_snap_oi, true, NULL);
- ctx->clone_obc->get();
+ ctx->clone_obc = object_contexts.lookup_or_create(static_snap_oi.soid);
+ ctx->clone_obc->destructor_callback = new C_PG_ObjectContext(this, ctx->clone_obc.get());
+ ctx->clone_obc->obs.oi = static_snap_oi;
+ ctx->clone_obc->obs.exists = true;
snap_oi = &ctx->clone_obc->obs.oi;
} else {
snap_oi = &static_snap_oi;
@@ -4491,8 +4493,15 @@ void ReplicatedPG::handle_watch_timeout(WatchRef watch)
ObjectContextRef ReplicatedPG::create_object_context(const object_info_t& oi,
SnapSetContext *ssc)
{
- ObjectContext *obc = new ObjectContext(oi, false, ssc);
- dout(10) << "create_object_context " << obc << " " << oi.soid << " " << obc->ref << dendl;
+ ObjectContextRef obc(object_contexts.lookup_or_create(oi.soid));
+ assert(obc->destructor_callback == NULL);
+ obc->destructor_callback = new C_PG_ObjectContext(this, obc.get());
+ obc->obs.oi = oi;
+ obc->obs.exists = false;
+ obc->ssc = ssc;
+ if (ssc)
+ register_snapset_context(ssc);
+ dout(10) << "create_object_context " << (void*)obc.get() << " " << oi.soid << " " << dendl;
populate_obc_watchers(obc);
return obc;
}
@@ -4521,15 +4530,15 @@ ObjectContextRef ReplicatedPG::get_object_context(const hobject_t& soid,
assert(oi.soid.pool == (int64_t)info.pgid.pool());
- SnapSetContext *ssc = NULL;
- if (can_create)
- ssc = get_snapset_context(soid.oid, soid.get_key(), soid.hash, true, soid.get_namespace());
- obc = new ObjectContext(oi, true, ssc);
+ obc = object_contexts.lookup_or_create(oi.soid);
+ obc->destructor_callback = new C_PG_ObjectContext(this, obc.get());
+ obc->obs.oi = oi;
obc->obs.exists = true;
-
- if (can_create && !obc->ssc)
+ if (can_create) {
obc->ssc = get_snapset_context(soid.oid, soid.get_key(), soid.hash, true, soid.get_namespace());
+ register_snapset_context(obc->ssc);
+ }
populate_obc_watchers(obc);
dout(10) << "get_object_context " << obc << " " << soid << " 0 -> 1 read " << obc->obs.oi << dendl;