]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/transaction: change delayed_alloc_list/pre_alloc_list to CachedEx...
authorXuehan Xu <xuxuehan@qianxin.com>
Sun, 4 Feb 2024 09:23:18 +0000 (17:23 +0800)
committerXuehan Xu <xuxuehan@qianxin.com>
Mon, 22 Apr 2024 03:26:45 +0000 (11:26 +0800)
Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/crimson/os/seastore/extent_placement_manager.cc
src/crimson/os/seastore/extent_placement_manager.h
src/crimson/os/seastore/transaction.h

index 3acd3dbd63def59ac6fed8df1624dd737a4cc1b8..4d09e8da459534654a5e75ac62b50d6809bebe8c 100644 (file)
@@ -70,7 +70,7 @@ SegmentedOolWriter::write_record(
 SegmentedOolWriter::alloc_write_iertr::future<>
 SegmentedOolWriter::do_write(
   Transaction& t,
-  std::list<LogicalCachedExtentRef>& extents)
+  std::list<CachedExtentRef>& extents)
 {
   LOG_PREFIX(SegmentedOolWriter::do_write);
   assert(!extents.empty());
@@ -89,7 +89,9 @@ SegmentedOolWriter::do_write(
   auto commit_time = seastar::lowres_system_clock::now();
 
   for (auto it = extents.begin(); it != extents.end();) {
-    auto& extent = *it;
+    auto& ext = *it;
+    assert(ext->is_logical());
+    auto extent = ext->template cast<LogicalCachedExtent>();
     record_size_t wouldbe_rsize = record.size;
     wouldbe_rsize.account_extent(extent->get_bptr().length());
     using action_t = journal::RecordSubmitter::action_t;
@@ -167,7 +169,7 @@ SegmentedOolWriter::do_write(
 SegmentedOolWriter::alloc_write_iertr::future<>
 SegmentedOolWriter::alloc_write_ool_extents(
   Transaction& t,
-  std::list<LogicalCachedExtentRef>& extents)
+  std::list<CachedExtentRef>& extents)
 {
   if (extents.empty()) {
     return alloc_write_iertr::now();
@@ -340,14 +342,14 @@ ExtentPlacementManager::write_delayed_ool_extents(
 ExtentPlacementManager::alloc_paddr_iertr::future<>
 ExtentPlacementManager::write_preallocated_ool_extents(
     Transaction &t,
-    std::list<LogicalCachedExtentRef> extents)
+    std::list<CachedExtentRef> extents)
 {
   LOG_PREFIX(ExtentPlacementManager::write_preallocated_ool_extents);
   DEBUGT("start with {} allocated extents",
          t, extents.size());
   assert(writer_refs.size());
   return seastar::do_with(
-      std::map<ExtentOolWriter*, std::list<LogicalCachedExtentRef>>(),
+      std::map<ExtentOolWriter*, std::list<CachedExtentRef>>(),
       [this, &t, extents=std::move(extents)](auto& alloc_map) {
     for (auto& extent : extents) {
       auto writer_ptr = get_writer(
@@ -758,7 +760,7 @@ void ExtentPlacementManager::BackgroundProcess::register_metrics()
 RandomBlockOolWriter::alloc_write_iertr::future<>
 RandomBlockOolWriter::alloc_write_ool_extents(
   Transaction& t,
-  std::list<LogicalCachedExtentRef>& extents)
+  std::list<CachedExtentRef>& extents)
 {
   if (extents.empty()) {
     return alloc_write_iertr::now();
@@ -771,7 +773,7 @@ RandomBlockOolWriter::alloc_write_ool_extents(
 RandomBlockOolWriter::alloc_write_iertr::future<>
 RandomBlockOolWriter::do_write(
   Transaction& t,
-  std::list<LogicalCachedExtentRef>& extents)
+  std::list<CachedExtentRef>& extents)
 {
   LOG_PREFIX(RandomBlockOolWriter::do_write);
   assert(!extents.empty());
@@ -793,7 +795,8 @@ RandomBlockOolWriter::do_write(
     extent_len_t offset = 0;
     bufferptr bp;
     if (can_inplace_rewrite(t, ex)) {
-      auto r = ex->get_modified_region();
+      assert(ex->is_logical());
+      auto r = ex->template cast<LogicalCachedExtent>()->get_modified_region();
       ceph_assert(r.has_value());
       offset = p2align(r->offset, rbm->get_block_size());
       extent_len_t len =
@@ -816,7 +819,9 @@ RandomBlockOolWriter::do_write(
       if (ex->is_initial_pending()) {
        t.mark_allocated_extent_ool(ex);
       } else if (can_inplace_rewrite(t, ex)) {
-       t.mark_inplace_rewrite_extent_ool(ex);
+        assert(ex->is_logical());
+       t.mark_inplace_rewrite_extent_ool(
+          ex->template cast<LogicalCachedExtent>());
       } else {
        ceph_assert("impossible");
       }
index 6a71a4ca986458981bb732a87a0f2d619b12dfaf..141a019c7932b0bb919ea3c942db3ae94c3fc38b 100644 (file)
@@ -41,7 +41,7 @@ public:
   using alloc_write_iertr = trans_iertr<alloc_write_ertr>;
   virtual alloc_write_iertr::future<> alloc_write_ool_extents(
     Transaction &t,
-    std::list<LogicalCachedExtentRef> &extents) = 0;
+    std::list<CachedExtentRef> &extents) = 0;
 
   using close_ertr = base_ertr;
   virtual close_ertr::future<> close() = 0;
@@ -74,7 +74,7 @@ public:
 
   alloc_write_iertr::future<> alloc_write_ool_extents(
     Transaction &t,
-    std::list<LogicalCachedExtentRef> &extents) final;
+    std::list<CachedExtentRef> &extents) final;
 
   close_ertr::future<> close() final {
     return write_guard.close().then([this] {
@@ -100,7 +100,7 @@ public:
 private:
   alloc_write_iertr::future<> do_write(
     Transaction& t,
-    std::list<LogicalCachedExtentRef> &extent);
+    std::list<CachedExtentRef> &extent);
 
   alloc_write_ertr::future<> write_record(
     Transaction& t,
@@ -126,7 +126,7 @@ public:
 
   alloc_write_iertr::future<> alloc_write_ool_extents(
     Transaction &t,
-    std::list<LogicalCachedExtentRef> &extents) final;
+    std::list<CachedExtentRef> &extents) final;
 
   close_ertr::future<> close() final {
     return write_guard.close().then([this] {
@@ -166,7 +166,7 @@ public:
 private:
   alloc_write_iertr::future<> do_write(
     Transaction& t,
-    std::list<LogicalCachedExtentRef> &extent);
+    std::list<CachedExtentRef> &extent);
 
   RBMCleaner* rb_cleaner;
   seastar::gate write_guard;
@@ -407,10 +407,10 @@ public:
    * usage is used to reserve projected space
    */
   using extents_by_writer_t =
-    std::map<ExtentOolWriter*, std::list<LogicalCachedExtentRef>>;
+    std::map<ExtentOolWriter*, std::list<CachedExtentRef>>;
   struct dispatch_result_t {
     extents_by_writer_t alloc_map;
-    std::list<LogicalCachedExtentRef> delayed_extents;
+    std::list<CachedExtentRef> delayed_extents;
     io_usage_t usage;
   };
 
@@ -439,7 +439,7 @@ public:
    */
   alloc_paddr_iertr::future<> write_preallocated_ool_extents(
     Transaction &t,
-    std::list<LogicalCachedExtentRef> extents);
+    std::list<CachedExtentRef> extents);
 
   seastar::future<> stop_background() {
     return background_process.stop_background();
@@ -562,7 +562,7 @@ private:
    * Specify the extent inline or ool
    * return true indicates inline otherwise ool
    */
-  bool dispatch_delayed_extent(LogicalCachedExtentRef& extent) {
+  bool dispatch_delayed_extent(CachedExtentRef& extent) {
     // TODO: all delayed extents are ool currently
     boost::ignore_unused(extent);
     return false;
index a283982f699e19116be8cc0444dafbb98e2ffa85..8d77ee728a72f6dccad139031d0575eaa5c4e39e 100644 (file)
@@ -163,10 +163,10 @@ public:
       assert(ref->is_logical());
       ref->set_paddr(make_delayed_temp_paddr(delayed_temp_offset));
       delayed_temp_offset += ref->get_length();
-      delayed_alloc_list.emplace_back(ref->cast<LogicalCachedExtent>());
+      delayed_alloc_list.emplace_back(ref);
       fresh_block_stats.increment(ref->get_length());
     } else if (ref->get_paddr().is_absolute()) {
-      pre_alloc_list.emplace_back(ref->cast<LogicalCachedExtent>());
+      pre_alloc_list.emplace_back(ref);
       fresh_block_stats.increment(ref->get_length());
     } else {
       if (likely(ref->get_paddr() == make_record_relative_paddr(0))) {
@@ -187,7 +187,7 @@ public:
     return fresh_backref_extents;
   }
 
-  void mark_delayed_extent_inline(LogicalCachedExtentRef& ref) {
+  void mark_delayed_extent_inline(CachedExtentRef& ref) {
     write_set.erase(*ref);
     assert(ref->get_paddr().is_delayed());
     ref->set_paddr(make_record_relative_paddr(offset),
@@ -197,7 +197,7 @@ public:
     write_set.insert(*ref);
   }
 
-  void mark_delayed_extent_ool(LogicalCachedExtentRef& ref) {
+  void mark_delayed_extent_ool(CachedExtentRef& ref) {
     written_ool_block_list.push_back(ref);
   }
 
@@ -211,13 +211,13 @@ public:
     write_set.insert(*ref);
   }
 
-  void mark_allocated_extent_ool(LogicalCachedExtentRef& ref) {
+  void mark_allocated_extent_ool(CachedExtentRef& ref) {
     assert(ref->get_paddr().is_absolute());
     assert(!ref->is_inline());
     written_ool_block_list.push_back(ref);
   }
 
-  void mark_inplace_rewrite_extent_ool(LogicalCachedExtentRef& ref) {
+  void mark_inplace_rewrite_extent_ool(LogicalCachedExtentRef ref) {
     assert(ref->get_paddr().is_absolute());
     assert(!ref->is_inline());
     written_inplace_ool_block_list.push_back(ref);
@@ -269,7 +269,7 @@ public:
   }
 
   auto get_delayed_alloc_list() {
-    std::list<LogicalCachedExtentRef> ret;
+    std::list<CachedExtentRef> ret;
     for (auto& extent : delayed_alloc_list) {
       // delayed extents may be invalidated
       if (extent->is_valid()) {
@@ -283,7 +283,7 @@ public:
   }
 
   auto get_valid_pre_alloc_list() {
-    std::list<LogicalCachedExtentRef> ret;
+    std::list<CachedExtentRef> ret;
     assert(num_allocated_invalid_extents == 0);
     for (auto& extent : pre_alloc_list) {
       if (extent->is_valid()) {
@@ -551,10 +551,10 @@ private:
   uint64_t num_delayed_invalid_extents = 0;
   uint64_t num_allocated_invalid_extents = 0;
   /// fresh blocks with delayed allocation, may become inline or ool below
-  std::list<LogicalCachedExtentRef> delayed_alloc_list;
+  std::list<CachedExtentRef> delayed_alloc_list;
   /// fresh blocks with pre-allocated addresses with RBM,
   /// should be released upon conflicts, will be added to ool below
-  std::list<LogicalCachedExtentRef> pre_alloc_list;
+  std::list<CachedExtentRef> pre_alloc_list;
   /// dirty blocks for inplace rewrite with RBM, will be added to inplace ool below
   std::list<LogicalCachedExtentRef> pre_inplace_rewrite_list;