From bf8b23bfde76df370b86360896f32116c7d98ebb Mon Sep 17 00:00:00 2001 From: Matan Breizman Date: Thu, 22 May 2025 13:08:33 +0000 Subject: [PATCH] mon: 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/mon/ElectionLogic.cc | 2 +- src/mon/LogMonitor.cc | 2 +- src/mon/MgrMonitor.cc | 2 +- src/mon/MonClient.cc | 2 +- src/mon/Monitor.cc | 4 ++-- src/mon/OSDMonitor.cc | 6 +++--- src/mon/PGMap.cc | 4 ++-- src/mon/Paxos.cc | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/mon/ElectionLogic.cc b/src/mon/ElectionLogic.cc index e24a80e9135..be0c35d06ac 100644 --- a/src/mon/ElectionLogic.cc +++ b/src/mon/ElectionLogic.cc @@ -86,7 +86,7 @@ void ElectionLogic::bump_epoch(epoch_t e) void ElectionLogic::declare_standalone_victory() { - assert(elector->paxos_size() == 1 && elector->get_my_rank() == 0); + ceph_assert(elector->paxos_size() == 1 && elector->get_my_rank() == 0); init(); bump_epoch(epoch+1); } diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index 33b554e16c7..3cd9c40e524 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -465,7 +465,7 @@ void LogMonitor::log_external_backlog() } else { // pre-quincy, we assumed that anything through summary.version was // logged externally. - assert(r == -ENOENT); + ceph_assert(r == -ENOENT); external_log_to = summary.version; dout(10) << __func__ << " initialized external_log_to = " << external_log_to << " (summary v " << summary.version << ")" << dendl; diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index 72b1d4e2745..9f9d3876f12 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -725,7 +725,7 @@ void MgrMonitor::on_active() return; } mon.clog->debug() << "mgrmap e" << map.epoch << ": " << map; - assert(HAVE_FEATURE(mon.get_quorum_con_features(), SERVER_NAUTILUS)); + ceph_assert(HAVE_FEATURE(mon.get_quorum_con_features(), SERVER_NAUTILUS)); if (pending_map.always_on_modules == always_on_modules()) { return; } diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index 5e83a2cf324..5770e6a2b0c 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -1861,7 +1861,7 @@ int MonConnection::handle_auth_bad_method( auth_registry->get_supported_methods(con->get_peer_type(), &auth_supported); auto p = std::find(auth_supported.begin(), auth_supported.end(), old_auth_method); - assert(p != auth_supported.end()); + ceph_assert(p != auth_supported.end()); p = std::find_first_of(std::next(p), auth_supported.end(), allowed_methods.begin(), allowed_methods.end()); if (p == auth_supported.end()) { diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index affd9732ed8..0c3dead2730 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -6545,7 +6545,7 @@ int Monitor::handle_auth_request( dout(1) << __func__ << " invalid mode " << (int)mode << dendl; return -EACCES; } - assert(mode >= AUTH_MODE_MON && mode <= AUTH_MODE_MON_MAX); + ceph_assert(mode >= AUTH_MODE_MON && mode <= AUTH_MODE_MON_MAX); decode(entity_name, p); decode(con->peer_global_id, p); } catch (ceph::buffer::error& e) { @@ -6677,7 +6677,7 @@ bool Monitor::ms_handle_fast_authentication(Connection *con) entity_name_t(con->get_peer_type(), -1), // we don't know yet con->get_peer_addrs(), con); - assert(s); + ceph_assert(s); dout(10) << __func__ << " adding session " << s << " to con " << con << dendl; con->set_priv(s); diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 0a9107c8839..f702f5b7cd0 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -7795,8 +7795,8 @@ int OSDMonitor::prepare_pool_size(const unsigned pool_type, *min_size = erasure_code->get_data_chunk_count() + std::min(1, erasure_code->get_coding_chunk_count() - 1); - assert(*min_size <= *size); - assert(*min_size >= erasure_code->get_data_chunk_count()); + ceph_assert(*min_size <= *size); + ceph_assert(*min_size >= erasure_code->get_data_chunk_count()); } } break; @@ -8678,7 +8678,7 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap, } if (osdmap.require_osd_release < ceph_release_t::nautilus) { // pre-nautilus osdmap format; increase pg_num directly - assert(n > (int)p.get_pg_num()); + ceph_assert(n > (int)p.get_pg_num()); // force pre-nautilus clients to resend their ops, since they // don't understand pg_num_target changes form a new interval p.last_force_op_resend_prenautilus = pending_inc.epoch; diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 07304cfcd8e..940b7ef9348 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -57,7 +57,7 @@ void PGMapDigest::encode(bufferlist& bl, uint64_t features) const { // NOTE: see PGMap::encode_digest uint8_t v = 5; - assert(HAVE_FEATURE(features, SERVER_NAUTILUS)); + ceph_assert(HAVE_FEATURE(features, SERVER_NAUTILUS)); ENCODE_START(v, 1, bl); encode(num_pg, bl); encode(num_pg_active, bl); @@ -84,7 +84,7 @@ void PGMapDigest::encode(bufferlist& bl, uint64_t features) const void PGMapDigest::decode(bufferlist::const_iterator& p) { DECODE_START(5, p); - assert(struct_v >= 4); + ceph_assert(struct_v >= 4); decode(num_pg, p); decode(num_pg_active, p); decode(num_pg_unknown, p); diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index 2a6167ec2e1..af6bc3f8fdc 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -979,7 +979,7 @@ void Paxos::handle_commit(MonOpRequestRef op) void Paxos::extend_lease() { ceph_assert(mon.is_leader()); - //assert(is_active()); + //ceph_assert(is_active()); lease_expire = ceph::real_clock::now(); lease_expire += ceph::make_timespan(g_conf()->mon_lease); -- 2.39.5