]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore/lba_manager/lba_btree: add at_boundary helper distinct from is_end
authorSamuel Just <sjust@redhat.com>
Mon, 25 Oct 2021 06:03:33 +0000 (23:03 -0700)
committerSamuel Just <sjust@redhat.com>
Mon, 25 Oct 2021 19:59:36 +0000 (19:59 +0000)
From an external caller, the condition is identical.  However, internally
iterators may be at a leaf boundary without being at end().  For those
checks, use at_boundary() instead.

Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/os/seastore/lba_manager/btree/lba_btree.cc
src/crimson/os/seastore/lba_manager/btree/lba_btree.h

index 31770ed688eb8c2c6b3826032add8497de4db3ce..a1a324f62d20be5a49367bc7eab662649c8c72d5 100644 (file)
@@ -166,7 +166,7 @@ LBABtree::insert_ret LBABtree::insert(
       return find_insertion(
        c, laddr, ret
       ).si_then([this, c, laddr, val, &ret] {
-       if (!ret.is_end() && ret.get_key() == laddr) {
+       if (!ret.at_boundary() && ret.get_key() == laddr) {
          return insert_ret(
            interruptible::ready_future_marker{},
            std::make_pair(ret, false));
@@ -488,7 +488,7 @@ LBABtree::find_insertion_ret LBABtree::find_insertion(
       // invariant that pos is a valid index for the node in the event
       // that the insertion point is at the end of a node.
       p.leaf.pos++;
-      assert(p.is_end());
+      assert(p.at_boundary());
       iter = p;
       return seastar::now();
     });
index 6afa31f4ccde6a824b5c067876c95b51cbb50be7..3364446862b224d1095b3e48f92f02a46ac7cc76 100644 (file)
@@ -87,8 +87,8 @@ public:
     }
 
     bool is_end() const {
-      assert(leaf.pos <= leaf.node->get_size());
-      return leaf.pos == leaf.node->get_size();
+      // external methods may only resolve at a boundary if at end
+      return at_boundary();
     }
 
     bool is_begin() const {
@@ -134,6 +134,11 @@ public:
       node_position_t<LBAInternalNode>, MAX_DEPTH> internal;
     node_position_t<LBALeafNode> leaf;
 
+    bool at_boundary() const {
+      assert(leaf.pos <= leaf.node->get_size());
+      return leaf.pos == leaf.node->get_size();
+    }
+
     depth_t check_split() const {
       if (!leaf.node->at_max_capacity()) {
        return 0;