]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/d4n: SSDDriver uses async_initiate
authorCasey Bodley <cbodley@redhat.com>
Tue, 23 Apr 2024 16:04:22 +0000 (12:04 -0400)
committerCasey Bodley <cbodley@redhat.com>
Mon, 13 May 2024 16:13:39 +0000 (12:13 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_ssd_driver.cc
src/rgw/rgw_ssd_driver.h

index 5c6d8aa7281d8f2849b4a23b2800873b886976a2..24726ebcf62e1713e6407a5f036344477a23f720 100644 (file)
@@ -99,9 +99,12 @@ int SSDDriver::put(const DoutPrefixProvider* dpp, const std::string& key, const
     if (y) {
         using namespace boost::asio;
         spawn::yield_context yield = y.get_yield_context();
-        this->put_async(dpp, y.get_io_context(), key, bl, len, attrs, yield[ec]);
+        async_completion<spawn::yield_context, void()> init(yield);
+        auto ex = get_associated_executor(init.completion_handler);
+        this->put_async(dpp, ex, key, bl, len, attrs, yield[ec]);
     } else {
-        this->put_async(dpp, y.get_io_context(), key, bl, len, attrs, ceph::async::use_blocked[ec]);
+      auto ex = boost::asio::system_executor{};
+      this->put_async(dpp, ex, key, bl, len, attrs, ceph::async::use_blocked[ec]);
     }
     if (ec) {
         return ec.value();
@@ -199,19 +202,22 @@ auto SSDDriver::AsyncWriteRequest::create(const Executor1& ex1, CompletionHandle
     return p;
 }
 
-template <typename ExecutionContext, typename CompletionToken>
-auto SSDDriver::get_async(const DoutPrefixProvider *dpp, ExecutionContext& ctx, const std::string& key,
+template <typename Executor, typename CompletionToken>
+auto SSDDriver::get_async(const DoutPrefixProvider *dpp, const Executor& ex, const std::string& key,
                 off_t read_ofs, off_t read_len, CompletionToken&& token)
 {
+  using Op = AsyncReadOp;
+  using Signature = typename Op::Signature;
+  return boost::asio::async_initiate<CompletionToken, Signature>(
+      [this] (auto handler, const DoutPrefixProvider *dpp,
+              const Executor& ex, const std::string& key,
+              off_t read_ofs, off_t read_len) {
+    auto p = Op::create(ex, handler);
+    auto& op = p->user_data;
+
     std::string location = partition_info.location + key;
     ldpp_dout(dpp, 20) << "SSDCache: " << __func__ << "(): location=" << location << dendl;
 
-    using Op = AsyncReadOp;
-    using Signature = typename Op::Signature;
-    boost::asio::async_completion<CompletionToken, Signature> init(token);
-    auto p = Op::create(ctx.get_executor(), init.completion_handler);
-    auto& op = p->user_data;
-
     int ret = op.prepare_libaio_read_op(dpp, location, read_ofs, read_len, p.get());
     if(0 == ret) {
         ret = ::aio_read(op.aio_cb.get());
@@ -223,23 +229,25 @@ auto SSDDriver::get_async(const DoutPrefixProvider *dpp, ExecutionContext& ctx,
     } else {
         (void)p.release();
     }
-    ldpp_dout(dpp, 20) << "SSDCache: " << __func__ << "(): Before init.result.get()" << ret << dendl;
-    return init.result.get();
+  }, token, dpp, ex, key, read_ofs, read_len);
 }
 
-template <typename ExecutionContext, typename CompletionToken>
-void SSDDriver::put_async(const DoutPrefixProvider *dpp, ExecutionContext& ctx, const std::string& key,
+template <typename Executor, typename CompletionToken>
+void SSDDriver::put_async(const DoutPrefixProvider *dpp, const Executor& ex, const std::string& key,
                 const bufferlist& bl, uint64_t len, const rgw::sal::Attrs& attrs, CompletionToken&& token)
 {
+  using Op = AsyncWriteRequest;
+  using Signature = typename Op::Signature;
+  return boost::asio::async_initiate<CompletionToken, Signature>(
+      [this] (auto handler, const DoutPrefixProvider *dpp,
+              const Executor& ex, const std::string& key, const bufferlist& bl,
+              uint64_t len, const rgw::sal::Attrs& attrs) {
+    auto p = Op::create(ex, handler);
+    auto& op = p->user_data;
+
     std::string location = partition_info.location + key;
     ldpp_dout(dpp, 20) << "SSDCache: " << __func__ << "(): location=" << location << dendl;
 
-    using Op = AsyncWriteRequest;
-    using Signature = typename Op::Signature;
-    boost::asio::async_completion<CompletionToken, Signature> init(token);
-    auto p = Op::create(ctx.get_executor(), init.completion_handler);
-    auto& op = p->user_data;
-
     int r = 0;
     bufferlist src = bl;
     std::string temp_key = key + "_" + std::to_string(index++);
@@ -267,7 +275,7 @@ void SSDDriver::put_async(const DoutPrefixProvider *dpp, ExecutionContext& ctx,
     } else {
         (void)p.release();
     }
-    init.result.get();
+  }, token, dpp, ex, key, bl, len, attrs);
 }
 
 rgw::Aio::OpFunc SSDDriver::ssd_cache_read_op(const DoutPrefixProvider *dpp, optional_yield y, rgw::cache::CacheDriver* cache_driver,
@@ -282,7 +290,7 @@ rgw::Aio::OpFunc SSDDriver::ssd_cache_read_op(const DoutPrefixProvider *dpp, opt
     auto ex = get_associated_executor(init.completion_handler);
 
     ldpp_dout(dpp, 20) << "SSDCache: " << __func__ << "(): key=" << key << dendl;
-    this->get_async(dpp, y.get_io_context(), key, read_ofs, read_len, bind_executor(ex, SSDDriver::libaio_read_handler{aio, r}));
+    this->get_async(dpp, ex, key, read_ofs, read_len, bind_executor(ex, SSDDriver::libaio_read_handler{aio, r}));
   };
 }
 
@@ -298,7 +306,7 @@ rgw::Aio::OpFunc SSDDriver::ssd_cache_write_op(const DoutPrefixProvider *dpp, op
     auto ex = get_associated_executor(init.completion_handler);
 
     ldpp_dout(dpp, 20) << "SSDCache: " << __func__ << "(): key=" << key << dendl;
-    this->put_async(dpp, y.get_io_context(), key, bl, len, attrs, bind_executor(ex, SSDDriver::libaio_write_handler{aio, r}));
+    this->put_async(dpp, ex, key, bl, len, attrs, bind_executor(ex, SSDDriver::libaio_write_handler{aio, r}));
   };
 }
 
index d142467b8a79e188dcb9d8e884de24e8474bdef6..9b2b4edb26a8feac8f03f3d1f0aad84a457e118c 100644 (file)
@@ -70,12 +70,12 @@ private:
     }
   };
 
-  template <typename ExecutionContext, typename CompletionToken>
-    auto get_async(const DoutPrefixProvider *dpp, ExecutionContext& ctx, const std::string& key,
+  template <typename Executor, typename CompletionToken>
+    auto get_async(const DoutPrefixProvider *dpp, const Executor& ex, const std::string& key,
                    off_t read_ofs, off_t read_len, CompletionToken&& token);
   
-  template <typename ExecutionContext, typename CompletionToken>
-  void put_async(const DoutPrefixProvider *dpp, ExecutionContext& ctx, const std::string& key,
+  template <typename Executor, typename CompletionToken>
+  void put_async(const DoutPrefixProvider *dpp, const Executor& ex, const std::string& key,
                   const bufferlist& bl, uint64_t len, const rgw::sal::Attrs& attrs, CompletionToken&& token);
   
   rgw::Aio::OpFunc ssd_cache_read_op(const DoutPrefixProvider *dpp, optional_yield y, rgw::cache::CacheDriver* cache_driver,