From: Casey Bodley Date: Tue, 11 Aug 2015 18:38:06 +0000 (-0400) Subject: memstore: use intrusive_ptr instead of shared_ptr X-Git-Tag: v9.1.0~253^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=26f716e949a0e522b17085faf324c3fe6af69092;p=ceph.git memstore: use intrusive_ptr instead of shared_ptr Signed-off-by: Casey Bodley --- diff --git a/src/os/MemStore.h b/src/os/MemStore.h index 477e8fde63e..a3bed1cbad1 100644 --- a/src/os/MemStore.h +++ b/src/os/MemStore.h @@ -16,21 +16,28 @@ #ifndef CEPH_MEMSTORE_H #define CEPH_MEMSTORE_H +#include + #include "include/assert.h" #include "include/unordered_map.h" #include "include/memory.h" #include "common/Finisher.h" +#include "common/RefCountedObj.h" #include "common/RWLock.h" #include "ObjectStore.h" class MemStore : public ObjectStore { public: - struct Object { + struct Object : public RefCountedObject { bufferlist data; map xattr; bufferlist omap_header; map omap; + typedef boost::intrusive_ptr Ref; + friend void intrusive_ptr_add_ref(Object *o) { o->get(); } + friend void intrusive_ptr_release(Object *o) { o->put(); } + void encode(bufferlist& bl) const { ENCODE_START(1, 1, bl); ::encode(data, bl); @@ -74,14 +81,18 @@ public: f->close_section(); } }; - typedef ceph::shared_ptr ObjectRef; + typedef Object::Ref ObjectRef; - struct Collection { + struct Collection : public RefCountedObject { ceph::unordered_map object_hash; ///< for lookup map object_map; ///< for iteration map xattr; RWLock lock; ///< for object_{map,hash} + typedef boost::intrusive_ptr Ref; + friend void intrusive_ptr_add_ref(Collection *c) { c->get(); } + friend void intrusive_ptr_release(Collection *c) { c->put(); } + // NOTE: The lock only needs to protect the object_map/hash, not the // contents of individual objects. The osd is already sequencing // reads and writes, so we will never see them concurrently at this @@ -136,7 +147,7 @@ public: Collection() : lock("MemStore::Collection::lock") {} }; - typedef ceph::shared_ptr CollectionRef; + typedef Collection::Ref CollectionRef; private: class OmapIteratorImpl : public ObjectMap::ObjectMapIteratorImpl {