]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/segment_cleaner: cleanup and validate config_t
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 28 Apr 2022 07:35:14 +0000 (15:35 +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 1a9784e36f3fdb6d6726a8c8c1419d6e54cdbf18..fd81d0d313e2f7ec51d0e634b92e1ab32899a81d 100644 (file)
@@ -387,7 +387,9 @@ SegmentCleaner::SegmentCleaner(
     ool_segment_seq_allocator(
       new SegmentSeqAllocator(segment_type_t::OOL)),
     gc_process(*this)
-{}
+{
+  config.validate();
+}
 
 void SegmentCleaner::register_metrics()
 {
@@ -564,7 +566,7 @@ SegmentCleaner::trim_backrefs_ret SegmentCleaner::trim_backrefs(
   return backref_manager.batch_insert_from_cache(
     t,
     limit,
-    config.journal_rewrite_backref_per_cycle
+    config.rewrite_backref_bytes_per_cycle
   );
 }
 
@@ -575,7 +577,7 @@ SegmentCleaner::rewrite_dirty_ret SegmentCleaner::rewrite_dirty(
   return ecb->get_next_dirty_extents(
     t,
     limit,
-    config.journal_rewrite_dirty_per_cycle
+    config.rewrite_dirty_bytes_per_cycle
   ).si_then([=, &t](auto dirty_list) {
     LOG_PREFIX(SegmentCleaner::rewrite_dirty);
     DEBUGT("rewrite {} dirty extents", t, dirty_list.size());
@@ -766,7 +768,7 @@ SegmentCleaner::gc_reclaim_space_ret SegmentCleaner::gc_reclaim_space()
       segment_id.device_segment_id() + 1};
     end_paddr = paddr_t::make_seg_paddr(next_segment_id, 0);
   } else {
-    end_paddr = seg_paddr + config.reclaim_bytes_stride;
+    end_paddr = seg_paddr + config.reclaim_bytes_per_cycle;
   }
 
   double pavail_ratio = get_projected_available_ratio();
@@ -888,7 +890,7 @@ SegmentCleaner::gc_reclaim_space_ret SegmentCleaner::gc_reclaim_space()
        next_reclaim_pos.reset();
       } else {
        next_reclaim_pos =
-         paddr_t(*next_reclaim_pos + config.reclaim_bytes_stride);
+         paddr_t(*next_reclaim_pos + config.reclaim_bytes_per_cycle);
       }
     });
   });
index 41654e44be526df09b57886e0526d226caa55da3..6a55f8ebb06958e123e73ea01fe5e6682765550b 100644 (file)
@@ -424,34 +424,50 @@ public:
 
   /// Config
   struct config_t {
+    /// Number of minimum journal segments to stop trimming.
     size_t target_journal_segments = 0;
+    /// Number of maximum journal segments to block user transactions.
     size_t max_journal_segments = 0;
 
+    /// Ratio of maximum available space to disable reclaiming.
     double available_ratio_gc_max = 0;
+    /// Ratio of minimum available space to force reclaiming.
+    double available_ratio_hard_limit = 0;
+
+    /// Ratio of maximum reclaimable space to block user transactions.
     double reclaim_ratio_hard_limit = 0;
-    double reclaim_ratio_gc_threshhold = 0;
+    /// Ratio of minimum reclaimable space to stop reclaiming.
+    double reclaim_ratio_gc_threshold = 0;
 
-    double available_ratio_hard_limit = 0;
+    /// Number of bytes to reclaim per cycle
+    size_t reclaim_bytes_per_cycle = 0;
 
-    /// Number of bytes to reclaim on each cycle
-    size_t reclaim_bytes_stride = 0;
+    /// Number of bytes to rewrite dirty per cycle
+    size_t rewrite_dirty_bytes_per_cycle = 0;
 
-    /// Number of bytes of journal entries to rewrite per cycle
-    size_t journal_rewrite_dirty_per_cycle = 0;
+    /// Number of bytes to rewrite backref per cycle
+    size_t rewrite_backref_bytes_per_cycle = 0;
 
-    size_t journal_rewrite_backref_per_cycle = 0;
+    void validate() const {
+      ceph_assert(max_journal_segments > target_journal_segments);
+      ceph_assert(available_ratio_gc_max > available_ratio_hard_limit);
+      ceph_assert(reclaim_ratio_hard_limit > reclaim_ratio_gc_threshold);
+      ceph_assert(reclaim_bytes_per_cycle > 0);
+      ceph_assert(rewrite_dirty_bytes_per_cycle > 0);
+      ceph_assert(rewrite_backref_bytes_per_cycle > 0);
+    }
 
     static config_t get_default() {
       return config_t{
          2,    // target_journal_segments
          4,    // max_journal_segments
          .9,   // available_ratio_gc_max
-         .8,   // reclaim_ratio_hard_limit
-         .6,   // reclaim_ratio_gc_threshhold
          .2,   // available_ratio_hard_limit
-         1<<20,// reclaim 1MB per gc cycle
-         1<<20,// rewrite 1MB of journal entries per gc cycle
-         1<<24 // create 16MB of backref extents per gc cycle
+         .8,   // reclaim_ratio_hard_limit
+         .6,   // reclaim_ratio_gc_threshold
+         1<<20,// reclaim_bytes_per_cycle
+         1<<20,// rewrite_dirty_bytes_per_cycle
+         1<<24 // rewrite_backref_bytes_per_cycle
        };
     }
   };
@@ -886,7 +902,7 @@ private:
 
   bool final_reclaim() {
     return next_reclaim_pos->as_seg_paddr().get_segment_off()
-      + config.reclaim_bytes_stride >= (size_t)segments.get_segment_size();
+      + config.reclaim_bytes_per_cycle >= (size_t)segments.get_segment_size();
   }
 
   /**
@@ -1092,11 +1108,11 @@ private:
   bool should_block_on_gc() const {
     // TODO: probably worth projecting journal usage as well
     auto aratio = get_projected_available_ratio();
+    auto rratio = get_projected_reclaim_ratio();
     return (
+      (aratio < config.available_ratio_hard_limit) ||
       ((aratio < config.available_ratio_gc_max) &&
-       ((get_projected_reclaim_ratio() >
-        config.reclaim_ratio_hard_limit) ||
-       (aratio < config.available_ratio_hard_limit))) ||
+       (rratio > config.reclaim_ratio_hard_limit)) ||
       (get_dirty_tail_limit() > journal_tail_target)
     );
   }
@@ -1194,10 +1210,11 @@ private:
    */
   bool gc_should_reclaim_space() const {
     auto aratio = get_available_ratio();
+    auto rratio = get_reclaim_ratio();
     return (
-      (aratio < config.available_ratio_gc_max) &&
-      (get_reclaim_ratio() > config.reclaim_ratio_gc_threshhold ||
-       aratio < config.available_ratio_hard_limit)
+      (aratio < config.available_ratio_hard_limit) ||
+      ((aratio < config.available_ratio_gc_max) &&
+       (rratio > config.reclaim_ratio_gc_threshold))
     );
   }