From 22025a6a75ec30e3f81090c42a415e8580876622 Mon Sep 17 00:00:00 2001 From: Matan Breizman Date: Tue, 20 May 2025 08:17:05 +0000 Subject: [PATCH] os: s/assert/ceph_assert/g' Now that we fallback to RelDebWithInfo [1], C asserts are not compiled in. Replace some of the existing asserts with ceph_assserts instead. [1] #61637 Fixes: https://tracker.ceph.com/issues/71360 Signed-off-by: Matan Breizman --- src/os/bluestore/BitmapFreelistManager.cc | 2 +- src/os/bluestore/BlueFS.cc | 8 ++++---- src/os/bluestore/BlueRocksEnv.cc | 2 +- src/os/bluestore/BlueStore.cc | 12 ++++++------ src/os/bluestore/BtreeAllocator.cc | 2 +- src/os/bluestore/bluefs_types.cc | 4 ++-- src/os/bluestore/bluestore_types.cc | 2 +- src/os/bluestore/fastbmap_allocator_impl.cc | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/os/bluestore/BitmapFreelistManager.cc b/src/os/bluestore/BitmapFreelistManager.cc index fe267f8a330..cb0b0c1df93 100644 --- a/src/os/bluestore/BitmapFreelistManager.cc +++ b/src/os/bluestore/BitmapFreelistManager.cc @@ -116,7 +116,7 @@ int BitmapFreelistManager::create(uint64_t new_size, uint64_t granularity, int BitmapFreelistManager::_expand(uint64_t old_size, KeyValueDB* db) { - assert(old_size < size); + ceph_assert(old_size < size); ceph_assert(std::has_single_bit(bytes_per_block)); KeyValueDB::Transaction txn; diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 195dced51f3..268e68119b8 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -1208,7 +1208,7 @@ int BlueFS::prepare_new_device(int id, const bluefs_layout_t& layout) REMOVE_WAL, layout); } else { - assert(false); + ceph_assert(false); } return 0; } @@ -1411,7 +1411,7 @@ int BlueFS::_replay(bool noop, bool to_stdout) if (r != (int)super.block_size && cct->_conf->bluefs_replay_recovery) { r += _do_replay_recovery_read(log_reader, pos, read_pos + r, super.block_size - r, &bl); } - assert(r == (int)super.block_size); + ceph_assert(r == (int)super.block_size); read_pos += r; } uint64_t more = 0; @@ -1948,7 +1948,7 @@ int BlueFS::device_migrate_to_existing( dout(10) << __func__ << " devs_source " << devs_source << " dev_target " << dev_target << dendl; - assert(dev_target < (int)MAX_BDEV); + ceph_assert(dev_target < (int)MAX_BDEV); int flags = 0; flags |= devs_source.count(BDEV_DB) ? @@ -2093,7 +2093,7 @@ int BlueFS::device_migrate_to_new( dout(10) << __func__ << " devs_source " << devs_source << " dev_target " << dev_target << dendl; - assert(dev_target == (int)BDEV_NEWDB || dev_target == (int)BDEV_NEWWAL); + ceph_assert(dev_target == (int)BDEV_NEWDB || dev_target == (int)BDEV_NEWWAL); int flags = 0; diff --git a/src/os/bluestore/BlueRocksEnv.cc b/src/os/bluestore/BlueRocksEnv.cc index fc4f60e1fc9..20993e007c8 100644 --- a/src/os/bluestore/BlueRocksEnv.cc +++ b/src/os/bluestore/BlueRocksEnv.cc @@ -36,7 +36,7 @@ std::pair split(const std::string &fn) { size_t slash = fn.rfind('/'); - assert(slash != fn.npos); + ceph_assert(slash != fn.npos); size_t file_begin = slash + 1; while (slash && fn[slash - 1] == '/') --slash; diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 5e8d245929b..70dfde2fe79 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -1250,7 +1250,7 @@ struct LruBufferCacheShard : public BlueStore::BufferCacheShard { void _rm(BlueStore::Buffer *b) override { ceph_assert(buffer_bytes >= b->length); buffer_bytes -= b->length; - assert(*(b->cache_age_bin) >= b->length); + ceph_assert(*(b->cache_age_bin) >= b->length); *(b->cache_age_bin) -= b->length; auto q = lru.iterator_to(*b); lru.erase(q); @@ -1263,7 +1263,7 @@ struct LruBufferCacheShard : public BlueStore::BufferCacheShard { void _adjust_size(BlueStore::Buffer *b, int64_t delta) override { ceph_assert((int64_t)buffer_bytes + delta >= 0); buffer_bytes += delta; - assert(*(b->cache_age_bin) + delta >= 0); + ceph_assert(*(b->cache_age_bin) + delta >= 0); *(b->cache_age_bin) += delta; } void _touch(BlueStore::Buffer *b) override { @@ -1289,7 +1289,7 @@ struct LruBufferCacheShard : public BlueStore::BufferCacheShard { BlueStore::Buffer *b = &*i; ceph_assert(b->is_clean()); dout(20) << __func__ << " rm " << *b << dendl; - assert(*(b->cache_age_bin) >= b->length); + ceph_assert(*(b->cache_age_bin) >= b->length); *(b->cache_age_bin) -= b->length; b->space->_rm_buffer(this, b); } @@ -1424,7 +1424,7 @@ public: buffer_bytes -= b->length; ceph_assert(list_bytes[b->cache_private] >= b->length); list_bytes[b->cache_private] -= b->length; - assert(*(b->cache_age_bin) >= b->length); + ceph_assert(*(b->cache_age_bin) >= b->length); *(b->cache_age_bin) -= b->length; } switch (b->cache_private) { @@ -1481,7 +1481,7 @@ public: buffer_bytes += delta; ceph_assert((int64_t)list_bytes[b->cache_private] + delta >= 0); list_bytes[b->cache_private] += delta; - assert(*(b->cache_age_bin) + delta >= 0); + ceph_assert(*(b->cache_age_bin) + delta >= 0); *(b->cache_age_bin) += delta; } } @@ -1551,7 +1551,7 @@ public: buffer_bytes -= b->length; ceph_assert(list_bytes[BUFFER_WARM_IN] >= b->length); list_bytes[BUFFER_WARM_IN] -= b->length; - assert(*(b->cache_age_bin) >= b->length); + ceph_assert(*(b->cache_age_bin) >= b->length); *(b->cache_age_bin) -= b->length; to_evict_bytes -= b->length; evicted += b->length; diff --git a/src/os/bluestore/BtreeAllocator.cc b/src/os/bluestore/BtreeAllocator.cc index acf664e696c..de3f6bb93d2 100644 --- a/src/os/bluestore/BtreeAllocator.cc +++ b/src/os/bluestore/BtreeAllocator.cc @@ -241,7 +241,7 @@ int64_t BtreeAllocator::_allocate( extents->emplace_back(offset, length); allocated += length; } - assert(range_size_tree.size() == range_tree.size()); + ceph_assert(range_size_tree.size() == range_tree.size()); return allocated ? allocated : -ENOSPC; } diff --git a/src/os/bluestore/bluefs_types.cc b/src/os/bluestore/bluefs_types.cc index 80e948a72f2..84978ddd99e 100644 --- a/src/os/bluestore/bluefs_types.cc +++ b/src/os/bluestore/bluefs_types.cc @@ -251,9 +251,9 @@ mempool::bluefs::vector::iterator bluefs_fnode_t::seek( if (extents_index.size() > 4) { auto it = std::upper_bound(extents_index.begin(), extents_index.end(), offset); - assert(it != extents_index.begin()); + ceph_assert(it != extents_index.begin()); --it; - assert(offset >= *it); + ceph_assert(offset >= *it); uint32_t skip = it - extents_index.begin(); ceph_assert(skip <= extents.size()); p += skip; diff --git a/src/os/bluestore/bluestore_types.cc b/src/os/bluestore/bluestore_types.cc index 7673b73dc1c..38bbe7fd7c3 100644 --- a/src/os/bluestore/bluestore_types.cc +++ b/src/os/bluestore/bluestore_types.cc @@ -1092,7 +1092,7 @@ bool bluestore_blob_t::release_extents(bool all, ++pext_it; } else { - //assert(pext_loffs == pext_loffs_start); + //ceph_assert(pext_loffs == pext_loffs_start); int delta0 = pext_loffs - pext_loffs_start; ceph_assert(delta0 >= 0); diff --git a/src/os/bluestore/fastbmap_allocator_impl.cc b/src/os/bluestore/fastbmap_allocator_impl.cc index 4833b9d1a7b..c1f8897e1d7 100644 --- a/src/os/bluestore/fastbmap_allocator_impl.cc +++ b/src/os/bluestore/fastbmap_allocator_impl.cc @@ -593,7 +593,7 @@ void AllocatorLevel01Loose::foreach_internal( if (p < bits_per_slot) { //now @p are 1s ssize_t free_count = count_1s(allocation_pattern, p); - assert(free_count > 0); + ceph_assert(free_count > 0); len = free_count; off = (pos + t) * bits_per_slot + p; p += free_count; -- 2.39.5