]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/async_cleaner: simplify GCProcess::run()
authorYingxin Cheng <yingxin.cheng@intel.com>
Wed, 24 Aug 2022 09:10:17 +0000 (17:10 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 26 Aug 2022 09:47:30 +0000 (17:47 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/async_cleaner.cc
src/crimson/os/seastore/async_cleaner.h

index 1027107c0c61ff279eea0798667d83123ccd0f70..8ce1df44a5bd503c4981ead9b2d9e1234778f875 100644 (file)
@@ -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>(
+          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()
index 9d4b9f3f1cb329eb85f5051f0518e35587dde05b..a44eb709e0c3f683386b508068347a0edfb4c908 100644 (file)
@@ -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<gc_cycle_ret> process_join;
     std::optional<seastar::promise<>> blocking;