]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/crimson/os/seastore/btree/btree_range_pin.h
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / crimson / os / seastore / btree / btree_range_pin.h
index fef89197fd9ec6238f0d217e45faa02babf63a2b..68188e9ff55022b91df5fd528b7120a51e871d04 100644 (file)
@@ -21,21 +21,6 @@ struct op_context_t {
 
 constexpr uint16_t MAX_FIXEDKVBTREE_DEPTH = 8;
 
-template <typename T>
-struct min_max_t {};
-
-template <>
-struct min_max_t<laddr_t> {
-  static constexpr laddr_t max = L_ADDR_MAX;
-  static constexpr laddr_t min = L_ADDR_MIN;
-};
-
-template <>
-struct min_max_t<paddr_t> {
-  static constexpr paddr_t max = P_ADDR_MAX;
-  static constexpr paddr_t min = P_ADDR_MIN;
-};
-
 template <typename bound_t>
 struct fixed_kv_node_meta_t {
   bound_t begin = min_max_t<bound_t>::min;
@@ -117,7 +102,7 @@ struct fixed_kv_node_meta_le_t {
 
 template <typename key_t, typename val_t>
 class BtreeNodeMapping : public PhysicalNodeMapping<key_t, val_t> {
-
+protected:
   op_context_t<key_t> ctx;
   /**
    * parent
@@ -127,11 +112,16 @@ class BtreeNodeMapping : public PhysicalNodeMapping<key_t, val_t> {
    */
   CachedExtentRef parent;
 
-  val_t value;
-  extent_len_t len;
+  pladdr_t value;
+  extent_len_t len = 0;
   fixed_kv_node_meta_t<key_t> range;
   uint16_t pos = std::numeric_limits<uint16_t>::max();
 
+  virtual std::unique_ptr<BtreeNodeMapping> _duplicate(op_context_t<key_t>) const = 0;
+  fixed_kv_node_meta_t<key_t> _get_pin_range() const {
+    return range;
+  }
+
 public:
   using val_type = val_t;
   BtreeNodeMapping(op_context_t<key_t> ctx) : ctx(ctx) {}
@@ -140,14 +130,14 @@ public:
     op_context_t<key_t> ctx,
     CachedExtentRef parent,
     uint16_t pos,
-    val_t &value,
+    pladdr_t value,
     extent_len_t len,
-    fixed_kv_node_meta_t<key_t> &&meta)
+    fixed_kv_node_meta_t<key_t> meta)
     : ctx(ctx),
       parent(parent),
       value(value),
       len(len),
-      range(std::move(meta)),
+      range(meta),
       pos(pos)
   {
     if (!parent->is_pending()) {
@@ -182,16 +172,20 @@ public:
   }
 
   val_t get_val() const final {
-    return value;
+    if constexpr (std::is_same_v<val_t, paddr_t>) {
+      return value.get_paddr();
+    } else {
+      static_assert(std::is_same_v<val_t, laddr_t>);
+      return value.get_laddr();
+    }
   }
 
-  key_t get_key() const final {
+  key_t get_key() const override {
     return range.begin;
   }
 
   PhysicalNodeMappingRef<key_t, val_t> duplicate() const final {
-    auto ret = std::unique_ptr<BtreeNodeMapping<key_t, val_t>>(
-      new BtreeNodeMapping<key_t, val_t>(ctx));
+    auto ret = _duplicate(ctx);
     ret->range = range;
     ret->value = value;
     ret->parent = parent;