From 95349c028ef049e28f651773cbf28f49a872013c Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Tue, 13 Aug 2013 16:52:18 +0200 Subject: [PATCH] ReplicatedPG: add Context to cleanup the PG after an ObjectContext deletion ReplicatedPG::C_PG_ObjectContext is added to encapsulate a call to ReplicatedPG::object_context_destructor_callback method which is reponsible for * manually de-allocating the SnapSetContext of the ObjectContext if any. It will eventually be managed by a SharedPtrRegistry. ReplicatedPG::C_PG_ObjectContext must be added to the destructor_callback member of ObjectContext immediately after it is created. http://tracker.ceph.com/issues/5510 refs #5510 Signed-off-by: Loic Dachary --- src/osd/ReplicatedPG.cc | 11 ++++++++++- src/osd/ReplicatedPG.h | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 6c81997c93148..a1bba507033a4 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4678,7 +4678,16 @@ int ReplicatedPG::find_object_context(const hobject_t& oid, } } -void ReplicatedPG::add_object_context_to_pg_stat(ObjectContext *obc, pg_stat_t *pgstat) +void ReplicatedPG::object_context_destructor_callback(ObjectContext *obc) +{ + dout(10) << "object_context_destructor_callback " << obc << " " + << obc->obs.oi.soid << dendl; + + if (obc->ssc) + put_snapset_context(obc->ssc); +} + +void ReplicatedPG::add_object_context_to_pg_stat(ObjectContextRef obc, pg_stat_t *pgstat) { object_info_t& oi = obc->obs.oi; diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 133be172a98e5..0fbe5afd9caca 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -302,6 +302,17 @@ protected: ObjectContextRef get_object_context(const hobject_t& soid, bool can_create); void context_registry_on_change(); + void object_context_destructor_callback(ObjectContext *obc); + struct C_PG_ObjectContext : public Context { + ReplicatedPGRef pg; + ObjectContext *obc; + C_PG_ObjectContext(ReplicatedPG *p, ObjectContext *o) : + pg(p), obc(o) {} + void finish(int r) { + pg->object_context_destructor_callback(obc); + } + }; + int find_object_context(const hobject_t& oid, ObjectContextRef *pobc, bool can_create, snapid_t *psnapid=NULL); -- 2.39.5