ool_segment_seq_allocator(
new SegmentSeqAllocator(segment_type_t::OOL)),
gc_process(*this)
-{}
+{
+ config.validate();
+}
void SegmentCleaner::register_metrics()
{
return backref_manager.batch_insert_from_cache(
t,
limit,
- config.journal_rewrite_backref_per_cycle
+ config.rewrite_backref_bytes_per_cycle
);
}
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());
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();
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);
}
});
});
/// 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
};
}
};
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();
}
/**
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)
);
}
*/
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))
);
}