]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/.../btree_range_pin: use ceph_assert
authorSamuel Just <sjust@redhat.com>
Thu, 25 Mar 2021 20:12:11 +0000 (13:12 -0700)
committerSamuel Just <sjust@redhat.com>
Thu, 25 Mar 2021 20:13:59 +0000 (13:13 -0700)
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 <sjust@redhat.com>
src/crimson/os/seastore/lba_manager/btree/btree_range_pin.cc
src/crimson/os/seastore/lba_manager/btree/btree_range_pin.h

index a86c3cc57d8f696767d090114d57549787f43b5b..aab9d97c9a65d74ea1a63ec0029168e363dc3331 100644 (file)
@@ -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<void*>(parent));
index 571ce2f3fe4a6038f6d9f1b297e2952ee0bfa2e5..ba3d4dbd9b9a72c988ea73f2b087e1d6d55b5b26 100644 (file)
@@ -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<lba_node_meta_t, lba_node_meta_t>
   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;
   }