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 <sam.just@inktank.com>
This commit is contained in:
Samuel Just 2012-07-16 15:43:47 -07:00
parent d4410e4ad5
commit 3821f6c4bf
3 changed files with 9 additions and 1 deletions

View File

@ -5713,3 +5713,6 @@ bool PG::PriorSet::affected_by_map(const OSDMapRef osdmap, const PG *debug_pg) c
return false; return false;
} }
void boost::intrusive_ptr_add_ref(PG *pg) { pg->get(); }
void boost::intrusive_ptr_release(PG *pg) { pg->put(); }

View File

@ -1564,4 +1564,9 @@ WRITE_CLASS_ENCODER(PG::OndiskLog)
ostream& operator<<(ostream& out, const PG& pg); ostream& operator<<(ostream& out, const PG& pg);
namespace boost {
void intrusive_ptr_add_ref(PG *pg);
void intrusive_ptr_release(PG *pg);
};
#endif #endif

View File

@ -849,7 +849,7 @@ protected:
} }
}; };
struct C_OSD_AppliedRecoveredObject : public Context { struct C_OSD_AppliedRecoveredObject : public Context {
ReplicatedPG *pg; boost::intrusive_ptr<ReplicatedPG> pg;
ObjectStore::Transaction *t; ObjectStore::Transaction *t;
ObjectContext *obc; ObjectContext *obc;
C_OSD_AppliedRecoveredObject(ReplicatedPG *p, ObjectStore::Transaction *tt, ObjectContext *o) : C_OSD_AppliedRecoveredObject(ReplicatedPG *p, ObjectStore::Transaction *tt, ObjectContext *o) :