if (!segment_info.is_open()) {
ERROR("segment is not open, not updating, offset={}, {}",
offset, segment_info);
- // FIXME
- return;
+ ceph_abort();
}
auto new_avail = get_segment_size() - saddr.get_segment_off();
journal_seq_t dirty_replay_from,
journal_seq_t alloc_replay_from)
{
- logger().debug(
- "{}: {}, current dirty_extents_replay_from {}",
- __func__,
- dirty_replay_from,
- dirty_extents_replay_from);
+ LOG_PREFIX(SegmentCleaner::update_journal_tail_target);
if (dirty_extents_replay_from == JOURNAL_SEQ_NULL
|| dirty_replay_from > dirty_extents_replay_from) {
+ DEBUG("dirty_extents_replay_from={} => {}",
+ dirty_extents_replay_from, dirty_replay_from);
dirty_extents_replay_from = dirty_replay_from;
}
update_alloc_info_replay_from(alloc_replay_from);
journal_seq_t target = std::min(dirty_replay_from, alloc_replay_from);
- logger().debug(
- "{}: {}, current tail target {}",
- __func__,
- target,
- journal_tail_target);
- if (journal_tail_target == JOURNAL_SEQ_NULL || target > journal_tail_target) {
+ ceph_assert(target != JOURNAL_SEQ_NULL);
+ ceph_assert(journal_head == JOURNAL_SEQ_NULL ||
+ journal_head >= target);
+ if (journal_tail_target == JOURNAL_SEQ_NULL ||
+ target > journal_tail_target) {
+ DEBUG("journal_tail_target={} => {}", journal_tail_target, target);
journal_tail_target = target;
}
gc_process.maybe_wake_on_space_used();
void SegmentCleaner::update_alloc_info_replay_from(
journal_seq_t alloc_replay_from)
{
- logger().debug(
- "{}: {}, current alloc_info_replay_from {}",
- __func__,
- alloc_replay_from,
- alloc_info_replay_from);
+ LOG_PREFIX(SegmentCleaner::update_alloc_info_replay_from);
if (alloc_info_replay_from == JOURNAL_SEQ_NULL
|| alloc_replay_from > alloc_info_replay_from) {
+ DEBUG("alloc_info_replay_from={} => {}",
+ alloc_info_replay_from, alloc_replay_from);
alloc_info_replay_from = alloc_replay_from;
}
}
void SegmentCleaner::update_journal_tail_committed(journal_seq_t committed)
{
+ LOG_PREFIX(SegmentCleaner::update_journal_tail_committed);
+ if (committed == JOURNAL_SEQ_NULL) {
+ return;
+ }
+ ceph_assert(journal_head == JOURNAL_SEQ_NULL ||
+ journal_head >= committed);
+
if (journal_tail_committed == JOURNAL_SEQ_NULL ||
committed > journal_tail_committed) {
- logger().debug(
- "{}: update journal_tail_committed {}",
- __func__,
- committed);
+ DEBUG("update journal_tail_committed={} => {}",
+ journal_tail_committed, committed);
journal_tail_committed = committed;
}
if (journal_tail_target == JOURNAL_SEQ_NULL ||
committed > journal_tail_target) {
- logger().debug(
- "{}: update journal_tail_target {}",
- __func__,
- committed);
+ DEBUG("update journal_tail_target={} => {}",
+ journal_tail_target, committed);
journal_tail_target = committed;
}
}
}
}
+void SegmentCleaner::complete_init()
+{
+ LOG_PREFIX(SegmentCleaner::complete_init);
+ INFO("done, start GC");
+ ceph_assert(journal_head != JOURNAL_SEQ_NULL);
+ init_complete = true;
+ gc_process.start();
+}
+
}
std::size_t get_count_close() const {
return count_close;
}
- size_t get_total_bytes() const {
+ std::size_t get_total_bytes() const {
return total_bytes;
}
- size_t get_available_bytes() const {
+ std::size_t get_available_bytes() const {
return avail_bytes;
}
journal_seq_t alloc_replay_from);
void init_mkfs(journal_seq_t head) {
+ ceph_assert(head != JOURNAL_SEQ_NULL);
journal_tail_target = head;
journal_tail_committed = head;
journal_head = head;
}
void set_journal_head(journal_seq_t head) {
+ ceph_assert(head != JOURNAL_SEQ_NULL);
assert(journal_head == JOURNAL_SEQ_NULL || head >= journal_head);
journal_head = head;
segments.update_written_to(head.offset);
return space_tracker->make_empty();
}
- void start() {
- gc_process.start();
- }
-
- void complete_init() {
- init_complete = true;
- start();
- }
+ void complete_init();
store_statfs_t stat() const {
store_statfs_t st;
journal_seq_t get_dirty_tail() const {
auto ret = journal_head;
+ ceph_assert(ret != JOURNAL_SEQ_NULL);
if (ret.segment_seq >= config.target_journal_segments) {
ret.segment_seq -= config.target_journal_segments;
} else {
journal_seq_t get_dirty_tail_limit() const {
auto ret = journal_head;
+ ceph_assert(ret != JOURNAL_SEQ_NULL);
if (ret.segment_seq >= config.max_journal_segments) {
ret.segment_seq -= config.max_journal_segments;
} else {
}
void maybe_wake_on_space_used() {
+ if (is_stopping()) {
+ return;
+ }
if (cleaner.gc_should_run()) {
wake();
}
return segments.get_total_bytes() - segments.get_available_bytes();
}
size_t get_projected_unavailable_bytes() const {
- return (get_total_bytes() > get_projected_available_bytes()) ?
- (get_total_bytes() - get_projected_available_bytes()) :
- 0;
+ assert(get_total_bytes() >= get_projected_available_bytes());
+ return get_total_bytes() - get_projected_available_bytes();
}
/// Returns bytes currently occupied by live extents (not journal)
/// Return bytes contained in segments in journal
size_t get_journal_segment_bytes() const {
- if (journal_head == JOURNAL_SEQ_NULL) {
- // this for calculating journal bytes in the journal
- // replay phase in which journal_head is not set
- return segments.get_num_in_journal() * segments.get_segment_size();
- } else {
- assert(journal_head >= journal_tail_committed);
- auto segment_size = segments.get_segment_size();
- return (journal_head.segment_seq - journal_tail_committed.segment_seq + 1) *
- segment_size;
- }
+ return segments.get_num_in_journal() * segments.get_segment_size();
}
/**
public:
seastar::future<> reserve_projected_usage(size_t projected_usage) {
+ ceph_assert(init_complete);
// The pipeline configuration prevents another IO from entering
// prepare until the prior one exits and clears this.
ceph_assert(!blocked_io_wake);
}
void release_projected_usage(size_t projected_usage) {
+ ceph_assert(init_complete);
ceph_assert(stats.projected_used_bytes >= projected_usage);
stats.projected_used_bytes -= projected_usage;
return maybe_wake_gc_blocked_io();
}
private:
void maybe_wake_gc_blocked_io() {
+ if (!init_complete) {
+ return;
+ }
if (!should_block_on_gc() && blocked_io_wake) {
blocked_io_wake->set_value();
blocked_io_wake = std::nullopt;
* True if gc should be running.
*/
bool gc_should_run() const {
+ ceph_assert(init_complete);
return gc_should_reclaim_space() || gc_should_trim_journal();
}