From e99501f4258fdba8262f37005928efd29dec89ef Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Wed, 24 Aug 2022 17:10:17 +0800 Subject: [PATCH] crimson/os/seastore/async_cleaner: simplify GCProcess::run() Signed-off-by: Yingxin Cheng --- src/crimson/os/seastore/async_cleaner.cc | 33 ++++++++++++++---------- src/crimson/os/seastore/async_cleaner.h | 13 ---------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/crimson/os/seastore/async_cleaner.cc b/src/crimson/os/seastore/async_cleaner.cc index 1027107c0c61f..8ce1df44a5bd5 100644 --- a/src/crimson/os/seastore/async_cleaner.cc +++ b/src/crimson/os/seastore/async_cleaner.cc @@ -750,20 +750,27 @@ double AsyncCleaner::calc_gc_benefit_cost( AsyncCleaner::gc_cycle_ret AsyncCleaner::GCProcess::run() { - return seastar::do_until( - [this] { return is_stopping(); }, - [this] { - return maybe_wait_should_run( - ).then([this] { - cleaner.log_gc_state("GCProcess::run"); - - if (is_stopping()) { - return seastar::now(); - } else { - return cleaner.do_gc_cycle(); - } - }); + ceph_assert(!is_stopping()); + return seastar::repeat([this] { + if (is_stopping()) { + cleaner.log_gc_state("GCProcess::run(exit)"); + return seastar::make_ready_future( + seastar::stop_iteration::yes); + } + return seastar::futurize_invoke([this] { + if (cleaner.gc_should_run()) { + cleaner.log_gc_state("GCProcess::run(gc)"); + return cleaner.do_gc_cycle(); + } else { + cleaner.log_gc_state("GCProcess::run(block)"); + ceph_assert(!blocking); + blocking = seastar::promise<>(); + return blocking->get_future(); + } + }).then([] { + return seastar::stop_iteration::no; }); + }); } AsyncCleaner::gc_cycle_ret AsyncCleaner::do_gc_cycle() diff --git a/src/crimson/os/seastore/async_cleaner.h b/src/crimson/os/seastore/async_cleaner.h index 9d4b9f3f1cb32..a44eb709e0c3f 100644 --- a/src/crimson/os/seastore/async_cleaner.h +++ b/src/crimson/os/seastore/async_cleaner.h @@ -1153,19 +1153,6 @@ private: } } - seastar::future<> maybe_wait_should_run() { - return seastar::do_until( - [this] { - cleaner.log_gc_state("GCProcess::maybe_wait_should_run"); - return is_stopping() || cleaner.gc_should_run(); - }, - [this] { - ceph_assert(!blocking); - blocking = seastar::promise<>(); - return blocking->get_future(); - }); - } - AsyncCleaner &cleaner; std::optional process_join; std::optional> blocking; -- 2.39.5