From: myoungwon oh Date: Thu, 18 Aug 2022 16:29:00 +0000 (+0900) Subject: crimson/os/seastore: introduce finish_commit to update tails after trim transaction X-Git-Tag: v18.0.0~230^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F47691%2Fhead;p=ceph.git crimson/os/seastore: introduce finish_commit to update tails after trim transaction Signed-off-by: Myoungwon Oh --- diff --git a/src/crimson/os/seastore/journal.h b/src/crimson/os/seastore/journal.h index 71eac4c00338..1500649428ed 100644 --- a/src/crimson/os/seastore/journal.h +++ b/src/crimson/os/seastore/journal.h @@ -102,6 +102,9 @@ public: virtual replay_ret replay( delta_handler_t &&delta_handler) = 0; + virtual seastar::future<> finish_commit( + transaction_type_t type) = 0; + virtual ~Journal() {} virtual journal_type_t get_type() = 0; diff --git a/src/crimson/os/seastore/journal/circular_bounded_journal.cc b/src/crimson/os/seastore/journal/circular_bounded_journal.cc index d7a5a11febd0..ab6fb627d6b0 100644 --- a/src/crimson/os/seastore/journal/circular_bounded_journal.cc +++ b/src/crimson/os/seastore/journal/circular_bounded_journal.cc @@ -474,5 +474,14 @@ CircularBoundedJournal::write_header() bl.length()); return device_write_bl(CBJOURNAL_START_ADDRESS, bl); } +seastar::future<> CircularBoundedJournal::finish_commit(transaction_type_t type) { + if (is_trim_transaction(type)) { + return update_journal_tail( + trimmer.get_dirty_tail(), + trimmer.get_alloc_tail()); + } + return seastar::now(); +} + } diff --git a/src/crimson/os/seastore/journal/circular_bounded_journal.h b/src/crimson/os/seastore/journal/circular_bounded_journal.h index 38b5ca676f32..9be8eb0f508a 100644 --- a/src/crimson/os/seastore/journal/circular_bounded_journal.h +++ b/src/crimson/os/seastore/journal/circular_bounded_journal.h @@ -250,12 +250,16 @@ public: return get_total_size() - get_used_size(); } - write_ertr::future<> update_journal_tail( + seastar::future<> update_journal_tail( journal_seq_t dirty, journal_seq_t alloc) { header.dirty_tail = dirty; header.alloc_tail = alloc; - return write_header(); + return write_header( + ).handle_error( + crimson::ct_error::assert_all{ + "encountered invalid error in update_journal_tail" + }); } journal_seq_t get_dirty_tail() const { return header.dirty_tail; @@ -293,7 +297,7 @@ public: rbm_abs_addr get_journal_end() const { return get_start_addr() + header.size + get_block_size(); // journal size + header length } - + seastar::future<> finish_commit(transaction_type_t type) final; private: cbj_header_t header; JournalTrimmer &trimmer; diff --git a/src/crimson/os/seastore/journal/segmented_journal.h b/src/crimson/os/seastore/journal/segmented_journal.h index ba4b0cd5fb9d..2ac1f2bcce2d 100644 --- a/src/crimson/os/seastore/journal/segmented_journal.h +++ b/src/crimson/os/seastore/journal/segmented_journal.h @@ -54,6 +54,9 @@ public: journal_type_t get_type() final { return journal_type_t::SEGMENT_JOURNAL; } + seastar::future<> finish_commit(transaction_type_t type) { + return seastar::now(); + } private: submit_record_ret do_submit_record( diff --git a/src/crimson/os/seastore/seastore_types.h b/src/crimson/os/seastore/seastore_types.h index 07b13269c687..cd8c3c4792bb 100644 --- a/src/crimson/os/seastore/seastore_types.h +++ b/src/crimson/os/seastore/seastore_types.h @@ -1657,6 +1657,11 @@ constexpr bool is_cleaner_transaction(transaction_type_t type) { type < transaction_type_t::MAX); } +constexpr bool is_trim_transaction(transaction_type_t type) { + return (type == transaction_type_t::CLEANER_TRIM_DIRTY || + type == transaction_type_t::CLEANER_TRIM_ALLOC); +} + struct record_size_t { extent_len_t plain_mdlength = 0; // mdlength without the record header extent_len_t dlength = 0; diff --git a/src/crimson/os/seastore/transaction_manager.cc b/src/crimson/os/seastore/transaction_manager.cc index 5172838673c8..23d957293e4a 100644 --- a/src/crimson/os/seastore/transaction_manager.cc +++ b/src/crimson/os/seastore/transaction_manager.cc @@ -392,7 +392,10 @@ TransactionManager::submit_transaction_direct( journal->get_trimmer().update_journal_tails( cache->get_oldest_dirty_from().value_or(start_seq), cache->get_oldest_backref_dirty_from().value_or(start_seq)); - return tref.get_handle().complete(); + return journal->finish_commit(tref.get_src() + ).then([&tref] { + return tref.get_handle().complete(); + }); }).handle_error( submit_transaction_iertr::pass_further{}, crimson::ct_error::all_same_way([](auto e) { diff --git a/src/test/crimson/seastore/test_cbjournal.cc b/src/test/crimson/seastore/test_cbjournal.cc index 545012c12ed8..73e5ac0048ee 100644 --- a/src/test/crimson/seastore/test_cbjournal.cc +++ b/src/test/crimson/seastore/test_cbjournal.cc @@ -292,7 +292,7 @@ struct cbjournal_test_t : public seastar_test_suite_t, JournalTrimmer cbj->update_journal_tail( seq, seq - ).unsafe_get0(); + ).get0(); } void set_written_to(journal_seq_t seq) { cbj->set_written_to(seq);