]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ReplicatedPG: add Context to cleanup the PG after an ObjectContext deletion
authorLoic Dachary <loic@dachary.org>
Tue, 13 Aug 2013 14:52:18 +0000 (16:52 +0200)
committerLoic Dachary <loic@dachary.org>
Thu, 22 Aug 2013 00:10:59 +0000 (02:10 +0200)
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 <loic@dachary.org>
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h

index 6c81997c93148dfbb14abd48685ad654877dc6cc..a1bba507033a4633e1dcf5cdee14208af3d22984 100644 (file)
@@ -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;
 
index 133be172a98e5cbd3e46e157261f7b08cd9e88f7..0fbe5afd9caca9a3b0708159a884a177894d728a 100644 (file)
@@ -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);