From: Samuel Just Date: Mon, 25 Oct 2021 06:26:05 +0000 (+0000) Subject: crimson/os/seastore/.../lba_btree: fix lower_bound at_boundary() X-Git-Tag: v17.1.0~607^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=542d237ffef70b60f851320ac7432c331859d47e;p=ceph-ci.git crimson/os/seastore/.../lba_btree: fix lower_bound at_boundary() 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 --- diff --git a/src/crimson/os/seastore/lba_manager/btree/lba_btree.cc b/src/crimson/os/seastore/lba_manager/btree/lba_btree.cc index ba166fb127a..3190d59d48b 100644 --- a/src/crimson/os/seastore/lba_manager/btree/lba_btree.cc +++ b/src/crimson/os/seastore/lba_manager/btree/lba_btree.cc @@ -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); }); }); diff --git a/src/crimson/os/seastore/lba_manager/btree/lba_btree.h b/src/crimson/os/seastore/lba_manager/btree/lba_btree.h index 10ec1a6b04c..dedf8e239e4 100644 --- a/src/crimson/os/seastore/lba_manager/btree/lba_btree.h +++ b/src/crimson/os/seastore/lba_manager/btree/lba_btree.h @@ -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 @@ -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); });