diff options
author | Patrick Donnelly <pdonnell@redhat.com> | 2019-02-06 23:48:57 +0100 |
---|---|---|
committer | Kefu Chai <tchaikov@gmail.com> | 2019-09-16 13:53:58 +0200 |
commit | 517bdca529db390e7ebc4e596570f80522060485 (patch) | |
tree | 3d7c2376b36f61ea8e85e97f6de515ccf6d6d4a1 /src/os/memstore/MemStore.h | |
parent | common: add make_ref factory for RefCountedObject (diff) | |
download | ceph-517bdca529db390e7ebc4e596570f80522060485.tar.xz ceph-517bdca529db390e7ebc4e596570f80522060485.zip |
common/RefCountedObj: cleanup con/des
Also, don't allow children to set nref (to 0). This is the more significant
change as it required fixing various code to not do this:
<reftype> ptr = new RefCountedObjectFoo(..., 0);
as a way to create a starting reference with nref==1. This is a pretty
bad code smell so I've converted all the code doing this to use the new
factory method which produces the reference safely:
auto ptr = ceph::make_ref<RefCountedObjectFoo>(...);
libradosstriper was particularly egregious in its abuse of setting the starting
nref. :(
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
Diffstat (limited to 'src/os/memstore/MemStore.h')
-rw-r--r-- | src/os/memstore/MemStore.h | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/os/memstore/MemStore.h b/src/os/memstore/MemStore.h index ec7cf53b501..55f55ee4bfa 100644 --- a/src/os/memstore/MemStore.h +++ b/src/os/memstore/MemStore.h @@ -36,11 +36,8 @@ public: bufferlist omap_header; map<string,bufferlist> omap; - typedef boost::intrusive_ptr<Object> Ref; - friend void intrusive_ptr_add_ref(Object *o) { o->get(); } - friend void intrusive_ptr_release(Object *o) { o->put(); } + using Ref = ceph::ref_t<Object>; - Object() : RefCountedObject(nullptr, 0) {} // interface for object data virtual size_t get_size() const = 0; virtual int read(uint64_t offset, uint64_t len, bufferlist &bl) = 0; @@ -90,8 +87,10 @@ public: } f->close_section(); } + protected: + Object() = default; }; - typedef Object::Ref ObjectRef; + using ObjectRef = Object::Ref; struct PageSetObject; struct Collection : public CollectionImpl { @@ -110,8 +109,6 @@ public: ceph::make_mutex("MemStore::Collection::sequencer_mutex")}; typedef boost::intrusive_ptr<Collection> Ref; - friend void intrusive_ptr_add_ref(Collection *c) { c->get(); } - friend void intrusive_ptr_release(Collection *c) { c->put(); } ObjectRef create_object() const; @@ -184,8 +181,10 @@ public: return true; } + private: + FRIEND_MAKE_REF(Collection); explicit Collection(CephContext *cct, coll_t c) - : CollectionImpl(c), + : CollectionImpl(cct, c), cct(cct), use_page_set(cct->_conf->memstore_page_set) {} }; |