]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/ObjectStore: ref count Sequencer_impl
authorSage Weil <sage@redhat.com>
Mon, 17 Aug 2015 19:09:29 +0000 (15:09 -0400)
committerSage Weil <sage@redhat.com>
Wed, 19 Aug 2015 21:03:54 +0000 (17:03 -0400)
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 <sage@redhat.com>
src/os/FileStore.cc
src/os/KeyValueStore.cc
src/os/ObjectStore.h

index 57bfaf32490e2f016e1a7a2842fbbec98f2ac3c8..d0ab348d6a394a7639e6d63c3fbe6e263c7d8c4f 100644 (file)
@@ -1927,7 +1927,7 @@ int FileStore::queue_transactions(Sequencer *posr, list<Transaction*> &tls,
   if (!posr)
     posr = &default_osr;
   if (posr->p) {
-    osr = static_cast<OpSequencer *>(posr->p);
+    osr = static_cast<OpSequencer *>(posr->p.get());
     dout(5) << "queue_transactions existing " << *osr << "/" << osr->parent << dendl; //<< " w/ q " << osr->q << dendl;
   } else {
     osr = new OpSequencer;
index 3bf8f33a4a68ace991e13c7d900bdd5f0d6ec1ca..fc17a8a086995f8d4d7958d943335264be657108 100644 (file)
@@ -1054,7 +1054,7 @@ int KeyValueStore::queue_transactions(Sequencer *posr, list<Transaction*> &tls,
   if (!posr)
     posr = &default_osr;
   if (posr->p) {
-    osr = static_cast<OpSequencer *>(posr->p);
+    osr = static_cast<OpSequencer *>(posr->p.get());
     dout(5) << "queue_transactions existing " << *osr << "/" << osr->parent
             << dendl; //<< " w/ q " << osr->q << dendl;
   } else {
index eeb91bd94e28890316feaddb520d8bd328cf9e9c..201ec30a083eed827528591b4b9cbf6fefeb7c30 100644 (file)
@@ -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_impl> 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