]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore/segment_cleaner: cleanup, drop the unnecessary stopping flag
authorYingxin Cheng <yingxin.cheng@intel.com>
Fri, 29 Apr 2022 08:32:21 +0000 (16:32 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 13 May 2022 07:51:19 +0000 (15:51 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/segment_cleaner.cc
src/crimson/os/seastore/segment_cleaner.h

index e9251e718bd9311bce7a686f2c91cd948e72956d..2c181b0fe1df6cc96148f6d63e82634d89bfb5dc 100644 (file)
@@ -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();
index dc66de43e9c4edd7f7abe03f03144e47baa85a41..18a1d9207e23a551b4bb83598881b085ff2a5f1c 100644 (file)
@@ -922,10 +922,12 @@ private:
 
     SegmentCleaner &cleaner;
 
-    bool stopping = false;
-
     std::optional<seastar::promise<>> 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");