From: Casey Bodley Date: Thu, 9 Feb 2023 14:09:51 +0000 (-0500) Subject: Revert "spawn: use explicit strand executor" X-Git-Tag: v19.3.0~285^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ae7ee5ebab9a728e1f648dfbae1e83f9827cee0b;p=ceph.git Revert "spawn: use explicit strand executor" This reverts commit 9d9258e06b78bb47fd0156d9bd7bb00b52a726b0. Signed-off-by: Casey Bodley --- diff --git a/src/common/async/yield_context.h b/src/common/async/yield_context.h index 05e6ca6140c5..baa028fa1b4a 100644 --- a/src/common/async/yield_context.h +++ b/src/common/async/yield_context.h @@ -22,23 +22,17 @@ #include -// use explicit executor types instead of the type-erased boost::asio::executor. -// coroutines wrap the default io_context executor with a strand executor -using yield_context = spawn::basic_yield_context< - boost::asio::executor_binder>>; - /// optional-like wrapper for a spawn::yield_context and its associated /// boost::asio::io_context. operations that take an optional_yield argument /// will, when passed a non-empty yield context, suspend this coroutine instead /// of the blocking the thread of execution class optional_yield { boost::asio::io_context *c = nullptr; - yield_context *y = nullptr; + spawn::yield_context *y = nullptr; public: /// construct with a valid io and yield_context explicit optional_yield(boost::asio::io_context& c, - yield_context& y) noexcept + spawn::yield_context& y) noexcept : c(&c), y(&y) {} /// type tag to construct an empty object @@ -52,7 +46,7 @@ class optional_yield { boost::asio::io_context& get_io_context() const noexcept { return *c; } /// return a reference to the yield_context. only valid if non-empty - yield_context& get_yield_context() const noexcept { return *y; } + spawn::yield_context& get_yield_context() const noexcept { return *y; } }; // type tag object to construct an empty optional_yield diff --git a/src/rgw/driver/rados/rgw_bucket.cc b/src/rgw/driver/rados/rgw_bucket.cc index 64d8e31cc3cc..aac80909634f 100644 --- a/src/rgw/driver/rados/rgw_bucket.cc +++ b/src/rgw/driver/rados/rgw_bucket.cc @@ -584,7 +584,7 @@ int RGWBucket::check_index_olh(rgw::sal::RadosStore* const rados_store, const int max_aio = std::max(1, op_state.get_max_aio()); for (int i=0; iget_cct()->_conf, persistency_tracker, entry, yield); @@ -543,7 +543,7 @@ private: // process all queues // find which of the queues is owned by this daemon and process it - void process_queues(yield_context yield) { + void process_queues(spawn::yield_context yield) { auto has_error = false; owned_queues_t owned_queues; @@ -610,7 +610,7 @@ private: if (owned_queues.insert(queue_name).second) { ldpp_dout(this, 10) << "INFO: queue: " << queue_name << " now owned (locked) by this daemon" << dendl; // start processing this queue - spawn::spawn(io_context, [this, &queue_gc, &queue_gc_lock, queue_name](yield_context yield) { + spawn::spawn(io_context, [this, &queue_gc, &queue_gc_lock, queue_name](spawn::yield_context yield) { process_queue(queue_name, yield); // if queue processing ended, it means that the queue was removed or not owned anymore // mark it for deletion @@ -661,7 +661,7 @@ public: reservations_cleanup_period_s(_reservations_cleanup_period_s), rados_store(*store) { - spawn::spawn(io_context, [this] (yield_context yield) { + spawn::spawn(io_context, [this](spawn::yield_context yield) { process_queues(yield); }, make_stack_allocator()); diff --git a/src/rgw/driver/rados/rgw_pubsub_push.cc b/src/rgw/driver/rados/rgw_pubsub_push.cc index 05dc9e65d0ea..52bee2a16d31 100644 --- a/src/rgw/driver/rados/rgw_pubsub_push.cc +++ b/src/rgw/driver/rados/rgw_pubsub_push.cc @@ -122,7 +122,7 @@ namespace { class Waiter { using Signature = void(boost::system::error_code); using Completion = ceph::async::Completion; - using CompletionInit = boost::asio::async_completion; + using CompletionInit = boost::asio::async_completion; std::unique_ptr completion = nullptr; int ret; diff --git a/src/rgw/rgw_aio.cc b/src/rgw/rgw_aio.cc index cd85ea6d7fab..c70acae79e95 100644 --- a/src/rgw/rgw_aio.cc +++ b/src/rgw/rgw_aio.cc @@ -89,12 +89,12 @@ struct Handler { template Aio::OpFunc aio_abstract(librados::IoCtx ctx, Op&& op, boost::asio::io_context& context, - yield_context yield) { + spawn::yield_context yield) { return [ctx = std::move(ctx), op = std::move(op), &context, yield] (Aio* aio, AioResult& r) mutable { // arrange for the completion Handler to run on the yield_context's strand // executor so it can safely call back into Aio without locking using namespace boost::asio; - async_completion init(yield); + async_completion init(yield); auto ex = get_associated_executor(init.completion_handler); librados::async_operate(context, ctx, r.obj.oid, &op, 0, diff --git a/src/rgw/rgw_aio_throttle.h b/src/rgw/rgw_aio_throttle.h index 89f9c0eef649..c0656ef225e6 100644 --- a/src/rgw/rgw_aio_throttle.h +++ b/src/rgw/rgw_aio_throttle.h @@ -81,7 +81,7 @@ class BlockingAioThrottle final : public Aio, private Throttle { // functions must be called within the coroutine strand class YieldingAioThrottle final : public Aio, private Throttle { boost::asio::io_context& context; - yield_context yield; + spawn::yield_context yield; struct Handler; // completion callback associated with the waiter @@ -95,7 +95,7 @@ class YieldingAioThrottle final : public Aio, private Throttle { public: YieldingAioThrottle(uint64_t window, boost::asio::io_context& context, - yield_context yield) + spawn::yield_context yield) : Throttle(window), context(context), yield(yield) {} diff --git a/src/rgw/rgw_asio_frontend.cc b/src/rgw/rgw_asio_frontend.cc index 23ccfcafeb08..226fbe6936d7 100644 --- a/src/rgw/rgw_asio_frontend.cc +++ b/src/rgw/rgw_asio_frontend.cc @@ -76,12 +76,12 @@ class StreamIO : public rgw::asio::ClientIO { CephContext* const cct; Stream& stream; timeout_timer& timeout; - yield_context yield; + spawn::yield_context yield; parse_buffer& buffer; boost::system::error_code fatal_ec; public: StreamIO(CephContext *cct, Stream& stream, timeout_timer& timeout, - rgw::asio::parser_type& parser, yield_context yield, + rgw::asio::parser_type& parser, spawn::yield_context yield, parse_buffer& buffer, bool is_ssl, const tcp::endpoint& local_endpoint, const tcp::endpoint& remote_endpoint) @@ -207,7 +207,7 @@ void handle_connection(boost::asio::io_context& context, rgw::dmclock::Scheduler *scheduler, const std::string& uri_prefix, boost::system::error_code& ec, - yield_context yield) + spawn::yield_context yield) { // don't impose a limit on the body, since we read it in pieces static constexpr size_t body_limit = std::numeric_limits::max(); @@ -1029,7 +1029,7 @@ void AsioFrontend::accept(Listener& l, boost::system::error_code ec) #ifdef WITH_RADOSGW_BEAST_OPENSSL if (l.use_ssl) { spawn::spawn(context, - [this, s=std::move(stream)] (yield_context yield) mutable { + [this, s=std::move(stream)] (spawn::yield_context yield) mutable { auto conn = boost::intrusive_ptr{new Connection(std::move(s))}; auto c = connections.add(*conn); // wrap the tcp stream in an ssl stream @@ -1060,7 +1060,7 @@ void AsioFrontend::accept(Listener& l, boost::system::error_code ec) { #endif // WITH_RADOSGW_BEAST_OPENSSL spawn::spawn(context, - [this, s=std::move(stream)] (yield_context yield) mutable { + [this, s=std::move(stream)] (spawn::yield_context yield) mutable { auto conn = boost::intrusive_ptr{new Connection(std::move(s))}; auto c = connections.add(*conn); auto timeout = timeout_timer{context.get_executor(), request_timeout, conn}; diff --git a/src/rgw/rgw_d3n_cacherequest.h b/src/rgw/rgw_d3n_cacherequest.h index 40fc758e2eb4..2ae4e16396de 100644 --- a/src/rgw/rgw_d3n_cacherequest.h +++ b/src/rgw/rgw_d3n_cacherequest.h @@ -131,11 +131,11 @@ struct D3nL1CacheRequest { } }; - void file_aio_read_abstract(const DoutPrefixProvider *dpp, boost::asio::io_context& context, yield_context yield, + void file_aio_read_abstract(const DoutPrefixProvider *dpp, boost::asio::io_context& context, 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; - async_completion init(yield); + async_completion init(yield); auto ex = get_associated_executor(init.completion_handler); ldpp_dout(dpp, 20) << "D3nDataCache: " << __func__ << "(): oid=" << r.obj.oid << dendl; diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 0a1c3b1cf459..91aa27620284 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -7356,7 +7356,7 @@ void RGWDeleteMultiObj::execute(optional_yield y) return aio_count < max_aio; }); aio_count++; - spawn::spawn(y.get_yield_context(), [this, &y, &aio_count, obj_key, &formatter_flush_cond] (yield_context yield) { + spawn::spawn(y.get_yield_context(), [this, &y, &aio_count, obj_key, &formatter_flush_cond] (spawn::yield_context yield) { handle_individual_object(obj_key, optional_yield { y.get_io_context(), yield }, &*formatter_flush_cond); aio_count--; }); diff --git a/src/rgw/rgw_sync_checkpoint.cc b/src/rgw/rgw_sync_checkpoint.cc index 7ef6c3fc02b4..1394a712a94f 100644 --- a/src/rgw/rgw_sync_checkpoint.cc +++ b/src/rgw/rgw_sync_checkpoint.cc @@ -226,7 +226,7 @@ int rgw_bucket_sync_checkpoint(const DoutPrefixProvider* dpp, entry.pipe = pipe; // fetch remote markers - spawn::spawn(ioctx, [&] (yield_context yield) { + spawn::spawn(ioctx, [&] (spawn::yield_context yield) { auto y = optional_yield{ioctx, yield}; rgw_bucket_index_marker_info info; int r = source_bilog_info(dpp, store->svc()->zone, entry.pipe, @@ -239,7 +239,7 @@ int rgw_bucket_sync_checkpoint(const DoutPrefixProvider* dpp, entry.latest_gen = info.latest_gen; }); // fetch source bucket info - spawn::spawn(ioctx, [&] (yield_context yield) { + spawn::spawn(ioctx, [&] (spawn::yield_context yield) { auto y = optional_yield{ioctx, yield}; int r = store->getRados()->get_bucket_instance_info( *entry.pipe.source.bucket, entry.source_bucket_info, diff --git a/src/test/rgw/test_rgw_dmclock_scheduler.cc b/src/test/rgw/test_rgw_dmclock_scheduler.cc index 92800767c99a..36652d22f038 100644 --- a/src/test/rgw/test_rgw_dmclock_scheduler.cc +++ b/src/test/rgw/test_rgw_dmclock_scheduler.cc @@ -400,7 +400,7 @@ TEST(Queue, SpawnAsyncRequest) { boost::asio::io_context context; - spawn::spawn(context, [&] (yield_context yield) { + spawn::spawn(context, [&] (spawn::yield_context yield) { ClientCounters counters(g_ceph_context); AsyncScheduler queue(g_ceph_context, context, std::ref(counters), nullptr, [] (client_id client) -> ClientInfo* { diff --git a/src/test/rgw/test_rgw_reshard_wait.cc b/src/test/rgw/test_rgw_reshard_wait.cc index 06caae34adef..98b2aa235b95 100644 --- a/src/test/rgw/test_rgw_reshard_wait.cc +++ b/src/test/rgw/test_rgw_reshard_wait.cc @@ -64,7 +64,7 @@ TEST(ReshardWait, wait_yield) RGWReshardWait waiter(wait_duration); boost::asio::io_context context; - spawn::spawn(context, [&] (yield_context yield) { + spawn::spawn(context, [&] (spawn::yield_context yield) { EXPECT_EQ(0, waiter.wait(optional_yield{context, yield})); }); @@ -90,7 +90,7 @@ TEST(ReshardWait, stop_yield) boost::asio::io_context context; spawn::spawn(context, - [&] (yield_context yield) { + [&] (spawn::yield_context yield) { EXPECT_EQ(-ECANCELED, long_waiter.wait(optional_yield{context, yield})); }); @@ -133,7 +133,7 @@ TEST(ReshardWait, stop_multiple) // spawn 4 coroutines boost::asio::io_context context; { - auto async_waiter = [&] (yield_context yield) { + auto async_waiter = [&] (spawn::yield_context yield) { EXPECT_EQ(-ECANCELED, long_waiter.wait(optional_yield{context, yield})); }; spawn::spawn(context, async_waiter); diff --git a/src/test/rgw/test_rgw_throttle.cc b/src/test/rgw/test_rgw_throttle.cc index 5e18fc3c1854..e5df9f84efa1 100644 --- a/src/test/rgw/test_rgw_throttle.cc +++ b/src/test/rgw/test_rgw_throttle.cc @@ -144,7 +144,7 @@ TEST(Aio_Throttle, YieldCostOverWindow) boost::asio::io_context context; spawn::spawn(context, - [&] (yield_context yield) { + [&] (spawn::yield_context yield) { YieldingAioThrottle throttle(4, context, yield); scoped_completion op; auto c = throttle.get(obj, wait_on(op), 8, 0); @@ -167,7 +167,7 @@ TEST(Aio_Throttle, YieldingThrottleOverMax) boost::asio::io_context context; spawn::spawn(context, - [&] (yield_context yield) { + [&] (spawn::yield_context yield) { YieldingAioThrottle throttle(window, context, yield); for (uint64_t i = 0; i < total; i++) { using namespace std::chrono_literals;