]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/journal: lift the alloc_map scanning from CircularBoundedJournal...
authorXuehan Xu <xuxuehan@qianxin.com>
Fri, 3 Jul 2026 13:32:53 +0000 (21:32 +0800)
committerXuehan Xu <xuxuehan@qianxin.com>
Fri, 31 Jul 2026 01:40:19 +0000 (09:40 +0800)
Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/crimson/os/seastore/journal.cc
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

index e55b62b045a23674618efffa4dc1abc0645e7597..2f866de5db365aff1c538463475e1c64d8654eac 100644 (file)
@@ -5,7 +5,35 @@
 #include "journal/segmented_journal.h"
 #include "journal/circular_bounded_journal.h"
 
-namespace crimson::os::seastore::journal {
+namespace crimson::os::seastore {
+
+Journal::scan_alloc_map_ret
+Journal::scan_alloc_map() {
+  alloc_map_t map;
+  journal_seq_t tail = get_dirty_tail() <= get_alloc_tail() ?
+    get_dirty_tail() : get_alloc_tail();
+  auto build_paddr_seq_map = [&map](
+    const auto &offsets,
+    const auto &e,
+    sea_time_point modify_time)
+  {
+    if (e.type == extent_types_t::ALLOC_INFO) {
+      alloc_delta_t alloc_delta;
+      decode(alloc_delta, e.bl);
+      if (alloc_delta.op == alloc_delta_t::op_types_t::CLEAR) {
+        for (auto &alloc_blk : alloc_delta.alloc_blk_ranges) {
+          map[alloc_blk.paddr] = offsets.write_result.start_seq;
+        }
+      }
+    }
+    return replay_ertr::make_ready_future<bool>(true);
+  };
+  // build the paddr->journal_seq_t map from extent allocations
+  co_await scan_valid_record_delta(std::move(build_paddr_seq_map), tail);
+  co_return map;
+}
+
+namespace journal {
 
 JournalRef make_segmented(
   store_index_t store_index,
@@ -24,4 +52,6 @@ JournalRef make_circularbounded(
   return std::make_unique<CircularBoundedJournal>(store_index, trimmer, device, path);
 }
 
-}
+} // namespace journal
+
+} // namespace crimson::os::seastore
index ea7debc0d4cf69b5ae44e88dd48831ec81eb7f58..6b757d02fa9c4d3bf16aca6aae1626739c788588 100644 (file)
@@ -106,6 +106,24 @@ public:
   virtual backend_type_t get_type() = 0;
 
   virtual bool is_checksum_needed() = 0; 
+
+protected:
+  using alloc_map_t = std::map<paddr_t, journal_seq_t>;
+  using scan_alloc_map_ertr = replay_ertr;
+  using scan_alloc_map_ret = scan_alloc_map_ertr::future<alloc_map_t>;
+  scan_alloc_map_ret scan_alloc_map();
+
+  using scan_delta_handler_t = std::function<
+    replay_ertr::future<bool>(
+      const record_locator_t&,
+      const delta_info_t&,
+      sea_time_point modify_time)>;
+  virtual replay_ret scan_valid_record_delta(
+    scan_delta_handler_t &&delta_handler,
+    journal_seq_t tail) = 0;
+
+  virtual journal_seq_t get_dirty_tail() const = 0;
+  virtual journal_seq_t get_alloc_tail() const = 0;
 };
 using JournalRef = std::unique_ptr<Journal>;
 
index 4bb31172fd4681111ee343e191af5be626d40ef7..b7fe14c0512af0e5650a36f7d575d5a0882e1aaa 100644 (file)
@@ -141,7 +141,7 @@ CircularBoundedJournal::submit_record(
 }
 
 Journal::replay_ret CircularBoundedJournal::replay_segment(
-   cbj_delta_handler_t &handler, scan_valid_records_cursor& cursor)
+   scan_delta_handler_t &handler, scan_valid_records_cursor& cursor)
 {
   LOG_PREFIX(Journal::replay_segment);
   return seastar::do_with(
@@ -232,7 +232,7 @@ Journal::replay_ret CircularBoundedJournal::replay_segment(
 
 
 Journal::replay_ret CircularBoundedJournal::scan_valid_record_delta(
-   cbj_delta_handler_t &&handler, journal_seq_t tail)
+   scan_delta_handler_t &&handler, journal_seq_t tail)
 {
   LOG_PREFIX(Journal::scan_valid_record_delta);
   INFO("starting at {} ", tail);
@@ -341,7 +341,6 @@ Journal::replay_ret CircularBoundedJournal::replay(
   cjs.set_cbj_header(head);
   DEBUG("header : {}", cjs.get_cbj_header());
   cjs.set_initialized(true);
-  std::map<paddr_t, journal_seq_t> map;
   std::map<paddr_t, std::pair<CachedExtentRef, uint32_t>> crc_info;
   auto tail = get_dirty_tail() <= get_alloc_tail() ?
     get_dirty_tail() : get_alloc_tail();
@@ -360,27 +359,9 @@ Journal::replay_ret CircularBoundedJournal::replay(
     return replay_ertr::make_ready_future<bool>(true);
   };
   co_await scan_valid_record_delta(std::move(find_tail), tail);
-  tail = get_dirty_tail() <= get_alloc_tail() ?
-    get_dirty_tail() : get_alloc_tail();
-  auto build_paddr_seq_map = [&map](
-    const auto &offsets,
-    const auto &e,
-    sea_time_point modify_time)
-  {
-    if (e.type == extent_types_t::ALLOC_INFO) {
-      alloc_delta_t alloc_delta;
-      decode(alloc_delta, e.bl);
-      if (alloc_delta.op == alloc_delta_t::op_types_t::CLEAR) {
-        for (auto &alloc_blk : alloc_delta.alloc_blk_ranges) {
-          map[alloc_blk.paddr] = offsets.write_result.start_seq;
-        }
-      }
-    }
-    return replay_ertr::make_ready_future<bool>(true);
-  };
   // The second pass to build the paddr->journal_seq_t map
   // from extent allocations
-  co_await scan_valid_record_delta(std::move(build_paddr_seq_map), tail);
+  alloc_map_t map = co_await scan_alloc_map();
   auto call_d_handler_if_valid = [this, &map, &d_handler, &crc_info](
     const auto &offsets,
     const auto &e,
index 9facd14d6543319aa0876891aa12f714ec9772fe..e6af4c556ec1083e5c0d6d94b985a6ef95a07f58 100644 (file)
@@ -147,14 +147,8 @@ public:
     return cjs.get_records_start();
   }
 
-  using cbj_delta_handler_t = std::function<
-  replay_ertr::future<bool>(
-    const record_locator_t&,
-    const delta_info_t&,
-    sea_time_point modify_time)>;
-
   Journal::replay_ret scan_valid_record_delta(
-    cbj_delta_handler_t &&delta_handler,
+    scan_delta_handler_t &&delta_handler,
     journal_seq_t tail);
 
   void try_read_rolled_header(scan_valid_records_cursor &cursor) {
@@ -170,7 +164,7 @@ public:
   };
 
   Journal::replay_ret replay_segment(
-    cbj_delta_handler_t &handler, scan_valid_records_cursor& cursor);
+    scan_delta_handler_t &handler, scan_valid_records_cursor& cursor);
 
   read_ret read(paddr_t start, size_t len) final;
 
index 03c1e8721c62c1f488544a1d170c846ff4f03ec5..05c191b6c25256c792e4979e4cf6a0790421093f 100644 (file)
@@ -110,6 +110,20 @@ private:
     delta_handler_t &delta_handler,  ///< [in] processes deltas in order
     replay_stats_t &stats            ///< [out] replay stats
   );
+
+  journal_seq_t get_dirty_tail() const final {
+    return trimmer.get_dirty_tail();
+  }
+
+  journal_seq_t get_alloc_tail() const final {
+    return trimmer.get_alloc_tail();
+  }
+
+  replay_ret scan_valid_record_delta(
+    scan_delta_handler_t &&delta_handler,
+    journal_seq_t tail) final {
+    return replay_ertr::now();
+  }
 };
 
 }