]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/seastore: add stub to introduce get_mapping() without length
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 27 May 2021 07:02:15 +0000 (15:02 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 28 May 2021 02:30:42 +0000 (10:30 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/lba_manager.h
src/crimson/os/seastore/lba_manager/btree/btree_lba_manager.cc
src/crimson/os/seastore/lba_manager/btree/btree_lba_manager.h
src/crimson/os/seastore/lba_manager/btree/lba_btree_node.h
src/crimson/os/seastore/transaction_manager.cc
src/crimson/os/seastore/transaction_manager.h
src/test/crimson/seastore/test_btree_lba_manager.cc

index 864637df1980eceaeb133ecd50454d83630c958f..22a548ede73c9cbcfb500b3bf4f31a53eeef113d 100644 (file)
@@ -42,23 +42,33 @@ public:
    *
    * Future will not resolve until all pins have resolved (set_paddr called)
    */
-  using get_mapping_ertr = base_ertr;
-  using get_mapping_ret = get_mapping_ertr::future<lba_pin_list_t>;
-  virtual get_mapping_ret get_mapping(
+  using get_mappings_ertr = base_ertr;
+  using get_mappings_ret = get_mappings_ertr::future<lba_pin_list_t>;
+  virtual get_mappings_ret get_mappings(
     Transaction &t,
     laddr_t offset, extent_len_t length) = 0;
 
   /**
-   * Fetches mappings for laddr_t in range [offset, offset + len)
+   * Fetches mappings for a list of laddr_t in range [offset, offset + len)
    *
-   * Future will not result until all pins have resolved (set_paddr called)
+   * Future will not resolve until all pins have resolved (set_paddr called)
    */
-  using get_mappings_ertr = base_ertr;
-  using get_mappings_ret = get_mapping_ertr::future<lba_pin_list_t>;
   virtual get_mappings_ret get_mappings(
     Transaction &t,
     laddr_list_t &&extent_lisk) = 0;
 
+  /**
+   * Fetches the mapping for laddr_t
+   *
+   * Future will not resolve until the pin has resolved (set_paddr called)
+   */
+  using get_mapping_ertr = base_ertr::extend<
+    crimson::ct_error::enoent>;
+  using get_mapping_ret = get_mapping_ertr::future<LBAPinRef>;
+  virtual get_mapping_ret get_mapping(
+    Transaction &t,
+    laddr_t offset) = 0;
+
   /**
    * Finds unmapped laddr extent of len len
    */
index c9b72df4df8ddf78ac22e65c7ded746715c77f86..c464994d6fdfdf8c8c1c95a315ab44a4320ee03f 100644 (file)
@@ -59,12 +59,12 @@ BtreeLBAManager::get_root(Transaction &t)
   });
 }
 
-BtreeLBAManager::get_mapping_ret
-BtreeLBAManager::get_mapping(
+BtreeLBAManager::get_mappings_ret
+BtreeLBAManager::get_mappings(
   Transaction &t,
   laddr_t offset, extent_len_t length)
 {
-  logger().debug("BtreeLBAManager::get_mapping: {}, {}", offset, length);
+  logger().debug("BtreeLBAManager::get_mappings: {}, {}", offset, length);
   return get_root(
     t).safe_then([this, &t, offset, length](auto extent) {
       return extent->lookup_range(
@@ -72,9 +72,9 @@ BtreeLBAManager::get_mapping(
        offset, length
       ).safe_then([extent](auto ret) { return ret; });
     }).safe_then([](auto &&e) {
-      logger().debug("BtreeLBAManager::get_mapping: got mapping {}", e);
-      return get_mapping_ret(
-       get_mapping_ertr::ready_future_marker{},
+      logger().debug("BtreeLBAManager::get_mappings: got mappings {}", e);
+      return get_mappings_ret(
+       get_mappings_ertr::ready_future_marker{},
        std::move(e));
     });
 }
@@ -93,7 +93,7 @@ BtreeLBAManager::get_mappings(
     l->begin(),
     l->end(),
     [this, &t, &ret](const auto &p) {
-      return get_mapping(t, p.first, p.second).safe_then(
+      return get_mappings(t, p.first, p.second).safe_then(
        [&ret](auto res) {
          ret.splice(ret.end(), res, res.begin(), res.end());
        });
@@ -102,6 +102,14 @@ BtreeLBAManager::get_mappings(
     });
 }
 
+BtreeLBAManager::get_mapping_ret
+BtreeLBAManager::get_mapping(
+  Transaction &t,
+  laddr_t offset)
+{
+  ceph_abort("not implemented");
+}
+
 BtreeLBAManager::find_hole_ret
 BtreeLBAManager::find_hole(
   Transaction &t,
index a03b24233410886a70e348c7398627bdf0d3eb1f..d2c21ed2cc034c9a7255554b76197799907be9a5 100644 (file)
@@ -50,7 +50,7 @@ public:
   mkfs_ret mkfs(
     Transaction &t) final;
 
-  get_mapping_ret get_mapping(
+  get_mappings_ret get_mappings(
     Transaction &t,
     laddr_t offset, extent_len_t length) final;
 
@@ -58,6 +58,10 @@ public:
     Transaction &t,
     laddr_list_t &&list) final;
 
+  get_mapping_ret get_mapping(
+    Transaction &t,
+    laddr_t offset) final;
+
   find_hole_ret find_hole(
     Transaction &t,
     laddr_t hint,
index 17c9e09ea27ac24d1eb495f57d810f04ced60047..516defd14b4073efc8569bae90ab6e4f3b7fc572 100644 (file)
@@ -50,8 +50,8 @@ using BtreeLBAPinRef = std::unique_ptr<BtreeLBAPin>;
  */
 struct LBANode : CachedExtent {
   using LBANodeRef = TCachedExtentRef<LBANode>;
-  using lookup_range_ertr = LBAManager::get_mapping_ertr;
-  using lookup_range_ret = LBAManager::get_mapping_ret;
+  using lookup_range_ertr = LBAManager::get_mappings_ertr;
+  using lookup_range_ret = LBAManager::get_mappings_ret;
 
   btree_range_pin_t pin;
 
index 2cba0ffb3eabd0aa9fe9c605eb7ab326ccb4724a..84f748d6945ec100191279de58eb016bf1fc0aaf 100644 (file)
@@ -321,7 +321,8 @@ TransactionManager::get_extent_if_live_ret TransactionManager::get_extent_if_liv
     }
 
     if (is_logical_type(type)) {
-      return lba_manager->get_mapping(
+      // TODO: switch to get_mapping()
+      return lba_manager->get_mappings(
        t,
        laddr,
        len).safe_then([=, &t](lba_pin_list_t pins) {
index 586f2f956472ff783f397c228fc844d400f1859b..7e4997953aeac96713ca4849085a7e400ebb88f4 100644 (file)
@@ -126,13 +126,13 @@ public:
    *
    * Get logical pins overlapping offset~length
    */
-  using get_pins_ertr = LBAManager::get_mapping_ertr;
+  using get_pins_ertr = LBAManager::get_mappings_ertr;
   using get_pins_ret = get_pins_ertr::future<lba_pin_list_t>;
   get_pins_ret get_pins(
     Transaction &t,
     laddr_t offset,
     extent_len_t length) {
-    return lba_manager->get_mapping(
+    return lba_manager->get_mappings(
       t, offset, length);
   }
 
index a7e2b96689a0eb3c84f4e2e880b5cbc87e6c2e49..281ad92c0188d970f37aea0bd66987d95e85b29c 100644 (file)
@@ -272,7 +272,7 @@ struct btree_lba_manager_test :
 
   void check_mappings(test_transaction_t &t) {
     for (auto &&i: t.mappings) {
-      auto ret_list = lba_manager->get_mapping(
+      auto ret_list = lba_manager->get_mappings(
        *t.t, i.first, i.second.len
       ).unsafe_get0();
       EXPECT_EQ(ret_list.size(), 1);
@@ -280,6 +280,7 @@ struct btree_lba_manager_test :
       EXPECT_EQ(i.second.addr, ret->get_paddr());
       EXPECT_EQ(i.first, ret->get_laddr());
       EXPECT_EQ(i.second.len, ret->get_length());
+      // TODO: test get_mapping()
     }
     lba_manager->scan_mappings(
       *t.t,