From: Yingxin Cheng Date: Fri, 29 Apr 2022 08:32:21 +0000 (+0800) Subject: crimson/os/seastore/segment_cleaner: cleanup, drop the unnecessary stopping flag X-Git-Tag: v18.0.0~884^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d8ff107183e9cf122677cee7be3dedb1d98b38db;p=ceph.git crimson/os/seastore/segment_cleaner: cleanup, drop the unnecessary stopping flag Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/os/seastore/segment_cleaner.cc b/src/crimson/os/seastore/segment_cleaner.cc index e9251e718bd9..2c181b0fe1df 100644 --- a/src/crimson/os/seastore/segment_cleaner.cc +++ b/src/crimson/os/seastore/segment_cleaner.cc @@ -597,13 +597,13 @@ SegmentCleaner::rewrite_dirty_ret SegmentCleaner::rewrite_dirty( SegmentCleaner::gc_cycle_ret SegmentCleaner::GCProcess::run() { return seastar::do_until( - [this] { return stopping; }, + [this] { return is_stopping(); }, [this] { return maybe_wait_should_run( ).then([this] { cleaner.log_gc_state("GCProcess::run"); - if (stopping) { + if (is_stopping()) { return seastar::now(); } else { return cleaner.do_gc_cycle(); diff --git a/src/crimson/os/seastore/segment_cleaner.h b/src/crimson/os/seastore/segment_cleaner.h index dc66de43e9c4..18a1d9207e23 100644 --- a/src/crimson/os/seastore/segment_cleaner.h +++ b/src/crimson/os/seastore/segment_cleaner.h @@ -922,10 +922,12 @@ private: SegmentCleaner &cleaner; - bool stopping = false; - std::optional> blocking; + bool is_stopping() const { + return !process_join; + } + gc_cycle_ret run(); void wake() { @@ -939,7 +941,7 @@ private: return seastar::do_until( [this] { cleaner.log_gc_state("GCProcess::maybe_wait_should_run"); - return stopping || cleaner.gc_should_run(); + return is_stopping() || cleaner.gc_should_run(); }, [this] { ceph_assert(!blocking); @@ -951,23 +953,25 @@ private: GCProcess(SegmentCleaner &cleaner) : cleaner(cleaner) {} void start() { - ceph_assert(!process_join); + ceph_assert(is_stopping()); + process_join = seastar::now(); // allow run() process_join = run(); + assert(!is_stopping()); } gc_cycle_ret stop() { - if (!process_join) - return seastar::now(); - stopping = true; - wake(); - ceph_assert(process_join); + if (is_stopping()) { + return seastar::now(); + } auto ret = std::move(*process_join); - process_join = std::nullopt; - return ret.then([this] { stopping = false; }); + process_join.reset(); + assert(is_stopping()); + wake(); + return ret; } gc_cycle_ret run_until_halt() { - ceph_assert(!process_join); + ceph_assert(is_stopping()); return seastar::do_until( [this] { cleaner.log_gc_state("GCProcess::run_until_halt");