]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: introduce finish_commit to update tails after trim transaction 47691/head
authormyoungwon oh <ohmyoungwon@gmail.com>
Thu, 18 Aug 2022 16:29:00 +0000 (01:29 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Fri, 19 Aug 2022 03:42:25 +0000 (12:42 +0900)
Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/crimson/os/seastore/journal.h
src/crimson/os/seastore/journal/circular_bounded_journal.cc
src/crimson/os/seastore/journal/circular_bounded_journal.h
src/crimson/os/seastore/journal/segmented_journal.h
src/crimson/os/seastore/seastore_types.h
src/crimson/os/seastore/transaction_manager.cc
src/test/crimson/seastore/test_cbjournal.cc

index 71eac4c00338754c6fb6957314427d47709426a7..1500649428ed1b1261279046e7e23669819b1a64 100644 (file)
@@ -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;
index d7a5a11febd02515f9b37ee9af12051994f11c9d..ab6fb627d6b0a5ff2952c106a1e534a8498bbfcc 100644 (file)
@@ -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();
+}
+
 
 }
index 38b5ca676f32f3a3649d87720bb4d6fef418252e..9be8eb0f508adc98bc0a2479b0209a134d4f6307 100644 (file)
@@ -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;
index ba4b0cd5fb9df053e3398a7f730498d965e5738f..2ac1f2bcce2de52d6460256e68573905fcf27fbc 100644 (file)
@@ -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(
index 07b13269c6870fa1ca0596648e46f7b1454c0cf3..cd8c3c4792bb6c92c46a1b04902357e9bc735aa3 100644 (file)
@@ -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;
index 5172838673c84218240221954466f439706dfbc2..23d957293e4a6cc13290d62e9b682448e749686f 100644 (file)
@@ -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) {
index 545012c12ed843723cf61e8ebc818ba3d5ac38f7..73e5ac0048ee8978e8ae5140b69ed21d3701ee27 100644 (file)
@@ -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);