]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: move ContextWQ::queue definition to header
authorJason Dillaman <dillaman@redhat.com>
Mon, 13 Jul 2020 20:08:51 +0000 (16:08 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 15 Jul 2020 11:50:10 +0000 (07:50 -0400)
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 <dillaman@redhat.com>
src/librbd/asio/ContextWQ.cc
src/librbd/asio/ContextWQ.h

index a81fe1ada1b9d06c5d0058530887a6965b6a45e6..7d18f6f3d3651bcf4c49fd0303b7a4faa8b513d1 100644 (file)
@@ -4,8 +4,6 @@
 #include "librbd/asio/ContextWQ.h"
 #include "include/Context.h"
 #include "common/Cond.h"
-#include <boost/asio/bind_executor.hpp>
-#include <boost/asio/post.hpp>
 
 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
index be906d9ee3b722301d82cf70a82a883135888722..2fff5b52cd416783fc5bdffd7ea619eabbe5f908 100644 (file)
@@ -4,11 +4,11 @@
 #ifndef CEPH_LIBRBD_ASIO_CONTEXT_WQ_H
 #define CEPH_LIBRBD_ASIO_CONTEXT_WQ_H
 
+#include "include/Context.h"
 #include <atomic>
 #include <boost/asio/io_context.hpp>
 #include <boost/asio/io_context_strand.hpp>
-
-struct Context;
+#include <boost/asio/post.hpp>
 
 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;