]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/.../lba_btree: fix lower_bound at_boundary()
authorSamuel Just <sjust@redhat.com>
Mon, 25 Oct 2021 06:26:05 +0000 (06:26 +0000)
committerSamuel Just <sjust@redhat.com>
Mon, 25 Oct 2021 19:59:36 +0000 (19:59 +0000)
Clarify that lookup_depth_range may return an iterator at_boundary() and
audity users.

Fix LBABtree::lookup to correctly handle at_boundary() after the call to
lookup_depth_range.

Fixes: https://tracker.ceph.com/issues/52805
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 ba166fb127ad09d117d49d3aed48e56c0af1f1c0..3190d59d48b7aca51a0e2ec71c1e52aef1e01ede 100644 (file)
@@ -44,6 +44,7 @@ LBABtree::iterator::handle_boundary_ret LBABtree::iterator::handle_boundary(
        }
        leaf.reset();
        get_internal(depth_with_space).pos++;
+       // note, cannot result in at_boundary() by construction
        return lookup_depth_range(
          c, *this, depth_with_space - 1, 0, li, ll, visitor
        );
@@ -113,9 +114,11 @@ LBABtree::iterator_fut LBABtree::iterator::prev(op_context_t c) const
       }
       ret.leaf.reset();
       ret.get_internal(depth_with_space).pos--;
+      // note, cannot result in at_boundary() by construction
       return lookup_depth_range(
        c, ret, depth_with_space - 1, 0, li, ll, nullptr
       ).si_then([&ret] {
+       assert(!ret.at_boundary());
        return std::move(ret);
       });
     });
index 10ec1a6b04c6220030a4c0e048456bdca7620bf4..dedf8e239e42a6dbae6b4510bdc7c33e78a49c6a 100644 (file)
@@ -494,6 +494,14 @@ private:
     });
   }
 
+  /**
+   * lookup_depth_range
+   *
+   * Performs node lookups on depths [from, to) using li and ll to
+   * specific target at each level.  Note, may leave the iterator
+   * at_boundary(), call handle_boundary() prior to returning out
+   * lf LBABtree.
+   */
   using lookup_depth_range_iertr = base_iertr;
   using lookup_depth_range_ret = lookup_depth_range_iertr::future<>;
   template <typename LI, typename LL>
@@ -579,7 +587,14 @@ private:
            0,
            li,
            ll,
-           visitor);
+           visitor
+         ).si_then([c, visitor, &iter] {
+           if (iter.at_boundary()) {
+             return iter.handle_boundary(c, visitor);
+           } else {
+             return lookup_iertr::now();
+           }
+         });
        }).si_then([&iter] {
          return std::move(iter);
        });