]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/async_cleaner: decouple gc_trim_alloc() and gc_trim_dirty()
authorYingxin Cheng <yingxin.cheng@intel.com>
Fri, 22 Jul 2022 08:58:30 +0000 (16:58 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 22 Jul 2022 09:32:20 +0000 (17:32 +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 776e32b394ed8866c25b479a926def6630b82135..c564e131ae82c2e12d4e5d106e9730e46bbb343d 100644 (file)
@@ -786,10 +786,8 @@ AsyncCleaner::gc_cycle_ret AsyncCleaner::GCProcess::run()
 AsyncCleaner::gc_cycle_ret AsyncCleaner::do_gc_cycle()
 {
   if (gc_should_trim_alloc()) {
-    return gc_trim_alloc(get_alloc_tail_target()
-    ).safe_then([](auto) {
-      return seastar::now();
-    }).handle_error(
+    return gc_trim_alloc(
+    ).handle_error(
       crimson::ct_error::assert_all{
        "GCProcess::run encountered invalid error in gc_trim_alloc"
       }
@@ -814,55 +812,38 @@ AsyncCleaner::gc_cycle_ret AsyncCleaner::do_gc_cycle()
 }
 
 AsyncCleaner::gc_trim_alloc_ret
-AsyncCleaner::gc_trim_alloc(journal_seq_t limit) {
-  return seastar::do_with(
-    journal_seq_t(),
-    [this, limit=std::move(limit)](auto &seq) mutable {
-    return repeat_eagain([this, limit=std::move(limit), &seq] {
-      return ecb->with_transaction_intr(
-       Transaction::src_t::CLEANER_TRIM_ALLOC,
-       "trim_alloc",
-       [this, limit](auto &t) {
-       return trim_alloc(
-         t,
-         limit
-       ).si_then([this, &t, limit](auto trim_alloc_to)
-         -> ExtentCallbackInterface::submit_transaction_direct_iertr::future<
-           journal_seq_t> {
-         if (trim_alloc_to != JOURNAL_SEQ_NULL) {
-           return ecb->submit_transaction_direct(
-             t, std::make_optional<journal_seq_t>(trim_alloc_to)
-           ).si_then([trim_alloc_to=std::move(trim_alloc_to)]() mutable {
-             return seastar::make_ready_future<
-               journal_seq_t>(std::move(trim_alloc_to));
-           });
-         }
-         return seastar::make_ready_future<journal_seq_t>(std::move(limit));
-       });
-      }).safe_then([&seq](auto trim_alloc_to) {
-       seq = std::move(trim_alloc_to);
+AsyncCleaner::gc_trim_alloc() {
+  return repeat_eagain([this] {
+    return ecb->with_transaction_intr(
+      Transaction::src_t::CLEANER_TRIM_ALLOC,
+      "trim_alloc",
+      [this](auto &t)
+    {
+      return trim_alloc(t, get_alloc_tail_target()
+      ).si_then([this, &t](auto trim_alloc_to)
+        -> ExtentCallbackInterface::submit_transaction_direct_iertr::future<>
+      {
+        if (trim_alloc_to != JOURNAL_SEQ_NULL) {
+          return ecb->submit_transaction_direct(
+            t, std::make_optional<journal_seq_t>(trim_alloc_to));
+        }
+        return seastar::now();
       });
-    }).safe_then([&seq] {
-      return gc_trim_alloc_ertr::make_ready_future<
-       journal_seq_t>(std::move(seq));
     });
   });
 }
 
 AsyncCleaner::gc_trim_dirty_ret AsyncCleaner::gc_trim_dirty()
 {
-  return gc_trim_alloc(get_dirty_tail_target()
-  ).safe_then([this](auto seq) {
-    return repeat_eagain([this, seq=std::move(seq)]() mutable {
-      return ecb->with_transaction_intr(
-       Transaction::src_t::CLEANER_TRIM_DIRTY,
-       "trim_dirty",
-       [this, seq=std::move(seq)](auto& t)
-      {
-       return rewrite_dirty(t, seq
-       ).si_then([this, &t] {
-         return ecb->submit_transaction_direct(t);
-       });
+  return repeat_eagain([this] {
+    return ecb->with_transaction_intr(
+      Transaction::src_t::CLEANER_TRIM_DIRTY,
+      "trim_dirty",
+      [this](auto &t)
+    {
+      return rewrite_dirty(t, get_dirty_tail_target()
+      ).si_then([this, &t] {
+        return ecb->submit_transaction_direct(t);
       });
     });
   });
index 1ae22517a4b89dbd5dc93e38332bf64c1d934c68..81b328d41c62c5168e3923d92c2d91c8d763230d 100644 (file)
@@ -1097,8 +1097,8 @@ private:
   gc_trim_dirty_ret gc_trim_dirty();
 
   using gc_trim_alloc_ertr = gc_ertr;
-  using gc_trim_alloc_ret = gc_trim_alloc_ertr::future<journal_seq_t>;
-  gc_trim_alloc_ret gc_trim_alloc(journal_seq_t limit);
+  using gc_trim_alloc_ret = gc_trim_alloc_ertr::future<>;
+  gc_trim_alloc_ret gc_trim_alloc();
 
   using gc_reclaim_space_ertr = gc_ertr;
   using gc_reclaim_space_ret = gc_reclaim_space_ertr::future<>;