From 5aa8187d56fa8cacad9b5348026d8a409c51454b Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Mon, 25 Jul 2022 16:28:42 +0800 Subject: [PATCH] crimson/os/seastore/async_cleaner: fix and improve update_journal_tails() * Accept JOURNAL_SEQ_NULL dirty_tail when it is pending. * Enforce monotone increasing to the journal tails. * Enforce journal tails to be always behind the journal head. Signed-off-by: Yingxin Cheng --- src/crimson/os/seastore/async_cleaner.cc | 30 ++++++++++++------- src/crimson/os/seastore/async_cleaner.h | 4 +++ .../os/seastore/transaction_manager.cc | 3 -- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/crimson/os/seastore/async_cleaner.cc b/src/crimson/os/seastore/async_cleaner.cc index 4a9765f61ae32..67690e91f8099 100644 --- a/src/crimson/os/seastore/async_cleaner.cc +++ b/src/crimson/os/seastore/async_cleaner.cc @@ -631,16 +631,17 @@ void AsyncCleaner::update_journal_tails( { LOG_PREFIX(AsyncCleaner::update_journal_tails); if (disable_trim) return; - assert(dirty_tail.offset.get_addr_type() != addr_types_t::RANDOM_BLOCK); - assert(alloc_tail.offset.get_addr_type() != addr_types_t::RANDOM_BLOCK); - ceph_assert(dirty_tail != JOURNAL_SEQ_NULL); - ceph_assert(alloc_tail != JOURNAL_SEQ_NULL); - ceph_assert(journal_head == JOURNAL_SEQ_NULL || - (journal_head >= dirty_tail && journal_head >= alloc_tail)); - - if (journal_dirty_tail == JOURNAL_SEQ_NULL || - dirty_tail > journal_dirty_tail) { + if (dirty_tail != JOURNAL_SEQ_NULL) { + assert(dirty_tail.offset.get_addr_type() != addr_types_t::RANDOM_BLOCK); + ceph_assert(journal_head == JOURNAL_SEQ_NULL || + journal_head >= dirty_tail); + if (journal_dirty_tail != JOURNAL_SEQ_NULL && + journal_dirty_tail > dirty_tail) { + ERROR("journal_dirty_tail {} => {} is backwards!", + journal_dirty_tail, dirty_tail); + ceph_abort(); + } if (journal_dirty_tail.segment_seq == dirty_tail.segment_seq) { DEBUG("journal_dirty_tail {} => {}", journal_dirty_tail, dirty_tail); } else { @@ -649,8 +650,15 @@ void AsyncCleaner::update_journal_tails( journal_dirty_tail = dirty_tail; } - if (journal_alloc_tail == JOURNAL_SEQ_NULL || - alloc_tail > journal_alloc_tail) { + if (alloc_tail != JOURNAL_SEQ_NULL) { + ceph_assert(journal_head == JOURNAL_SEQ_NULL || + journal_head >= alloc_tail); + assert(alloc_tail.offset.get_addr_type() != addr_types_t::RANDOM_BLOCK); + if (journal_alloc_tail != JOURNAL_SEQ_NULL && + journal_alloc_tail > alloc_tail) { + ERROR("journal_alloc_tail {} => {} is backwards!", + journal_alloc_tail, alloc_tail); + } if (journal_alloc_tail.segment_seq == alloc_tail.segment_seq) { DEBUG("journal_alloc_tail {} => {}", journal_alloc_tail, alloc_tail); } else { diff --git a/src/crimson/os/seastore/async_cleaner.h b/src/crimson/os/seastore/async_cleaner.h index 9af774e908c84..4f6adbb540923 100644 --- a/src/crimson/os/seastore/async_cleaner.h +++ b/src/crimson/os/seastore/async_cleaner.h @@ -774,6 +774,10 @@ public: ceph_assert(head != JOURNAL_SEQ_NULL); ceph_assert(journal_head == JOURNAL_SEQ_NULL || head >= journal_head); + ceph_assert(journal_alloc_tail == JOURNAL_SEQ_NULL || + head >= journal_alloc_tail); + ceph_assert(journal_dirty_tail == JOURNAL_SEQ_NULL || + head >= journal_dirty_tail); journal_head = head; gc_process.maybe_wake_on_space_used(); } diff --git a/src/crimson/os/seastore/transaction_manager.cc b/src/crimson/os/seastore/transaction_manager.cc index 272c66958f671..b91acea653832 100644 --- a/src/crimson/os/seastore/transaction_manager.cc +++ b/src/crimson/os/seastore/transaction_manager.cc @@ -96,9 +96,6 @@ TransactionManager::mount_ertr::future<> TransactionManager::mount() auto modify_time) { auto start_seq = offsets.write_result.start_seq; - async_cleaner->update_journal_tails( - cache->get_oldest_dirty_from().value_or(start_seq), - cache->get_oldest_backref_dirty_from().value_or(start_seq)); return cache->replay_delta( start_seq, offsets.record_block_base, -- 2.39.5