From: Samuel Just Date: Thu, 25 Mar 2021 20:12:11 +0000 (-0700) Subject: crimson/os/seastore/.../btree_range_pin: use ceph_assert X-Git-Tag: v17.1.0~2478^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0408a6099720eb9d07d27096597591cd328603b7;p=ceph.git crimson/os/seastore/.../btree_range_pin: use ceph_assert There's a performance overhead, but seastore is quite immature and detecting these logic errors saves a ton of debugging time. Signed-off-by: Samuel Just --- diff --git a/src/crimson/os/seastore/lba_manager/btree/btree_range_pin.cc b/src/crimson/os/seastore/lba_manager/btree/btree_range_pin.cc index a86c3cc57d8f6..aab9d97c9a65d 100644 --- a/src/crimson/os/seastore/lba_manager/btree/btree_range_pin.cc +++ b/src/crimson/os/seastore/lba_manager/btree/btree_range_pin.cc @@ -15,8 +15,8 @@ namespace crimson::os::seastore::lba_manager::btree { void btree_range_pin_t::take_pin(btree_range_pin_t &other) { - assert(other.extent); - assert(other.pins); + ceph_assert(other.extent); + ceph_assert(other.pins); other.pins->replace_pin(*this, other); pins = other.pins; other.pins = nullptr; @@ -29,8 +29,8 @@ void btree_range_pin_t::take_pin(btree_range_pin_t &other) btree_range_pin_t::~btree_range_pin_t() { - assert(!pins == !is_linked()); - assert(!ref); + ceph_assert(!pins == !is_linked()); + ceph_assert(!ref); if (pins) { logger().debug("{}: removing {}", __func__, *this); pins->remove_pin(*this, true); @@ -46,9 +46,9 @@ void btree_pin_set_t::replace_pin(btree_range_pin_t &to, btree_range_pin_t &from void btree_pin_set_t::remove_pin(btree_range_pin_t &pin, bool do_check_parent) { logger().debug("{}: {}", __func__, pin); - assert(pin.is_linked()); - assert(pin.pins); - assert(!pin.ref); + ceph_assert(pin.is_linked()); + ceph_assert(pin.pins); + ceph_assert(!pin.ref); pins.erase(pin); pin.pins = nullptr; @@ -98,7 +98,7 @@ const btree_range_pin_t *btree_pin_set_t::maybe_get_first_child( void btree_pin_set_t::release_if_no_children(btree_range_pin_t &pin) { - assert(pin.is_linked()); + ceph_assert(pin.is_linked()); if (maybe_get_first_child(pin.range) == nullptr) { pin.drop_ref(); } @@ -106,20 +106,20 @@ void btree_pin_set_t::release_if_no_children(btree_range_pin_t &pin) void btree_pin_set_t::add_pin(btree_range_pin_t &pin) { - assert(!pin.is_linked()); - assert(!pin.pins); - assert(!pin.ref); + ceph_assert(!pin.is_linked()); + ceph_assert(!pin.pins); + ceph_assert(!pin.ref); auto [prev, inserted] = pins.insert(pin); if (!inserted) { logger().error("{}: unable to add {}, found {}", __func__, pin, *prev); - assert(0 == "impossible"); + ceph_assert(0 == "impossible"); return; } pin.pins = this; if (!pin.is_root()) { auto *parent = maybe_get_parent(pin.range); - assert(parent); + ceph_assert(parent); if (!parent->has_ref()) { logger().debug("{}: acquiring parent {}", __func__, static_cast(parent)); diff --git a/src/crimson/os/seastore/lba_manager/btree/btree_range_pin.h b/src/crimson/os/seastore/lba_manager/btree/btree_range_pin.h index 571ce2f3fe4a6..ba3d4dbd9b9a7 100644 --- a/src/crimson/os/seastore/lba_manager/btree/btree_range_pin.h +++ b/src/crimson/os/seastore/lba_manager/btree/btree_range_pin.h @@ -32,13 +32,13 @@ struct lba_node_meta_t { static lba_node_meta_t merge_from( const lba_node_meta_t &lhs, const lba_node_meta_t &rhs) { - assert(lhs.depth == rhs.depth); + ceph_assert(lhs.depth == rhs.depth); return lba_node_meta_t{lhs.begin, rhs.end, lhs.depth}; } static std::pair rebalance(const lba_node_meta_t &lhs, const lba_node_meta_t &rhs, laddr_t pivot) { - assert(lhs.depth == rhs.depth); + ceph_assert(lhs.depth == rhs.depth); return std::make_pair( lba_node_meta_t{lhs.begin, pivot, lhs.depth}, lba_node_meta_t{pivot, rhs.end, lhs.depth}); @@ -113,7 +113,7 @@ public: range = nrange; } void set_extent(CachedExtent *nextent) { - assert(!extent); + ceph_assert(!extent); extent = nextent; } @@ -213,7 +213,7 @@ public: void check_parent(btree_range_pin_t &pin); ~btree_pin_set_t() { - assert(pins.empty()); + ceph_assert(pins.empty()); } }; @@ -247,7 +247,7 @@ public: } extent_len_t get_length() const final { - assert(pin.range.end > pin.range.begin); + ceph_assert(pin.range.end > pin.range.begin); return pin.range.end - pin.range.begin; }