]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore/async_cleaner: cleanup and add logs to gc trim
authorYingxin Cheng <yingxin.cheng@intel.com>
Fri, 12 Aug 2022 07:14:54 +0000 (15:14 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Mon, 15 Aug 2022 03:34:51 +0000 (11:34 +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 721f5ba39d2f5fd4fa079417f72c33fadcb3e8dc..426963ad3623fa48f42e0789c9350a82e3952b89 100644 (file)
@@ -700,17 +700,6 @@ void AsyncCleaner::close_segment(segment_id_t segment)
   INFO("closed, {} -- {}", gc_stat_printer_t{this, false}, seg_info);
 }
 
-AsyncCleaner::trim_alloc_ret AsyncCleaner::trim_alloc(
-  Transaction &t,
-  journal_seq_t limit)
-{
-  return backref_manager.merge_cached_backrefs(
-    t,
-    limit,
-    config.rewrite_backref_bytes_per_cycle
-  );
-}
-
 double AsyncCleaner::calc_gc_benefit_cost(
   segment_id_t id,
   const sea_time_point &now_time,
@@ -753,30 +742,6 @@ double AsyncCleaner::calc_gc_benefit_cost(
           (2 * age_factor - 2) * util + 1);
 }
 
-AsyncCleaner::rewrite_dirty_ret AsyncCleaner::rewrite_dirty(
-  Transaction &t,
-  journal_seq_t limit)
-{
-  return ecb->get_next_dirty_extents(
-    t,
-    limit,
-    config.rewrite_dirty_bytes_per_cycle
-  ).si_then([=, &t, this](auto dirty_list) {
-    LOG_PREFIX(AsyncCleaner::rewrite_dirty);
-    DEBUGT("rewrite {} dirty extents", t, dirty_list.size());
-    return seastar::do_with(
-      std::move(dirty_list),
-      [this, FNAME, &t](auto &dirty_list) {
-       return trans_intr::do_for_each(
-         dirty_list,
-         [this, FNAME, &t](auto &e) {
-         DEBUGT("cleaning {}", t, *e);
-         return ecb->rewrite_extent(t, e, DIRTY_GENERATION, NULL_TIME);
-       });
-      });
-  });
-}
-
 AsyncCleaner::gc_cycle_ret AsyncCleaner::GCProcess::run()
 {
   return seastar::do_until(
@@ -824,19 +789,26 @@ AsyncCleaner::gc_cycle_ret AsyncCleaner::do_gc_cycle()
 }
 
 AsyncCleaner::gc_trim_alloc_ret
-AsyncCleaner::gc_trim_alloc() {
-  return repeat_eagain([this] {
+AsyncCleaner::gc_trim_alloc()
+{
+  LOG_PREFIX(AsyncCleaner::gc_trim_alloc);
+  return repeat_eagain([this, FNAME] {
     return ecb->with_transaction_intr(
       Transaction::src_t::CLEANER_TRIM_ALLOC,
       "trim_alloc",
-      [this](auto &t)
+      [this, FNAME](auto &t)
     {
-      LOG_PREFIX(AsyncCleaner::gc_trim_alloc);
-      DEBUGT("target {}", t, get_alloc_tail_target());
-      return trim_alloc(t, get_alloc_tail_target()
-      ).si_then([this, &t](auto trim_alloc_to)
+      auto target = get_alloc_tail_target();
+      DEBUGT("start, alloc_tail={}, target={}",
+             t, journal_alloc_tail, target);
+      return backref_manager.merge_cached_backrefs(
+        t,
+        target,
+        config.rewrite_backref_bytes_per_cycle
+      ).si_then([this, FNAME, &t](auto trim_alloc_to)
         -> ExtentCallbackInterface::submit_transaction_direct_iertr::future<>
       {
+        DEBUGT("trim_alloc_to={}", t, trim_alloc_to);
         if (trim_alloc_to != JOURNAL_SEQ_NULL) {
           return ecb->submit_transaction_direct(
             t, std::make_optional<journal_seq_t>(trim_alloc_to));
@@ -844,22 +816,46 @@ AsyncCleaner::gc_trim_alloc() {
         return seastar::now();
       });
     });
+  }).safe_then([this, FNAME] {
+    DEBUGT("finish, alloc_tail={}", journal_alloc_tail);
   });
 }
 
-AsyncCleaner::gc_trim_dirty_ret AsyncCleaner::gc_trim_dirty()
+AsyncCleaner::gc_trim_dirty_ret
+AsyncCleaner::gc_trim_dirty()
 {
-  return repeat_eagain([this] {
+  LOG_PREFIX(AsyncCleaner::gc_trim_dirty);
+  return repeat_eagain([this, FNAME] {
     return ecb->with_transaction_intr(
       Transaction::src_t::CLEANER_TRIM_DIRTY,
       "trim_dirty",
-      [this](auto &t)
+      [this, FNAME](auto &t)
     {
-      return rewrite_dirty(t, get_dirty_tail_target()
-      ).si_then([this, &t] {
+      auto target = get_dirty_tail_target();
+      DEBUGT("start, dirty_tail={}, target={}",
+             t, journal_dirty_tail, target);
+      return ecb->get_next_dirty_extents(
+        t,
+        target,
+        config.rewrite_dirty_bytes_per_cycle
+      ).si_then([this, FNAME, &t](auto dirty_list) {
+        DEBUGT("rewrite {} dirty extents", t, dirty_list.size());
+        return seastar::do_with(
+          std::move(dirty_list),
+          [this, &t](auto &dirty_list)
+        {
+          return trans_intr::do_for_each(
+            dirty_list,
+            [this, &t](auto &e) {
+            return ecb->rewrite_extent(t, e, DIRTY_GENERATION, NULL_TIME);
+          });
+        });
+      }).si_then([this, &t] {
         return ecb->submit_transaction_direct(t);
       });
     });
+  }).safe_then([this, FNAME] {
+    DEBUGT("finish, dirty_tail={}", journal_dirty_tail);
   });
 }
 
index 4e7365bd1c8311430f33c8b4dee490bb2b894952..1a9928a46cc7c1e89009211f3824975e63b3658e 100644 (file)
@@ -961,23 +961,6 @@ private:
 
   segment_id_t get_next_reclaim_segment() const;
 
-  /**
-   * rewrite_dirty
-   *
-   * Writes out dirty blocks dirtied earlier than limit.
-   */
-  using rewrite_dirty_iertr = work_iertr;
-  using rewrite_dirty_ret = rewrite_dirty_iertr::future<>;
-  rewrite_dirty_ret rewrite_dirty(
-    Transaction &t,
-    journal_seq_t limit);
-
-  using trim_alloc_iertr = work_iertr;
-  using trim_alloc_ret = trim_alloc_iertr::future<journal_seq_t>;
-  trim_alloc_ret trim_alloc(
-    Transaction &t,
-    journal_seq_t limit);
-
   journal_seq_t get_dirty_tail_target() const {
     assert(init_complete);
     auto ret = journal_head;