From: Sage Weil Date: Mon, 17 Aug 2015 19:09:29 +0000 (-0400) Subject: os/ObjectStore: ref count Sequencer_impl X-Git-Tag: v9.1.0~324^2~31 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c76e3d6f24b9e8a49a3cc7f18ab51b43d2b8f87b;p=ceph.git os/ObjectStore: ref count Sequencer_impl This allows the implementation to have a lifecycle that extends beyond the Sequencer interface object we expose to the user. Signed-off-by: Sage Weil --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 57bfaf32490e..d0ab348d6a39 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -1927,7 +1927,7 @@ int FileStore::queue_transactions(Sequencer *posr, list &tls, if (!posr) posr = &default_osr; if (posr->p) { - osr = static_cast(posr->p); + osr = static_cast(posr->p.get()); dout(5) << "queue_transactions existing " << *osr << "/" << osr->parent << dendl; //<< " w/ q " << osr->q << dendl; } else { osr = new OpSequencer; diff --git a/src/os/KeyValueStore.cc b/src/os/KeyValueStore.cc index 3bf8f33a4a68..fc17a8a08699 100644 --- a/src/os/KeyValueStore.cc +++ b/src/os/KeyValueStore.cc @@ -1054,7 +1054,7 @@ int KeyValueStore::queue_transactions(Sequencer *posr, list &tls, if (!posr) posr = &default_osr; if (posr->p) { - osr = static_cast(posr->p); + osr = static_cast(posr->p.get()); dout(5) << "queue_transactions existing " << *osr << "/" << osr->parent << dendl; //<< " w/ q " << osr->q << dendl; } else { diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index eeb91bd94e28..201ec30a083e 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -137,7 +137,7 @@ public: * ABC for Sequencer implementation, private to the ObjectStore derived class. * created in ...::queue_transaction(s) */ - struct Sequencer_impl { + struct Sequencer_impl : public RefCountedObject { virtual void flush() = 0; /** @@ -155,20 +155,21 @@ public: Context *c ///< [in] context to call upon flush/commit ) = 0; ///< @return true if idle, false otherwise + Sequencer_impl() : RefCountedObject(0) {} virtual ~Sequencer_impl() {} }; + typedef boost::intrusive_ptr Sequencer_implRef; /** * External (opaque) sequencer implementation */ struct Sequencer { string name; - Sequencer_impl *p; + Sequencer_implRef p; Sequencer(string n) : name(n), p(NULL) {} ~Sequencer() { - delete p; } /// return a unique string identifier for this sequencer @@ -2119,6 +2120,13 @@ public: WRITE_CLASS_ENCODER(ObjectStore::Transaction) WRITE_CLASS_ENCODER(ObjectStore::Transaction::TransactionData) +static inline void intrusive_ptr_add_ref(ObjectStore::Sequencer_impl *s) { + s->get(); +} +static inline void intrusive_ptr_release(ObjectStore::Sequencer_impl *s) { + s->put(); +} + ostream& operator<<(ostream& out, const ObjectStore::Sequencer& s); #endif