From: Jason Dillaman Date: Mon, 13 Jul 2020 20:08:51 +0000 (-0400) Subject: librbd: move ContextWQ::queue definition to header X-Git-Tag: v16.1.0~1702^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7f6341f73fae222cfd60ed232f7587c6ff2ebd7f;p=ceph.git librbd: move ContextWQ::queue definition to header The parent cache plugin uses the ContextWQ::queue method and therefore requires its definition to properly dynamically link into the librbd process. If future plugins require additional functions this can be reconsidered by using interfaces, static libraries, or moving generic functions to libcommon. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/asio/ContextWQ.cc b/src/librbd/asio/ContextWQ.cc index a81fe1ada1b9..7d18f6f3d365 100644 --- a/src/librbd/asio/ContextWQ.cc +++ b/src/librbd/asio/ContextWQ.cc @@ -4,8 +4,6 @@ #include "librbd/asio/ContextWQ.h" #include "include/Context.h" #include "common/Cond.h" -#include -#include namespace librbd { namespace asio { @@ -29,23 +27,7 @@ void ContextWQ::drain_handler(Context* ctx) { // new items might be queued while we are trying to drain, so we // might need to post the handler multiple times - boost::asio::post(m_io_context, boost::asio::bind_executor( - m_strand, [this, ctx]() { drain_handler(ctx); })); -} - -void ContextWQ::queue(Context *ctx, int r) { - ++m_queued_ops; - - // ensure all legacy ContextWQ users are dispatched sequentially for backwards - // compatibility (i.e. might not be concurrent thread-safe) - boost::asio::post(m_io_context, boost::asio::bind_executor( - m_strand, - [this, ctx, r]() { - ctx->complete(r); - - ceph_assert(m_queued_ops > 0); - --m_queued_ops; - })); + boost::asio::post(m_strand, [this, ctx]() { drain_handler(ctx); }); } } // namespace asio diff --git a/src/librbd/asio/ContextWQ.h b/src/librbd/asio/ContextWQ.h index be906d9ee3b7..2fff5b52cd41 100644 --- a/src/librbd/asio/ContextWQ.h +++ b/src/librbd/asio/ContextWQ.h @@ -4,11 +4,11 @@ #ifndef CEPH_LIBRBD_ASIO_CONTEXT_WQ_H #define CEPH_LIBRBD_ASIO_CONTEXT_WQ_H +#include "include/Context.h" #include #include #include - -struct Context; +#include namespace librbd { namespace asio { @@ -18,7 +18,19 @@ public: explicit ContextWQ(boost::asio::io_context& io_context); void drain(); - void queue(Context *ctx, int r = 0); + + void queue(Context *ctx, int r = 0) { + ++m_queued_ops; + + // ensure all legacy ContextWQ users are dispatched sequentially for + // backwards compatibility (i.e. might not be concurrent thread-safe) + boost::asio::post(m_strand, [this, ctx, r]() { + ctx->complete(r); + + ceph_assert(m_queued_ops > 0); + --m_queued_ops; + }); + } private: boost::asio::io_context& m_io_context;