From: Sage Weil Date: Mon, 17 Apr 2017 21:48:59 +0000 (-0400) Subject: os/bluestore: use superclass for aio completions X-Git-Tag: v12.0.3~200^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7a59f60646e3efd2c5546da3a83146adfe194e33;p=ceph.git os/bluestore: use superclass for aio completions This is less fragile and more explicit than using the lower bit of the priv pointer. Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index bf9a00b26a64..3b5701ef470a 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -3267,11 +3267,8 @@ void *BlueStore::MempoolThread::entry() static void aio_cb(void *priv, void *priv2) { BlueStore *store = static_cast(priv); - if ((unsigned long long)priv2 & 0x1ull) { - store->deferred_aio_finish((void*)((unsigned long long)priv2 & ~1ull)); - } else { - store->txc_aio_finish(priv2); - } + BlueStore::AioContext *c = static_cast(priv2); + c->aio_finish(store); } BlueStore::BlueStore(CephContext *cct, const string& path) diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index af4b519fc72e..bc957d91f863 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -135,6 +135,11 @@ public: struct Collection; typedef boost::intrusive_ptr CollectionRef; + struct AioContext { + virtual void aio_finish(BlueStore *store) = 0; + virtual ~AioContext() {} + }; + /// cached buffer struct Buffer { MEMPOOL_CLASS_HELPERS(); @@ -1370,7 +1375,7 @@ public: class OpSequencer; typedef boost::intrusive_ptr OpSequencerRef; - struct TransContext { + struct TransContext : public AioContext { typedef enum { STATE_PREPARE, STATE_AIO_WAIT, @@ -1545,6 +1550,10 @@ public: onodes.erase(o); modified_objects.erase(o); } + + void aio_finish(BlueStore *store) override { + store->txc_aio_finish(this); + } }; typedef boost::intrusive::list< @@ -1554,7 +1563,8 @@ public: boost::intrusive::list_member_hook<>, &TransContext::deferred_queue_item> > deferred_queue_t; - struct DeferredBatch { + struct DeferredBatch : public AioContext { + OpSequencer *osr; struct deferred_io { bufferlist bl; ///< data uint64_t seq; ///< deferred transaction seq @@ -1569,12 +1579,16 @@ public: void _audit(CephContext *cct); DeferredBatch(CephContext *cct, OpSequencer *osr) - : ioc(cct, (void*)((unsigned long long)osr | 1ull)) {} + : osr(osr), ioc(cct, this) {} /// prepare a write void prepare_write(CephContext *cct, uint64_t seq, uint64_t offset, uint64_t length, bufferlist::const_iterator& p); + + void aio_finish(BlueStore *store) override { + store->_deferred_aio_finish(osr); + } }; class OpSequencer : public Sequencer_impl { @@ -1967,11 +1981,6 @@ private: } bluestore_deferred_op_t *_get_deferred_op(TransContext *txc, OnodeRef o); -public: - void deferred_aio_finish(void *priv) { - _deferred_aio_finish(static_cast(priv)); - } -private: void _deferred_queue(TransContext *txc); void deferred_try_submit() { std::lock_guard l(deferred_lock);