From 8dff96508975845626a4a0075ba0e4da33812a4a Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Wed, 24 Aug 2022 16:29:33 +0800 Subject: [PATCH] crimson/os/seastore/async_cleaner: sort GCProcess interfaces Signed-off-by: Yingxin Cheng --- src/crimson/os/seastore/async_cleaner.h | 76 ++++++++++++------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/crimson/os/seastore/async_cleaner.h b/src/crimson/os/seastore/async_cleaner.h index b431cb11897..9d4b9f3f1cb 100644 --- a/src/crimson/os/seastore/async_cleaner.h +++ b/src/crimson/os/seastore/async_cleaner.h @@ -1086,38 +1086,6 @@ private: */ using gc_cycle_ret = seastar::future<>; class GCProcess { - std::optional process_join; - - AsyncCleaner &cleaner; - - std::optional> blocking; - - bool is_stopping() const { - return !process_join; - } - - gc_cycle_ret run(); - - void wake() { - if (blocking) { - blocking->set_value(); - blocking = std::nullopt; - } - } - - 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(); - }); - } - bool is_running_until_halt = false; public: GCProcess(AsyncCleaner &cleaner) : cleaner(cleaner) {} @@ -1128,6 +1096,15 @@ private: assert(!is_stopping()); } + void maybe_wake_on_space_used() { + if (is_stopping()) { + return; + } + if (cleaner.gc_should_run()) { + wake(); + } + } + gc_cycle_ret stop() { if (is_stopping()) { return seastar::now(); @@ -1162,14 +1139,37 @@ private: ); } - void maybe_wake_on_space_used() { - if (is_stopping()) { - return; - } - if (cleaner.gc_should_run()) { - wake(); + private: + bool is_stopping() const { + return !process_join; + } + + gc_cycle_ret run(); + + void wake() { + if (blocking) { + blocking->set_value(); + blocking = std::nullopt; } } + + 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; + bool is_running_until_halt = false; } gc_process; using gc_ertr = work_ertr::extend_ertr< -- 2.39.5