]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore: enable CBJournal trim during transaction_manager unit test
authormyoungwon oh <ohmyoungwon@gmail.com>
Fri, 17 Jun 2022 06:14:41 +0000 (15:14 +0900)
committerYingxin Cheng <yingxin.cheng@intel.com>
Wed, 24 Aug 2022 03:00:05 +0000 (11:00 +0800)
Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/async_cleaner.cc
src/crimson/os/seastore/async_cleaner.h
src/crimson/os/seastore/backref/btree_backref_manager.cc
src/crimson/os/seastore/journal/circular_bounded_journal.cc
src/crimson/os/seastore/transaction_manager.cc

index 6a5dfe7f049204ec76d600ed06b98bf9f066573d..8045fdda1bb5926e77658627d060fe5bf8dc8add 100644 (file)
@@ -649,10 +649,8 @@ void AsyncCleaner::update_journal_tails(
   journal_seq_t alloc_tail)
 {
   LOG_PREFIX(AsyncCleaner::update_journal_tails);
-  if (disable_trim) return;
 
   if (dirty_tail != JOURNAL_SEQ_NULL) {
-    assert(dirty_tail.offset.get_addr_type() != paddr_types_t::RANDOM_BLOCK);
     ceph_assert(journal_head == JOURNAL_SEQ_NULL ||
                 journal_head >= dirty_tail);
     if (journal_dirty_tail != JOURNAL_SEQ_NULL &&
@@ -672,7 +670,6 @@ void AsyncCleaner::update_journal_tails(
   if (alloc_tail != JOURNAL_SEQ_NULL) {
     ceph_assert(journal_head == JOURNAL_SEQ_NULL ||
                 journal_head >= alloc_tail);
-    assert(alloc_tail.offset.get_addr_type() != paddr_types_t::RANDOM_BLOCK);
     if (journal_alloc_tail != JOURNAL_SEQ_NULL &&
         journal_alloc_tail > alloc_tail) {
       ERROR("journal_alloc_tail {} => {} is backwards!",
@@ -1202,9 +1199,6 @@ void AsyncCleaner::start_gc()
   LOG_PREFIX(AsyncCleaner::start_gc);
   ceph_assert(state == cleaner_state_t::SCAN_SPACE);
   state = cleaner_state_t::READY;
-  if (disable_trim) {
-    return;
-  }
   INFO("done, start GC, {}", gc_stat_printer_t{this, true});
   ceph_assert(journal_head != JOURNAL_SEQ_NULL);
   ceph_assert(journal_alloc_tail != JOURNAL_SEQ_NULL);
@@ -1376,8 +1370,7 @@ segment_id_t AsyncCleaner::get_next_reclaim_segment() const
 void AsyncCleaner::log_gc_state(const char *caller) const
 {
   LOG_PREFIX(AsyncCleaner::log_gc_state);
-  if (LOCAL_LOGGER.is_enabled(seastar::log_level::debug) &&
-      !disable_trim) {
+  if (LOCAL_LOGGER.is_enabled(seastar::log_level::debug)) {
     DEBUG("caller {}, {}", caller, gc_stat_printer_t{this, true});
   }
 }
@@ -1385,9 +1378,6 @@ void AsyncCleaner::log_gc_state(const char *caller) const
 seastar::future<>
 AsyncCleaner::reserve_projected_usage(std::size_t projected_usage)
 {
-  if (disable_trim) {
-    return seastar::now();
-  }
   ceph_assert(is_ready());
   // The pipeline configuration prevents another IO from entering
   // prepare until the prior one exits and clears this.
@@ -1430,7 +1420,6 @@ AsyncCleaner::reserve_projected_usage(std::size_t projected_usage)
 
 void AsyncCleaner::release_projected_usage(std::size_t projected_usage)
 {
-  if (disable_trim) return;
   ceph_assert(is_ready());
   ceph_assert(stats.projected_used_bytes >= projected_usage);
   stats.projected_used_bytes -= projected_usage;
index 2ca0ba974921a0bf0c2246d0aab4da8c01ab7834..1cc231ae2d84ce2c5a4341ce05815c83b9d00e54 100644 (file)
@@ -826,15 +826,6 @@ private:
 
   SegmentSeqAllocatorRef ool_segment_seq_allocator;
 
-  /**
-   * disable_trim
-   *
-   * added to enable unit testing of CircularBoundedJournal before
-   * proper support is added to AsyncCleaner.
-   * Should be removed once proper support is added. TODO
-   */
-  bool disable_trim = false;
-
 public:
   AsyncCleaner(
     config_t config,
@@ -971,10 +962,6 @@ public:
 
   bool check_usage();
 
-  void set_disable_trim(bool val) {
-    disable_trim = val;
-  }
-
   using work_ertr = ExtentCallbackInterface::extent_mapping_ertr;
   using work_iertr = ExtentCallbackInterface::extent_mapping_iertr;
 
@@ -1211,6 +1198,9 @@ private:
    * Segments calculations
    */
   std::size_t get_segments_in_journal() const {
+    if (journal_type == journal_type_t::CIRCULAR) {
+      return 0;
+    }
     auto journal_tail = get_journal_tail();
     if (journal_tail == JOURNAL_SEQ_NULL ||
         journal_head == JOURNAL_SEQ_NULL) {
@@ -1313,13 +1303,11 @@ private:
    */
   bool should_block_on_trim() const {
     assert(is_ready());
-    if (disable_trim) return false;
     return get_tail_limit() > get_journal_tail();
   }
 
   bool should_block_on_reclaim() const {
     assert(is_ready());
-    if (disable_trim) return false;
     if (get_segments_reclaimable() == 0) {
       return false;
     }
@@ -1357,7 +1345,6 @@ private:
    */
   bool gc_should_reclaim_space() const {
     assert(is_ready());
-    if (disable_trim) return false;
     if (get_segments_reclaimable() == 0) {
       return false;
     }
@@ -1385,7 +1372,6 @@ private:
    * True if gc should be running.
    */
   bool gc_should_run() const {
-    if (disable_trim) return false;
     ceph_assert(is_ready());
     return gc_should_reclaim_space()
       || gc_should_trim_dirty()
index 4e9e7a4c382c981a4082a57a11a118a9e9846fc6..01c96cf841fed5cbb66be9146981e021da7df09d 100644 (file)
@@ -123,7 +123,9 @@ BtreeBackrefManager::new_mapping(
 {
   ceph_assert(
     is_aligned(
-      key.as_seg_paddr().get_segment_off(),
+      key.get_addr_type() == paddr_types_t::SEGMENT ?
+       key.as_seg_paddr().get_segment_off() :
+       key.as_blk_paddr().get_block_off(),
       (uint64_t)cache.get_block_size()));
   struct state_t {
     paddr_t last_end;
index ab6fb627d6b0a5ff2952c106a1e534a8498bbfcc..b06c81b5f290d71f2841a9b87f95316e55c1315c 100644 (file)
@@ -378,6 +378,10 @@ Journal::replay_ret CircularBoundedJournal::replay(
          });
        });
       });
+    }).safe_then([this]() {
+      trimmer.update_journal_tails(
+       header.dirty_tail,
+       header.alloc_tail);
     });
   });
 }
index ef644a0796668f3298ffd3e8e8dca2eb784f0c90..5be13552245c673545b3e88ca808d9c9132ad5c4 100644 (file)
@@ -624,7 +624,6 @@ TransactionManagerRef make_transaction_manager(
     const std::vector<Device*> &secondary_devices,
     bool is_test)
 {
-  LOG_PREFIX(make_transaction_manager);
   auto epm = std::make_unique<ExtentPlacementManager>();
   auto cache = std::make_unique<Cache>(*epm);
   auto lba_manager = lba_manager::create_lba_manager(*cache);
@@ -693,9 +692,6 @@ TransactionManagerRef make_transaction_manager(
       *async_cleaner,
       static_cast<random_block_device::RBMDevice*>(primary_device),
       "");
-    async_cleaner->set_disable_trim(true);
-    ERROR("disabling journal trimming since support for CircularBoundedJournal "
-          "hasn't been added yet");
   }
 
   epm->set_async_cleaner(std::move(async_cleaner));