]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
seastore: free allocated extent if extent is retiered
authormyoungwon oh <myoungwon.oh@samsung.com>
Fri, 13 Aug 2021 03:55:17 +0000 (12:55 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Sat, 23 Oct 2021 14:33:11 +0000 (23:33 +0900)
This commit frees allocated extent  when the extent is retired

Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/cache.h
src/crimson/os/seastore/random_block_manager.h
src/crimson/os/seastore/random_block_manager/nvme_manager.cc
src/crimson/os/seastore/random_block_manager/nvme_manager.h
src/crimson/os/seastore/seastore_types.h
src/crimson/os/seastore/transaction.h
src/test/crimson/seastore/test_randomblock_manager.cc

index f67614d6f41e27ff981c8739120bf7c9d159b9b2..f0eb8370958c563d4dfdd49fb36d2b385c7cc28a 100644 (file)
@@ -947,6 +947,13 @@ record_t Cache::prepare_record(Transaction &t)
     get_by_ext(efforts.retire_by_ext,
                i->get_type()).increment(i->get_length());
     retire_extent(i);
+    if (i->backend_type == device_type_t::RANDOM_BLOCK) {
+      paddr_t paddr = i->get_paddr();
+      rbm_alloc_delta_t delta;
+      delta.op = rbm_alloc_delta_t::op_types_t::CLEAR;
+      delta.alloc_blk_ranges.push_back(std::make_pair(paddr, i->get_length()));
+      t.add_rbm_alloc_info_blocks(delta);
+    }
   }
 
   record.extents.reserve(t.inline_block_list.size());
@@ -979,6 +986,15 @@ record_t Cache::prepare_record(Transaction &t)
       });
   }
 
+  for (auto b : t.rbm_alloc_info_blocks) {
+    bufferlist bl;
+    encode(b, bl);
+    delta_info_t delta;
+    delta.type = extent_types_t::RBM_ALLOC_INFO;
+    delta.bl = bl;
+    record.deltas.push_back(delta);
+  }
+
   for (auto &i: t.ool_block_list) {
     ceph_assert(i->is_valid());
     DEBUGT("fresh ool block {}", t, *i);
index 5b2afa5c37d2f5453ca383e3a0ab01e8575dcfe9..7ad1af4a8762294b740f11f5e7d4bb7cc3032d43 100644 (file)
@@ -17,6 +17,7 @@
 #include "crimson/os/seastore/cached_extent.h"
 #include "crimson/os/seastore/root_block.h"
 #include "crimson/os/seastore/segment_cleaner.h"
+#include "crimson/os/seastore/random_block_manager.h"
 
 namespace crimson::os::seastore {
 
index eb619739cd329a6bfa9fa80b85bea97a14453358..5208c01abd1262387217def356c2b1e82a1e830a 100644 (file)
@@ -75,13 +75,6 @@ public:
     >;
   virtual allocate_ertr::future<> alloc_extent(Transaction &t, size_t size) = 0; // allocator, return blocks
 
-  using free_block_ertr = crimson::errorator<
-    crimson::ct_error::input_output_error,
-    crimson::ct_error::invarg
-    >;
-  // TODO: will include trim if necessary
-  virtual free_block_ertr::future<> free_extent(Transaction &t, blk_paddr_t from, size_t len) = 0;
-
   using abort_allocation_ertr = crimson::errorator<
     crimson::ct_error::input_output_error,
     crimson::ct_error::invarg
index 42410214c772806b99266e06fd279453ccffa233..6f9c89b429e5d41f13b974c78d251f375d5d756a 100644 (file)
@@ -293,13 +293,7 @@ NVMeManager::allocate_ertr::future<> NVMeManager::alloc_extent(
        );
 }
 
-NVMeManager::free_block_ertr::future<> NVMeManager::free_extent(
-    Transaction &t, blk_paddr_t from, size_t len)
-{
-  return free_block_ertr::now();
-}
-
-NVMeManager::free_block_ertr::future<> NVMeManager::add_free_extent(
+void NVMeManager::add_free_extent(
     std::vector<rbm_alloc_delta_t>& v, blk_paddr_t from, size_t len)
 {
   ceph_assert(!(len % super.block_size));
@@ -312,7 +306,6 @@ NVMeManager::free_block_ertr::future<> NVMeManager::add_free_extent(
   alloc_info.alloc_blk_ranges.push_back(std::make_pair(paddr, len));
   alloc_info.op = rbm_alloc_delta_t::op_types_t::CLEAR;
   v.push_back(alloc_info);
-  return free_block_ertr::now();
 }
 
 NVMeManager::write_ertr::future<> NVMeManager::rbm_sync_block_bitmap_by_range(
index 04ba5d12c52f722f2f5d249f067105263bda64b4..9842db2114b38bd4296f738a9f509070b05b2d21 100644 (file)
@@ -212,9 +212,6 @@ public:
    * add a range of free blocks to transaction
    *
    */
-  // TODO: will include trim if necessary
-  free_block_ertr::future<> free_extent(
-      Transaction &t, blk_paddr_t from, size_t len) final;
   abort_allocation_ertr::future<> abort_allocation(Transaction &t) final;
   write_ertr::future<> complete_allocation(Transaction &t) final;
 
@@ -359,7 +356,7 @@ public:
   write_ertr::future<> write(blk_paddr_t addr, bufferlist &bl);
   write_ertr::future<> sync_allocation(
       std::vector<rbm_alloc_delta_t>& alloc_blocks);
-  free_block_ertr::future<> add_free_extent(
+  void add_free_extent(
       std::vector<rbm_alloc_delta_t>& v, blk_paddr_t from, size_t len);
 
   uint32_t get_blocks_per_segment() const final {
index 5a186765916168856abbbee542a4bd1aca92f7b9..226010713884a6ea0293ff2740760ca24105c4b7 100644 (file)
@@ -1233,6 +1233,7 @@ WRITE_CLASS_DENC_BOUNDED(crimson::os::seastore::delta_info_t)
 WRITE_CLASS_DENC_BOUNDED(crimson::os::seastore::record_header_t)
 WRITE_CLASS_DENC_BOUNDED(crimson::os::seastore::extent_info_t)
 WRITE_CLASS_DENC_BOUNDED(crimson::os::seastore::segment_header_t)
+WRITE_CLASS_DENC_BOUNDED(crimson::os::seastore::rbm_alloc_delta_t)
 
 template<>
 struct denc_traits<crimson::os::seastore::device_type_t> {
index 4d406db99f989de77d7015be433f79d53a8f4607..4efbeca5f8361ba21ba8af80d6777ea5a6f52a74 100644 (file)
@@ -299,6 +299,17 @@ public:
   tree_stats_t& get_lba_tree_stats() {
     return lba_tree_stats;
   }
+  void add_rbm_alloc_info_blocks(rbm_alloc_delta_t &d) {
+    rbm_alloc_info_blocks.push_back(d);
+  }
+  void clear_rbm_alloc_info_blocks() {
+    if (!rbm_alloc_info_blocks.empty()) {
+      rbm_alloc_info_blocks.clear();
+    }
+  }
+  const auto &get_rbm_alloc_info_blocks() {
+    return rbm_alloc_info_blocks;
+  }
 
   struct ool_write_stats_t {
     io_stat_t extents;
@@ -387,6 +398,8 @@ private:
   on_destruct_func_t on_destruct;
 
   const src_t src;
+
+  std::vector<rbm_alloc_delta_t> rbm_alloc_info_blocks;
 };
 using TransactionRef = Transaction::Ref;
 
index 563db420e205a39759fea4bc075a3b208d80adfe..223f54029398198fac3a1e75fb320481c652fcd5 100644 (file)
@@ -133,7 +133,7 @@ struct rbm_test_t : public  seastar_test_suite_t,
       logger().debug("free_extent: start {} len {}", off * DEFAULT_BLOCK_SIZE,
                      len * DEFAULT_BLOCK_SIZE);
       rbm_manager->add_free_extent(t.allocated_blocks, off * DEFAULT_BLOCK_SIZE,
-                                   len * DEFAULT_BLOCK_SIZE).unsafe_get();
+                                   len * DEFAULT_BLOCK_SIZE);
     }
   }