]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
PG: grab reference to pg in C_OSD_AppliedRecoveredObject
authorSamuel Just <sam.just@inktank.com>
Mon, 16 Jul 2012 22:43:47 +0000 (15:43 -0700)
committerSamuel Just <sam.just@inktank.com>
Mon, 16 Jul 2012 22:43:52 +0000 (15:43 -0700)
Otherwise, accessing the pg via _applied_recovered_object
isn't safe.  Using intrusive_ptr clarifies the reference
ownership.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osd/PG.cc
src/osd/PG.h
src/osd/ReplicatedPG.h

index 803468833a306b5eecf0e28b67289b0d7d07cc7a..1287ca1f5da93452c0df2bf0155792cf243fa72a 100644 (file)
@@ -5713,3 +5713,6 @@ bool PG::PriorSet::affected_by_map(const OSDMapRef osdmap, const PG *debug_pg) c
 
   return false;
 }
+
+void boost::intrusive_ptr_add_ref(PG *pg) { pg->get(); }
+void boost::intrusive_ptr_release(PG *pg) { pg->put(); }
index d3eda0b927dbedf8b17a7c064f7958ed02579331..1f7bb6285c7844032e3f441ea17a2b6b452e2dcb 100644 (file)
@@ -1564,4 +1564,9 @@ WRITE_CLASS_ENCODER(PG::OndiskLog)
 
 ostream& operator<<(ostream& out, const PG& pg);
 
+namespace boost {
+  void intrusive_ptr_add_ref(PG *pg);
+  void intrusive_ptr_release(PG *pg);
+};
+
 #endif
index e886b17d902fff59fba089cec0f7a667a199b7d5..fb9861b04057fa673923c3b4b391f55be34a3f08 100644 (file)
@@ -849,7 +849,7 @@ protected:
     }
   };
   struct C_OSD_AppliedRecoveredObject : public Context {
-    ReplicatedPG *pg;
+    boost::intrusive_ptr<ReplicatedPG> pg;
     ObjectStore::Transaction *t;
     ObjectContext *obc;
     C_OSD_AppliedRecoveredObject(ReplicatedPG *p, ObjectStore::Transaction *tt, ObjectContext *o) :