From: Casey Bodley Date: Thu, 15 Feb 2024 03:49:14 +0000 (-0500) Subject: rgw/d3n: async_read() uses async_initiate X-Git-Tag: v20.0.0~1890^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0651e434893a7253a94f625976939c0ff43295f7;p=ceph.git rgw/d3n: async_read() uses async_initiate Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_d3n_cacherequest.h b/src/rgw/rgw_d3n_cacherequest.h index 2ae4e16396dec..0519c6def3e82 100644 --- a/src/rgw/rgw_d3n_cacherequest.h +++ b/src/rgw/rgw_d3n_cacherequest.h @@ -95,29 +95,33 @@ struct D3nL1CacheRequest { } }; - template - auto async_read(const DoutPrefixProvider *dpp, ExecutionContext& ctx, const std::string& location, + template + auto async_read(const DoutPrefixProvider *dpp, const Executor& ex, const std::string& location, off_t read_ofs, off_t read_len, CompletionToken&& token) { using Op = AsyncFileReadOp; using Signature = typename Op::Signature; - boost::asio::async_completion init(token); - auto p = Op::create(ctx.get_executor(), init.completion_handler); - auto& op = p->user_data; - - ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): location=" << location << dendl; - int ret = op.init_async_read(dpp, location, read_ofs, read_len, p.get()); - if(0 == ret) { - ret = ::aio_read(op.aio_cb.get()); - } - ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): ::aio_read(), ret=" << ret << dendl; - if(ret < 0) { - auto ec = boost::system::error_code{-ret, boost::system::system_category()}; - ceph::async::post(std::move(p), ec, bufferlist{}); - } else { - // coverity[leaked_storage:SUPPRESS] - (void)p.release(); - } - return init.result.get(); + return boost::asio::async_initiate( + [] (auto handler, const DoutPrefixProvider *dpp, + const Executor& ex, const std::string& location, + off_t read_ofs, off_t read_len) { + auto p = Op::create(ex, std::move(handler)); + auto& op = p->user_data; + + ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): location=" << location << dendl; + int ret = op.init_async_read(dpp, location, read_ofs, read_len, p.get()); + if(0 == ret) { + ret = ::aio_read(op.aio_cb.get()); + } + ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): ::aio_read(), ret=" << ret << dendl; + if(ret < 0) { + auto ec = boost::system::error_code{-ret, boost::system::system_category()}; + ceph::async::post(std::move(p), ec, bufferlist{}); + } else { + // coverity[leaked_storage:SUPPRESS] + (void)p.release(); + } + + }, token, dpp, ex, location, read_ofs, read_len); } struct d3n_libaio_handler { @@ -131,7 +135,7 @@ struct D3nL1CacheRequest { } }; - void file_aio_read_abstract(const DoutPrefixProvider *dpp, boost::asio::io_context& context, spawn::yield_context yield, + void file_aio_read_abstract(const DoutPrefixProvider *dpp, spawn::yield_context yield, std::string& cache_location, off_t read_ofs, off_t read_len, rgw::Aio* aio, rgw::AioResult& r) { using namespace boost::asio; @@ -139,7 +143,7 @@ struct D3nL1CacheRequest { auto ex = get_associated_executor(init.completion_handler); ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): oid=" << r.obj.oid << dendl; - async_read(dpp, context, cache_location+"/"+url_encode(r.obj.oid, true), read_ofs, read_len, bind_executor(ex, d3n_libaio_handler{aio, r})); + async_read(dpp, ex, cache_location+"/"+url_encode(r.obj.oid, true), read_ofs, read_len, bind_executor(ex, d3n_libaio_handler{aio, r})); } };