From: Samuel Just Date: Mon, 16 Jul 2012 22:43:47 +0000 (-0700) Subject: PG: grab reference to pg in C_OSD_AppliedRecoveredObject X-Git-Tag: v0.50~53 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3821f6c4bf2ffaf053efa12146c69c38805b798e;p=ceph.git PG: grab reference to pg in C_OSD_AppliedRecoveredObject Otherwise, accessing the pg via _applied_recovered_object isn't safe. Using intrusive_ptr clarifies the reference ownership. Signed-off-by: Samuel Just --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 803468833a306..1287ca1f5da93 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -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(); } diff --git a/src/osd/PG.h b/src/osd/PG.h index d3eda0b927dbe..1f7bb6285c784 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -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 diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index e886b17d902ff..fb9861b04057f 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -849,7 +849,7 @@ protected: } }; struct C_OSD_AppliedRecoveredObject : public Context { - ReplicatedPG *pg; + boost::intrusive_ptr pg; ObjectStore::Transaction *t; ObjectContext *obc; C_OSD_AppliedRecoveredObject(ReplicatedPG *p, ObjectStore::Transaction *tt, ObjectContext *o) :