From 915096910378bd54194b3990c9e11f18f5e02ab9 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Thu, 23 Aug 2018 11:20:29 -0400 Subject: [PATCH] mon: Use ceph_assert for asserts. Signed-off-by: Adam C. Emerson --- src/ceph_mon.cc | 14 +-- src/mon/AuthMonitor.cc | 60 ++++----- src/mon/AuthMonitor.h | 2 +- src/mon/ConfigKeyService.cc | 12 +- src/mon/ConfigMonitor.cc | 4 +- src/mon/Elector.cc | 24 ++-- src/mon/FSCommands.cc | 18 +-- src/mon/HealthMonitor.cc | 2 +- src/mon/LogMonitor.cc | 16 +-- src/mon/MDSMonitor.cc | 38 +++--- src/mon/MgrMap.h | 2 +- src/mon/MgrMonitor.cc | 10 +- src/mon/MgrStatMonitor.cc | 4 +- src/mon/MonClient.cc | 42 +++---- src/mon/MonMap.cc | 4 +- src/mon/MonMap.h | 26 ++-- src/mon/Monitor.cc | 232 +++++++++++++++++------------------ src/mon/Monitor.h | 4 +- src/mon/MonitorDBStore.h | 24 ++-- src/mon/MonmapMonitor.cc | 22 ++-- src/mon/OSDMonitor.cc | 234 ++++++++++++++++++------------------ src/mon/OSDMonitor.h | 6 +- src/mon/PGMap.cc | 32 ++--- src/mon/Paxos.cc | 102 ++++++++-------- src/mon/Paxos.h | 8 +- src/mon/PaxosFSMap.h | 6 +- src/mon/PaxosService.cc | 16 +-- src/mon/PaxosService.h | 8 +- src/mon/Session.h | 10 +- src/mon/health_check.h | 2 +- src/mon/mon_types.h | 8 +- 31 files changed, 496 insertions(+), 496 deletions(-) diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index adff949480fd4..eb0152d7f51da 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -70,8 +70,8 @@ int obtain_monmap(MonitorDBStore &store, bufferlist &bl) version_t latest_ver = store.get("monmap", "last_committed"); if (store.exists("monmap", latest_ver)) { int err = store.get("monmap", latest_ver, bl); - assert(err == 0); - assert(bl.length() > 0); + ceph_assert(err == 0); + ceph_assert(bl.length() > 0); dout(10) << __func__ << " read last committed monmap ver " << latest_ver << dendl; return 0; @@ -83,8 +83,8 @@ int obtain_monmap(MonitorDBStore &store, bufferlist &bl) dout(10) << __func__ << " detected aborted sync" << dendl; if (store.exists("mon_sync", "latest_monmap")) { int err = store.get("mon_sync", "latest_monmap", bl); - assert(err == 0); - assert(bl.length() > 0); + ceph_assert(err == 0); + ceph_assert(bl.length() > 0); dout(10) << __func__ << " read backup monmap" << dendl; return 0; } @@ -93,8 +93,8 @@ int obtain_monmap(MonitorDBStore &store, bufferlist &bl) if (store.exists("mkfs", "monmap")) { dout(10) << __func__ << " found mkfs monmap" << dendl; int err = store.get("mkfs", "monmap", bl); - assert(err == 0); - assert(bl.length() > 0); + ceph_assert(err == 0); + ceph_assert(bl.length() > 0); return 0; } @@ -430,7 +430,7 @@ int main(int argc, const char **argv) << g_conf()->mon_data << "': " << cpp_strerror(r) << dendl; exit(1); } - assert(r == 0); + ceph_assert(r == 0); Monitor mon(g_ceph_context, g_conf()->name.get_id(), &store, 0, 0, &monmap); r = mon.mkfs(osdmapbl); diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index cfa55aa3febe3..f2ac2d7996c14 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -96,7 +96,7 @@ bufferlist _encode_cap(const string& cap) void AuthMonitor::get_initial_keyring(KeyRing *keyring) { dout(10) << __func__ << dendl; - assert(keyring != nullptr); + ceph_assert(keyring != nullptr); bufferlist bl; int ret = mon->store->get("mkfs", "keyring", bl); @@ -104,7 +104,7 @@ void AuthMonitor::get_initial_keyring(KeyRing *keyring) return; } // fail hard only if there's an error we're not expecting to see - assert(ret == 0); + ceph_assert(ret == 0); auto p = bl.cbegin(); decode(*keyring, p); @@ -113,7 +113,7 @@ void AuthMonitor::get_initial_keyring(KeyRing *keyring) void _generate_bootstrap_keys( list >* auth_lst) { - assert(auth_lst != nullptr); + ceph_assert(auth_lst != nullptr); map > bootstrap = { { "admin", { @@ -153,7 +153,7 @@ void _generate_bootstrap_keys( void AuthMonitor::create_initial_keys(KeyRing *keyring) { dout(10) << __func__ << " with keyring" << dendl; - assert(keyring != nullptr); + ceph_assert(keyring != nullptr); list > auth_lst; _generate_bootstrap_keys(&auth_lst); @@ -173,7 +173,7 @@ void AuthMonitor::create_initial() // initialize rotating keys last_rotating_ver = 0; check_rotate(); - assert(pending_auth.size() == 1); + ceph_assert(pending_auth.size() == 1); if (mon->is_keyring_required()) { KeyRing keyring; @@ -202,7 +202,7 @@ void AuthMonitor::update_from_paxos(bool *need_bootstrap) version_t keys_ver = mon->key_server.get_ver(); if (version == keys_ver) return; - assert(version > keys_ver); + ceph_assert(version > keys_ver); version_t latest_full = get_version_latest_full(); @@ -212,8 +212,8 @@ void AuthMonitor::update_from_paxos(bool *need_bootstrap) if ((latest_full > 0) && (latest_full > keys_ver)) { bufferlist latest_bl; int err = get_version_full(latest_full, latest_bl); - assert(err == 0); - assert(latest_bl.length() != 0); + ceph_assert(err == 0); + ceph_assert(latest_bl.length() != 0); dout(7) << __func__ << " loading summary e " << latest_full << dendl; dout(7) << __func__ << " latest length " << latest_bl.length() << dendl; auto p = latest_bl.cbegin(); @@ -231,8 +231,8 @@ void AuthMonitor::update_from_paxos(bool *need_bootstrap) while (version > keys_ver) { bufferlist bl; int ret = get_version(keys_ver+1, bl); - assert(ret == 0); - assert(bl.length()); + ceph_assert(ret == 0); + ceph_assert(bl.length()); // reset if we are moving to initial state. we will normally have // keys in here temporarily for bootstrapping that we need to @@ -286,7 +286,7 @@ void AuthMonitor::update_from_paxos(bool *need_bootstrap) void AuthMonitor::increase_max_global_id() { - assert(mon->is_leader()); + ceph_assert(mon->is_leader()); max_global_id += g_conf()->mon_globalid_prealloc; dout(10) << "increasing max_global_id to " << max_global_id << dendl; @@ -332,7 +332,7 @@ void AuthMonitor::encode_full(MonitorDBStore::TransactionRef t) return; dout(10) << __func__ << " auth v " << version << dendl; - assert(get_last_committed() == version); + ceph_assert(get_last_committed() == version); bufferlist full_bl; Mutex::Locker l(mon->key_server.get_lock()); @@ -582,7 +582,7 @@ bool AuthMonitor::prep_auth(MonOpRequestRef op, bool paxos_writable) return true; } - assert(!paxos_writable); + ceph_assert(!paxos_writable); return false; } } @@ -787,7 +787,7 @@ int AuthMonitor::import_keyring(KeyRing& keyring) return -EINVAL; } int err = add_entity(p->first, p->second); - assert(err == 0); + ceph_assert(err == 0); } return 0; } @@ -898,7 +898,7 @@ int AuthMonitor::validate_osd_destroy( EntityName& lockbox_entity, stringstream& ss) { - assert(paxos->is_plugged()); + ceph_assert(paxos->is_plugged()); dout(10) << __func__ << " id " << id << " uuid " << uuid << dendl; @@ -931,7 +931,7 @@ int AuthMonitor::do_osd_destroy( const EntityName& cephx_entity, const EntityName& lockbox_entity) { - assert(paxos->is_plugged()); + ceph_assert(paxos->is_plugged()); dout(10) << __func__ << " cephx " << cephx_entity << " lockbox " << lockbox_entity << dendl; @@ -1048,7 +1048,7 @@ int AuthMonitor::validate_osd_new( } int err = _create_auth(cephx_entity.auth, cephx_secret, cephx_caps); - assert(0 == err); + ceph_assert(0 == err); bool cephx_is_idempotent = false, lockbox_is_idempotent = false; err = exists_and_matches_entity(cephx_entity, true, ss); @@ -1057,19 +1057,19 @@ int AuthMonitor::validate_osd_new( if (err < 0) { return err; } - assert(0 == err); + ceph_assert(0 == err); cephx_is_idempotent = true; } if (has_lockbox) { err = _create_auth(lockbox_entity.auth, lockbox_secret, lockbox_caps); - assert(err == 0); + ceph_assert(err == 0); err = exists_and_matches_entity(lockbox_entity, true, ss); if (err != -ENOENT) { if (err < 0) { return err; } - assert(0 == err); + ceph_assert(0 == err); lockbox_is_idempotent = true; } } @@ -1086,7 +1086,7 @@ int AuthMonitor::do_osd_new( const auth_entity_t& lockbox_entity, bool has_lockbox) { - assert(paxos->is_plugged()); + ceph_assert(paxos->is_plugged()); dout(10) << __func__ << " cephx " << cephx_entity.name << " lockbox "; @@ -1104,13 +1104,13 @@ int AuthMonitor::do_osd_new( if (!cephx_exists) { int err = add_entity(cephx_entity.name, cephx_entity.auth); - assert(0 == err); + ceph_assert(0 == err); } if (has_lockbox && !mon->key_server.contains(lockbox_entity.name)) { int err = add_entity(lockbox_entity.name, lockbox_entity.auth); - assert(0 == err); + ceph_assert(0 == err); } // given we have paxos plugged, this will not result in a proposal @@ -1316,7 +1316,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) goto done; } // no-op. - assert(err == 0); + ceph_assert(err == 0); goto done; } err = 0; @@ -1330,7 +1330,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) new_inc.caps = new_caps; err = add_entity(auth_inc.name, new_inc); - assert(err == 0); + ceph_assert(err == 0); ss << "added key for " << auth_inc.name; getline(ss, rs); @@ -1624,7 +1624,7 @@ bool AuthMonitor::prepare_global_id(MonOpRequestRef op) bool AuthMonitor::_upgrade_format_to_dumpling() { dout(1) << __func__ << " upgrading from format 0 to 1" << dendl; - assert(format_version == 0); + ceph_assert(format_version == 0); bool changed = false; map::iterator p; @@ -1684,7 +1684,7 @@ bool AuthMonitor::_upgrade_format_to_dumpling() bool AuthMonitor::_upgrade_format_to_luminous() { dout(1) << __func__ << " upgrading from format 1 to 2" << dendl; - assert(format_version == 1); + ceph_assert(format_version == 1); bool changed = false; map::iterator p; @@ -1745,7 +1745,7 @@ bool AuthMonitor::_upgrade_format_to_luminous() // ceph-create-keys) EntityName bootstrap_mgr_name; int r = bootstrap_mgr_name.from_str("client.bootstrap-mgr"); - assert(r); + ceph_assert(r); if (!mon->key_server.contains(bootstrap_mgr_name)) { EntityName name = bootstrap_mgr_name; @@ -1761,7 +1761,7 @@ bool AuthMonitor::_upgrade_format_to_luminous() bool AuthMonitor::_upgrade_format_to_mimic() { dout(1) << __func__ << " upgrading from format 2 to 3" << dendl; - assert(format_version == 2); + ceph_assert(format_version == 2); list > auth_lst; _generate_bootstrap_keys(&auth_lst); @@ -1772,7 +1772,7 @@ bool AuthMonitor::_upgrade_format_to_mimic() continue; } int err = add_entity(p.first, p.second); - assert(err == 0); + ceph_assert(err == 0); changed = true; } diff --git a/src/mon/AuthMonitor.h b/src/mon/AuthMonitor.h index 2378ce6c3905c..4e22da1f782c1 100644 --- a/src/mon/AuthMonitor.h +++ b/src/mon/AuthMonitor.h @@ -77,7 +77,7 @@ public: __u32 _type; decode(_type, bl); inc_type = (IncType)_type; - assert(inc_type >= GLOBAL_ID && inc_type <= AUTH_DATA); + ceph_assert(inc_type >= GLOBAL_ID && inc_type <= AUTH_DATA); if (_type == GLOBAL_ID) { decode(max_global_id, bl); } else { diff --git a/src/mon/ConfigKeyService.cc b/src/mon/ConfigKeyService.cc index 71b255d49c428..c31d956b39e7d 100644 --- a/src/mon/ConfigKeyService.cc +++ b/src/mon/ConfigKeyService.cc @@ -23,7 +23,7 @@ #include "common/errno.h" #include "include/stringify.h" -#include "include/assert.h" // re-clobber assert() +#include "include/assert.h" // re-clobber ceph_assert() #define dout_subsys ceph_subsys_mon #undef dout_prefix #define dout_prefix _prefix(_dout, mon, this) @@ -173,7 +173,7 @@ void ConfigKeyService::store_delete_prefix( bool ConfigKeyService::service_dispatch(MonOpRequestRef op) { Message *m = op->get_req(); - assert(m != NULL); + ceph_assert(m != NULL); dout(10) << __func__ << " " << *m << dendl; if (!in_quorum()) { @@ -182,11 +182,11 @@ bool ConfigKeyService::service_dispatch(MonOpRequestRef op) return false; } - assert(m->get_type() == MSG_MON_COMMAND); + ceph_assert(m->get_type() == MSG_MON_COMMAND); MMonCommand *cmd = static_cast(m); - assert(!cmd->cmd.empty()); + ceph_assert(!cmd->cmd.empty()); int ret = 0; stringstream ss; @@ -206,7 +206,7 @@ bool ConfigKeyService::service_dispatch(MonOpRequestRef op) if (prefix == "config-key get") { ret = store_get(key, rdata); if (ret < 0) { - assert(!rdata.length()); + ceph_assert(!rdata.length()); ss << "error obtaining '" << key << "': " << cpp_strerror(ret); goto out; } @@ -375,7 +375,7 @@ void ConfigKeyService::do_osd_new( const uuid_d& uuid, const string& dmcrypt_key) { - assert(paxos->is_plugged()); + ceph_assert(paxos->is_plugged()); string dmcrypt_key_prefix = _get_dmcrypt_prefix(uuid, "luks"); bufferlist dmcrypt_key_value; diff --git a/src/mon/ConfigMonitor.cc b/src/mon/ConfigMonitor.cc index b9fd6909c967b..246aa16177599 100644 --- a/src/mon/ConfigMonitor.cc +++ b/src/mon/ConfigMonitor.cc @@ -473,8 +473,8 @@ bool ConfigMonitor::prepare_command(MonOpRequestRef op) err = 0; goto reply; } - assert(num > 0); - assert((version_t)num < version); + ceph_assert(num > 0); + ceph_assert((version_t)num < version); for (int64_t v = version; v > num; --v) { ConfigChangeSet ch; load_changeset(v, &ch); diff --git a/src/mon/Elector.cc b/src/mon/Elector.cc index 6169e4344d425..c95ad3f203355 100644 --- a/src/mon/Elector.cc +++ b/src/mon/Elector.cc @@ -58,7 +58,7 @@ void Elector::shutdown() void Elector::bump_epoch(epoch_t e) { dout(10) << "bump_epoch " << epoch << " to " << e << dendl; - assert(epoch <= e); + ceph_assert(epoch <= e); epoch = e; auto t(std::make_shared()); t->put(Monitor::MONITOR_NAME, "election_epoch", epoch); @@ -91,7 +91,7 @@ void Elector::start() auto t(std::make_shared()); t->put(Monitor::MONITOR_NAME, "election_writeable_test", rand()); int r = mon->store->apply_transaction(t); - assert(r >= 0); + ceph_assert(r >= 0); } electing_me = true; acked_me[mon->rank].cluster_features = CEPH_FEATURES_ALL; @@ -206,7 +206,7 @@ void Elector::victory() cancel_timer(); - assert(epoch % 2 == 1); // election + ceph_assert(epoch % 2 == 1); // election bump_epoch(epoch+1); // is over! // tell everyone! @@ -236,7 +236,7 @@ void Elector::handle_propose(MonOpRequestRef op) dout(5) << "handle_propose from " << m->get_source() << dendl; int from = m->get_source().num(); - assert(m->epoch % 2 == 1); // election + ceph_assert(m->epoch % 2 == 1); // election uint64_t required_features = mon->get_required_features(); mon_feature_t required_mon_features = mon->get_required_mon_features(); @@ -279,7 +279,7 @@ void Elector::handle_propose(MonOpRequestRef op) if (mon->rank < from) { // i would win over them. if (leader_acked >= 0) { // we already acked someone - assert(leader_acked < from); // and they still win, of course + ceph_assert(leader_acked < from); // and they still win, of course dout(5) << "no, we already acked " << leader_acked << dendl; } else { // wait, i should win! @@ -307,14 +307,14 @@ void Elector::handle_ack(MonOpRequestRef op) dout(5) << "handle_ack from " << m->get_source() << dendl; int from = m->get_source().num(); - assert(m->epoch % 2 == 1); // election + ceph_assert(m->epoch % 2 == 1); // election if (m->epoch > epoch) { dout(5) << "woah, that's a newer epoch, i must have rebooted. bumping and re-starting!" << dendl; bump_epoch(m->epoch); start(); return; } - assert(m->epoch == epoch); + ceph_assert(m->epoch == epoch); uint64_t required_features = mon->get_required_features(); if ((required_features ^ m->get_connection()->get_features()) & required_features) { @@ -356,7 +356,7 @@ void Elector::handle_ack(MonOpRequestRef op) } } else { // ignore, i'm deferring already. - assert(leader_acked >= 0); + ceph_assert(leader_acked >= 0); } } @@ -371,8 +371,8 @@ void Elector::handle_victory(MonOpRequestRef op) << dendl; int from = m->get_source().num(); - assert(from < mon->rank); - assert(m->epoch % 2 == 0); + ceph_assert(from < mon->rank); + ceph_assert(m->epoch % 2 == 0); leader_acked = -1; @@ -394,7 +394,7 @@ void Elector::handle_victory(MonOpRequestRef op) cancel_timer(); // stash leader's commands - assert(m->sharing_bl.length()); + ceph_assert(m->sharing_bl.length()); vector new_cmds; auto bi = m->sharing_bl.cbegin(); MonCommand::decode_vector(new_cmds, bi); @@ -451,7 +451,7 @@ void Elector::handle_nak(MonOpRequestRef op) void Elector::dispatch(MonOpRequestRef op) { op->mark_event("elector:dispatch"); - assert(op->is_type_election()); + ceph_assert(op->is_type_election()); switch (op->get_req()->get_type()) { diff --git a/src/mon/FSCommands.cc b/src/mon/FSCommands.cc index ca1e227b003cb..009bbda31cfa0 100644 --- a/src/mon/FSCommands.cc +++ b/src/mon/FSCommands.cc @@ -95,7 +95,7 @@ class FsNewHandler : public FileSystemCommandHandler const cmdmap_t& cmdmap, std::stringstream &ss) override { - assert(m_paxos->is_plugged()); + ceph_assert(m_paxos->is_plugged()); string metadata_name; cmd_getval_throws(g_ceph_context, cmdmap, "metadata", metadata_name); @@ -174,9 +174,9 @@ class FsNewHandler : public FileSystemCommandHandler } pg_pool_t const *data_pool = mon->osdmon()->osdmap.get_pg_pool(data); - assert(data_pool != NULL); // Checked it existed above + ceph_assert(data_pool != NULL); // Checked it existed above pg_pool_t const *metadata_pool = mon->osdmon()->osdmap.get_pg_pool(metadata); - assert(metadata_pool != NULL); // Checked it existed above + ceph_assert(metadata_pool != NULL); // Checked it existed above int r = _check_pool(mon->osdmon()->osdmap, data, false, force, &ss); if (r < 0) { @@ -568,7 +568,7 @@ class AddDataPoolHandler : public FileSystemCommandHandler const cmdmap_t& cmdmap, std::stringstream &ss) override { - assert(m_paxos->is_plugged()); + ceph_assert(m_paxos->is_plugged()); string poolname; cmd_getval_throws(g_ceph_context, cmdmap, "pool", poolname); @@ -708,7 +708,7 @@ class RemoveFilesystemHandler : public FileSystemCommandHandler std::vector to_fail; // There may be standby_replay daemons left here for (const auto &i : fs->mds_map.get_mds_info()) { - assert(i.second.state == MDSMap::STATE_STANDBY_REPLAY); + ceph_assert(i.second.state == MDSMap::STATE_STANDBY_REPLAY); to_fail.push_back(i.first); } @@ -812,7 +812,7 @@ class RemoveDataPoolHandler : public FileSystemCommandHandler } } - assert(poolid >= 0); // Checked by parsing code above + ceph_assert(poolid >= 0); // Checked by parsing code above if (fs->mds_map.get_first_data_pool() == poolid) { ss << "cannot remove default data pool"; @@ -894,7 +894,7 @@ int FileSystemCommandHandler::parse_bool( bool *result, std::ostream &ss) { - assert(result != nullptr); + ceph_assert(result != nullptr); string interr; int64_t n = strict_strtoll(bool_str.c_str(), 10, &interr); @@ -920,7 +920,7 @@ int FileSystemCommandHandler::_check_pool( bool force, std::stringstream *ss) const { - assert(ss != NULL); + ceph_assert(ss != NULL); const pg_pool_t *pool = osd_map.get_pg_pool(pool_id); if (!pool) { @@ -947,7 +947,7 @@ int FileSystemCommandHandler::_check_pool( // write operations like modify+truncate we care about support for) const pg_pool_t *write_tier = osd_map.get_pg_pool( pool->write_tier); - assert(write_tier != NULL); // OSDMonitor shouldn't allow DNE tier + ceph_assert(write_tier != NULL); // OSDMonitor shouldn't allow DNE tier if (write_tier->cache_mode == pg_pool_t::CACHEMODE_FORWARD || write_tier->cache_mode == pg_pool_t::CACHEMODE_READONLY) { *ss << "EC pool '" << pool_name << "' has a write tier (" diff --git a/src/mon/HealthMonitor.cc b/src/mon/HealthMonitor.cc index b982ae312f557..699794441073f 100644 --- a/src/mon/HealthMonitor.cc +++ b/src/mon/HealthMonitor.cc @@ -205,7 +205,7 @@ bool HealthMonitor::check_member_health() get_fs_stats(stats.fs_stats, g_conf()->mon_data.c_str()); map extra; uint64_t store_size = mon->store->get_estimated_size(extra); - assert(store_size > 0); + ceph_assert(store_size > 0); stats.store_stats.bytes_total = store_size; stats.store_stats.bytes_sst = extra["sst"]; stats.store_stats.bytes_log = extra["log"]; diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index c4fa627988b3b..31872b11de42d 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -82,7 +82,7 @@ void LogMonitor::update_from_paxos(bool *need_bootstrap) << " summary v " << summary.version << dendl; if (version == summary.version) return; - assert(version >= summary.version); + ceph_assert(version >= summary.version); map channel_blog; @@ -91,7 +91,7 @@ void LogMonitor::update_from_paxos(bool *need_bootstrap) if ((latest_full > 0) && (latest_full > summary.version)) { bufferlist latest_bl; get_version_full(latest_full, latest_bl); - assert(latest_bl.length() != 0); + ceph_assert(latest_bl.length() != 0); dout(7) << __func__ << " loading summary e" << latest_full << dendl; auto p = latest_bl.cbegin(); decode(summary, p); @@ -102,8 +102,8 @@ void LogMonitor::update_from_paxos(bool *need_bootstrap) while (version > summary.version) { bufferlist bl; int err = get_version(summary.version+1, bl); - assert(err == 0); - assert(bl.length()); + ceph_assert(err == 0); + ceph_assert(bl.length()); auto p = bl.cbegin(); __u8 v; @@ -230,7 +230,7 @@ void LogMonitor::encode_pending(MonitorDBStore::TransactionRef t) void LogMonitor::encode_full(MonitorDBStore::TransactionRef t) { dout(10) << __func__ << " log v " << summary.version << dendl; - assert(get_last_committed() == summary.version); + ceph_assert(get_last_committed() == summary.version); bufferlist summary_bl; encode(summary, summary_bl, mon->get_quorum_con_features()); @@ -593,7 +593,7 @@ void LogMonitor::check_sub(Subscription *s) dout(10) << __func__ << " client wants " << s->type << " ver " << s->next << dendl; int sub_level = sub_name_to_id(s->type); - assert(sub_level >= 0); + ceph_assert(sub_level >= 0); version_t summary_version = summary.version; if (s->next > summary_version) { @@ -659,8 +659,8 @@ void LogMonitor::_create_sub_incremental(MLog *mlog, int level, version_t sv) while (sv && sv <= summary_ver) { bufferlist bl; int err = get_version(sv, bl); - assert(err == 0); - assert(bl.length()); + ceph_assert(err == 0); + ceph_assert(bl.length()); auto p = bl.cbegin(); __u8 v; decode(v,p); diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index cd502e2dfb126..1f467523d3cf0 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -105,7 +105,7 @@ void MDSMonitor::update_from_paxos(bool *need_bootstrap) dout(10) << __func__ << " version " << version << ", my e " << get_fsmap().epoch << dendl; - assert(version > get_fsmap().epoch); + ceph_assert(version > get_fsmap().epoch); load_health(); @@ -113,9 +113,9 @@ void MDSMonitor::update_from_paxos(bool *need_bootstrap) bufferlist fsmap_bl; fsmap_bl.clear(); int err = get_version(version, fsmap_bl); - assert(err == 0); + ceph_assert(err == 0); - assert(fsmap_bl.length() > 0); + ceph_assert(fsmap_bl.length() > 0); dout(10) << __func__ << " got " << version << dendl; PaxosFSMap::decode(fsmap_bl); @@ -167,7 +167,7 @@ void MDSMonitor::encode_pending(MonitorDBStore::TransactionRef t) } // apply to paxos - assert(get_last_committed() + 1 == pending.epoch); + ceph_assert(get_last_committed() + 1 == pending.epoch); bufferlist pending_bl; pending.encode(pending_bl, mon->get_quorum_con_features()); @@ -449,7 +449,7 @@ bool MDSMonitor::preprocess_beacon(MonOpRequestRef op) reply: // note time and reply - assert(effective_epoch > 0); + ceph_assert(effective_epoch > 0); _note_beacon(m); { auto beacon = MMDSBeacon::create(mon->monmap->fsid, @@ -592,7 +592,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op) failed_mds = true; } if (failed_mds) { - assert(mon->osdmon()->is_writeable()); + ceph_assert(mon->osdmon()->is_writeable()); request_proposal(mon->osdmon()); } } @@ -735,7 +735,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op) } fail_mds_gid(pending, gid); - assert(mon->osdmon()->is_writeable()); + ceph_assert(mon->osdmon()->is_writeable()); request_proposal(mon->osdmon()); // Respond to MDS, so that it knows it can continue to shut down @@ -911,8 +911,8 @@ bool MDSMonitor::preprocess_command(MonOpRequestRef op) r = -ENOENT; goto out; } else { - assert(err == 0); - assert(b.length()); + ceph_assert(err == 0); + ceph_assert(b.length()); dummy.decode(b); fsmapp = &dummy; } @@ -1112,7 +1112,7 @@ mds_gid_t MDSMonitor::gid_from_arg(const FSMap &fsmap, const std::string &arg, s if (r == 0) { // See if a GID is assigned to this role const auto &fs = fsmap.get_filesystem(role.fscid); - assert(fs != nullptr); // parse_role ensures it exists + ceph_assert(fs != nullptr); // parse_role ensures it exists if (fs->mds_map.is_up(role.rank)) { dout(10) << __func__ << ": validated rank/GID " << role << " as a rank" << dendl; @@ -1152,7 +1152,7 @@ mds_gid_t MDSMonitor::gid_from_arg(const FSMap &fsmap, const std::string &arg, s int MDSMonitor::fail_mds(FSMap &fsmap, std::ostream &ss, const std::string &arg, MDSMap::mds_info_t *failed_info) { - assert(failed_info != nullptr); + ceph_assert(failed_info != nullptr); mds_gid_t gid = gid_from_arg(fsmap, arg, ss); if (gid == MDS_GID_NONE) { @@ -1168,7 +1168,7 @@ int MDSMonitor::fail_mds(FSMap &fsmap, std::ostream &ss, fail_mds_gid(fsmap, gid); ss << "failed mds gid " << gid; - assert(mon->osdmon()->is_writeable()); + ceph_assert(mon->osdmon()->is_writeable()); request_proposal(mon->osdmon()); return 0; } @@ -1546,7 +1546,7 @@ void MDSMonitor::check_sub(Subscription *sub) null_map.compat = fsmap.compat; if (fscid == FS_CLUSTER_ID_NONE) { // For a client, we should have already dropped out - assert(is_mds); + ceph_assert(is_mds); auto it = fsmap.standby_daemons.find(mds_gid); if (it != fsmap.standby_daemons.end()) { @@ -1562,7 +1562,7 @@ void MDSMonitor::check_sub(Subscription *sub) mds_map = &fsmap.get_filesystem(fscid)->mds_map; } - assert(mds_map != nullptr); + ceph_assert(mds_map != nullptr); dout(10) << __func__ << " selected MDS map epoch " << mds_map->epoch << " for namespace " << fscid << " for subscriber " << sub->session->name << " who wants epoch " << sub->next << dendl; @@ -1657,7 +1657,7 @@ void MDSMonitor::count_metadata(const std::string &field, Formatter *f) int MDSMonitor::dump_metadata(const FSMap& fsmap, const std::string &who, Formatter *f, ostream& err) { - assert(f); + ceph_assert(f); mds_gid_t gid = gid_from_arg(fsmap, who, err); if (gid == MDS_GID_NONE) { @@ -1682,7 +1682,7 @@ int MDSMonitor::dump_metadata(const FSMap& fsmap, const std::string &who, int MDSMonitor::print_nodes(Formatter *f) { - assert(f); + ceph_assert(f); const auto &fsmap = get_fsmap(); @@ -1789,8 +1789,8 @@ bool MDSMonitor::maybe_resize_cluster(FSMap &fsmap, fs_cluster_id_t fscid) void MDSMonitor::maybe_replace_gid(FSMap &fsmap, mds_gid_t gid, const MDSMap::mds_info_t& info, bool *mds_propose, bool *osd_propose) { - assert(mds_propose != nullptr); - assert(osd_propose != nullptr); + ceph_assert(mds_propose != nullptr); + ceph_assert(osd_propose != nullptr); const auto fscid = fsmap.mds_roles.at(gid); @@ -1906,7 +1906,7 @@ bool MDSMonitor::maybe_promote_standby(FSMap &fsmap, std::shared_ptr for (const auto &gid : standby_gids) { const auto &info = fsmap.standby_daemons.at(gid); - assert(info.state == MDSMap::STATE_STANDBY); + ceph_assert(info.state == MDSMap::STATE_STANDBY); if (!info.standby_replay) { continue; diff --git a/src/mon/MgrMap.h b/src/mon/MgrMap.h index dd1c226c3f77a..592f7e58c7f25 100644 --- a/src/mon/MgrMap.h +++ b/src/mon/MgrMap.h @@ -352,7 +352,7 @@ public: void print_summary(Formatter *f, std::ostream *ss) const { // One or the other, not both - assert((ss != nullptr) != (f != nullptr)); + ceph_assert((ss != nullptr) != (f != nullptr)); if (f) { dump(f); } else { diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index c7aa400192297..bccc7386e543b 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -78,7 +78,7 @@ void MgrMonitor::update_from_paxos(bool *need_bootstrap) bufferlist bl; int err = get_version(version, bl); - assert(err == 0); + ceph_assert(err == 0); bool old_available = map.get_available(); uint64_t old_gid = map.get_active_gid(); @@ -158,7 +158,7 @@ void MgrMonitor::post_paxos_update() prev_health_checks.resize(mon->paxos_service.size()); send = true; } - assert(prev_health_checks.size() == mon->paxos_service.size()); + ceph_assert(prev_health_checks.size() == mon->paxos_service.size()); for (auto i = 0u; i < prev_health_checks.size(); i++) { const auto& curr = mon->paxos_service[i]->get_health_checks(); if (!send && curr != prev_health_checks[i]) { @@ -478,7 +478,7 @@ void MgrMonitor::check_sub(Subscription *sub) } } } else { - assert(sub->type == "mgrdigest"); + ceph_assert(sub->type == "mgrdigest"); if (sub->next == 0) { // new registration; cancel previous timer cancel_timer(); @@ -660,7 +660,7 @@ void MgrMonitor::on_restart() bool MgrMonitor::promote_standby() { - assert(pending_map.active_gid == 0); + ceph_assert(pending_map.active_gid == 0); if (pending_map.standbys.size()) { // Promote a replacement (arbitrary choice of standby) auto replacement_gid = pending_map.standbys.begin()->first; @@ -1059,7 +1059,7 @@ int MgrMonitor::dump_metadata(const string& name, Formatter *f, ostream *err) void MgrMonitor::print_nodes(Formatter *f) const { - assert(f); + ceph_assert(f); std::map > mgrs; // hostname => mgr auto ls = map.get_all_names(); diff --git a/src/mon/MgrStatMonitor.cc b/src/mon/MgrStatMonitor.cc index cac4adbf05606..545f64bd2c57d 100644 --- a/src/mon/MgrStatMonitor.cc +++ b/src/mon/MgrStatMonitor.cc @@ -45,7 +45,7 @@ void MgrStatMonitor::update_from_paxos(bool *need_bootstrap) bufferlist bl; get_version(version, bl); if (version) { - assert(bl.length()); + ceph_assert(bl.length()); try { auto p = bl.cbegin(); decode(digest, p); @@ -117,7 +117,7 @@ void MgrStatMonitor::encode_pending(MonitorDBStore::TransactionRef t) dout(10) << " " << version << dendl; bufferlist bl; encode(pending_digest, bl, mon->get_quorum_con_features()); - assert(pending_service_map_bl.length()); + ceph_assert(pending_service_map_bl.length()); bl.append(pending_service_map_bl); put_version(t, version, bl); put_last_committed(t, version); diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index 6cf4a4ea5d3be..1b7fba27ab61d 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -95,7 +95,7 @@ int MonClient::get_monmap() int MonClient::get_monmap_and_config() { ldout(cct, 10) << __func__ << dendl; - assert(!messenger); + ceph_assert(!messenger); int tries = 10; @@ -112,7 +112,7 @@ int MonClient::get_monmap_and_config() messenger = Messenger::create_client_messenger( cct, "temp_mon_client"); - assert(messenger); + ceph_assert(messenger); messenger->add_dispatcher_head(this); messenger->start(); @@ -510,7 +510,7 @@ int MonClient::authenticate(double timeout) ldout(cct, 5) << __func__ << " success, global_id " << active_con->get_global_id() << dendl; // active_con should not have been set if there was an error - assert(authenticate_err == 0); + ceph_assert(authenticate_err == 0); authenticated = true; } @@ -523,7 +523,7 @@ int MonClient::authenticate(double timeout) void MonClient::handle_auth(MAuthReply *m) { - assert(monc_lock.is_locked()); + ceph_assert(monc_lock.is_locked()); if (!_hunting()) { std::swap(active_con->get_auth(), auth); int ret = active_con->authenticate(m); @@ -541,7 +541,7 @@ void MonClient::handle_auth(MAuthReply *m) // hunting auto found = _find_pending_con(m->get_connection()); - assert(found != pending_cons.end()); + ceph_assert(found != pending_cons.end()); int auth_err = found->second.handle_auth(m, entity_name, want_keys, rotating_secrets.get()); m->put(); @@ -557,7 +557,7 @@ void MonClient::handle_auth(MAuthReply *m) // the last try just failed, give up. } else { auto& mc = found->second; - assert(mc.have_session()); + ceph_assert(mc.have_session()); active_con.reset(new MonConnection(std::move(mc))); pending_cons.clear(); } @@ -597,7 +597,7 @@ void MonClient::_finish_auth(int auth_err) // _resend_mon_commands() could _reopen_session() if the connected mon is not // the one the MonCommand is targeting. if (!auth_err && active_con) { - assert(auth); + ceph_assert(auth); _check_auth_tickets(); } auth_cond.SignalAll(); @@ -607,7 +607,7 @@ void MonClient::_finish_auth(int auth_err) void MonClient::_send_mon_message(Message *m) { - assert(monc_lock.is_locked()); + ceph_assert(monc_lock.is_locked()); if (active_con) { auto cur_con = active_con->get_con(); ldout(cct, 10) << "_send_mon_message to mon." @@ -621,7 +621,7 @@ void MonClient::_send_mon_message(Message *m) void MonClient::_reopen_session(int rank) { - assert(monc_lock.is_locked()); + ceph_assert(monc_lock.is_locked()); ldout(cct, 10) << __func__ << " rank " << rank << dendl; active_con.reset(); @@ -724,7 +724,7 @@ bool MonClient::ms_handle_reset(Connection *con) bool MonClient::_opened() const { - assert(monc_lock.is_locked()); + ceph_assert(monc_lock.is_locked()); return active_con || _hunting(); } @@ -735,7 +735,7 @@ bool MonClient::_hunting() const void MonClient::_start_hunting() { - assert(!_hunting()); + ceph_assert(!_hunting()); // adjust timeouts if necessary if (!had_a_connection) return; @@ -749,9 +749,9 @@ void MonClient::_start_hunting() void MonClient::_finish_hunting() { - assert(monc_lock.is_locked()); + ceph_assert(monc_lock.is_locked()); // the pending conns have been cleaned. - assert(!_hunting()); + ceph_assert(!_hunting()); if (active_con) { auto con = active_con->get_con(); ldout(cct, 1) << "found mon." @@ -836,7 +836,7 @@ void MonClient::schedule_tick() void MonClient::_renew_subs() { - assert(monc_lock.is_locked()); + ceph_assert(monc_lock.is_locked()); if (!sub.have_new()) { ldout(cct, 10) << __func__ << " - empty" << dendl; return; @@ -861,7 +861,7 @@ void MonClient::handle_subscribe_ack(MMonSubscribeAck *m) int MonClient::_check_auth_tickets() { - assert(monc_lock.is_locked()); + ceph_assert(monc_lock.is_locked()); if (active_con && auth) { if (auth->need_tickets()) { ldout(cct, 10) << __func__ << " getting new tickets!" << dendl; @@ -879,7 +879,7 @@ int MonClient::_check_auth_tickets() int MonClient::_check_auth_rotating() { - assert(monc_lock.is_locked()); + ceph_assert(monc_lock.is_locked()); if (!rotating_secrets || !auth_principal_needs_rotating_keys(entity_name)) { ldout(cct, 20) << "_check_auth_rotating not needed by " << entity_name << dendl; @@ -934,7 +934,7 @@ int MonClient::wait_auth_rotating(double timeout) until += timeout; // Must be initialized - assert(auth != nullptr); + ceph_assert(auth != nullptr); if (auth->get_protocol() == CEPH_AUTH_NONE) return 0; @@ -1041,7 +1041,7 @@ void MonClient::handle_mon_command_ack(MMonCommandAck *ack) int MonClient::_cancel_mon_command(uint64_t tid) { - assert(monc_lock.is_locked()); + ceph_assert(monc_lock.is_locked()); map::iterator it = mon_commands.find(tid); if (it == mon_commands.end()) { @@ -1151,7 +1151,7 @@ void MonClient::get_version(string map, version_t *newest, version_t *oldest, Co void MonClient::handle_get_version_reply(MMonGetVersionReply* m) { - assert(monc_lock.is_locked()); + ceph_assert(monc_lock.is_locked()); map::iterator iter = version_requests.find(m->handle); if (iter == version_requests.end()) { ldout(cct, 0) << __func__ << " version request with handle " << m->handle @@ -1285,7 +1285,7 @@ int MonConnection::_negotiate(MAuthReply *m, int MonConnection::authenticate(MAuthReply *m) { - assert(auth); + ceph_assert(auth); if (!m->global_id) { ldout(cct, 1) << "peer sent an invalid global_id" << dendl; } @@ -1309,7 +1309,7 @@ int MonConnection::authenticate(MAuthReply *m) } void MonClient::register_config_callback(md_config_t::config_callback fn) { - assert(!config_cb); + ceph_assert(!config_cb); config_cb = fn; } diff --git a/src/mon/MonMap.cc b/src/mon/MonMap.cc index 10ab35299de34..69f4b8eceeabc 100644 --- a/src/mon/MonMap.cc +++ b/src/mon/MonMap.cc @@ -387,7 +387,7 @@ void MonMap::set_initial_members(CephContext *cct, if (removed) removed->insert(get_addr(i)); remove(n); - assert(!contains(n)); + ceph_assert(!contains(n)); } // add missing initial members @@ -408,7 +408,7 @@ void MonMap::set_initial_members(CephContext *cct, lgeneric_dout(cct, 1) << " adding " << *p << " " << a << dendl; add(*p, a); } - assert(contains(*p)); + ceph_assert(contains(*p)); } } calc_legacy_ranks(); diff --git a/src/mon/MonMap.h b/src/mon/MonMap.h index 5e91a7d860a39..5b6e2702c5023 100644 --- a/src/mon/MonMap.h +++ b/src/mon/MonMap.h @@ -154,13 +154,13 @@ public: * @param m monitor info of the new monitor */ void add(const mon_info_t& m) { - assert(mon_info.count(m.name) == 0); - assert(addr_mons.count(m.public_addr) == 0); + ceph_assert(mon_info.count(m.name) == 0); + ceph_assert(addr_mons.count(m.public_addr) == 0); mon_info[m.name] = m; if (get_required_features().contains_all( ceph::features::mon::FEATURE_NAUTILUS)) { ranks.push_back(m.name); - assert(ranks.size() == mon_info.size()); + ceph_assert(ranks.size() == mon_info.size()); } else { calc_legacy_ranks(); } @@ -183,13 +183,13 @@ public: * @param name Monitor name (i.e., 'foo' in 'mon.foo') */ void remove(const string &name) { - assert(mon_info.count(name)); + ceph_assert(mon_info.count(name)); mon_info.erase(name); - assert(mon_info.count(name) == 0); + ceph_assert(mon_info.count(name) == 0); if (get_required_features().contains_all( ceph::features::mon::FEATURE_NAUTILUS)) { ranks.erase(std::find(ranks.begin(), ranks.end(), name)); - assert(ranks.size() == mon_info.size()); + ceph_assert(ranks.size() == mon_info.size()); } else { calc_legacy_ranks(); } @@ -203,15 +203,15 @@ public: * @param newname monitor's new name (i.e., 'bar' in 'mon.bar') */ void rename(string oldname, string newname) { - assert(contains(oldname)); - assert(!contains(newname)); + ceph_assert(contains(oldname)); + ceph_assert(!contains(newname)); mon_info[newname] = mon_info[oldname]; mon_info.erase(oldname); mon_info[newname].name = newname; if (get_required_features().contains_all( ceph::features::mon::FEATURE_NAUTILUS)) { *std::find(ranks.begin(), ranks.end(), oldname) = newname; - assert(ranks.size() == mon_info.size()); + ceph_assert(ranks.size() == mon_info.size()); } else { calc_legacy_ranks(); } @@ -257,7 +257,7 @@ public: } string get_name(unsigned n) const { - assert(n < ranks.size()); + ceph_assert(n < ranks.size()); return ranks[n]; } string get_name(const entity_addr_t& a) const { @@ -298,16 +298,16 @@ public: } const entity_addr_t& get_addr(const string& n) const { - assert(mon_info.count(n)); + ceph_assert(mon_info.count(n)); map::const_iterator p = mon_info.find(n); return p->second.public_addr; } const entity_addr_t& get_addr(unsigned m) const { - assert(m < ranks.size()); + ceph_assert(m < ranks.size()); return get_addr(ranks[m]); } void set_addr(const string& n, const entity_addr_t& a) { - assert(mon_info.count(n)); + ceph_assert(mon_info.count(n)); mon_info[n].public_addr = a; } diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 8da36176c0a62..5cf0de4675cb6 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -205,7 +205,7 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s, config_key_service = new ConfigKeyService(this, paxos); bool r = mon_caps.parse("allow *", NULL); - assert(r); + ceph_assert(r); exited_quorum = ceph_clock_now(); @@ -230,7 +230,7 @@ Monitor::~Monitor() paxos_service.clear(); delete config_key_service; delete paxos; - assert(session_map.sessions.empty()); + ceph_assert(session_map.sessions.empty()); } @@ -340,7 +340,7 @@ void Monitor::do_admin_command(std::string_view command, const cmdmap_t& cmdmap, please enable \"mon_enable_op_tracker\", and the tracker will start to track new ops received afterwards."; } } else { - assert(0 == "bad AdminSocket command binding"); + ceph_assert(0 == "bad AdminSocket command binding"); } (read_only ? audit_clog->debug() : audit_clog->info()) << "from='admin socket' " @@ -359,7 +359,7 @@ abort: void Monitor::handle_signal(int signum) { - assert(signum == SIGINT || signum == SIGTERM); + ceph_assert(signum == SIGINT || signum == SIGTERM); derr << "*** Got Signal " << sig_str(signum) << " ***" << dendl; shutdown(); } @@ -592,7 +592,7 @@ int Monitor::preinit() return r; } - assert(!logger); + ceph_assert(!logger); { PerfCountersBuilder pcb(g_ceph_context, "mon", l_mon_first, l_mon_last); pcb.add_u64(l_mon_num_sessions, "num_sessions", "Open sessions", "sess", @@ -615,7 +615,7 @@ int Monitor::preinit() cct->get_perfcounters_collection()->add(logger); } - assert(!cluster_logger); + ceph_assert(!cluster_logger); { PerfCountersBuilder pcb(g_ceph_context, "cluster", l_cluster_first, l_cluster_last); pcb.add_u64(l_cluster_num_mon, "num_mon", "Monitors"); @@ -757,54 +757,54 @@ int Monitor::preinit() lock.Unlock(); r = admin_socket->register_command("mon_status", "mon_status", admin_hook, "show current monitor status"); - assert(r == 0); + ceph_assert(r == 0); r = admin_socket->register_command("quorum_status", "quorum_status", admin_hook, "show current quorum status"); - assert(r == 0); + ceph_assert(r == 0); r = admin_socket->register_command("sync_force", "sync_force name=validate," "type=CephChoices," "strings=--yes-i-really-mean-it", admin_hook, "force sync of and clear monitor store"); - assert(r == 0); + ceph_assert(r == 0); r = admin_socket->register_command("add_bootstrap_peer_hint", "add_bootstrap_peer_hint name=addr," "type=CephIPAddr", admin_hook, "add peer address as potential bootstrap" " peer for cluster bringup"); - assert(r == 0); + ceph_assert(r == 0); r = admin_socket->register_command("quorum enter", "quorum enter", admin_hook, "force monitor back into quorum"); - assert(r == 0); + ceph_assert(r == 0); r = admin_socket->register_command("quorum exit", "quorum exit", admin_hook, "force monitor out of the quorum"); - assert(r == 0); + ceph_assert(r == 0); r = admin_socket->register_command("ops", "ops", admin_hook, "show the ops currently in flight"); - assert(r == 0); + ceph_assert(r == 0); r = admin_socket->register_command("sessions", "sessions", admin_hook, "list existing sessions"); - assert(r == 0); + ceph_assert(r == 0); r = admin_socket->register_command("dump_historic_ops", "dump_historic_ops", admin_hook, "show recent ops"); - assert(r == 0); + ceph_assert(r == 0); r = admin_socket->register_command("dump_historic_ops_by_duration", "dump_historic_ops_by_duration", admin_hook, "show recent ops, sorted by duration"); - assert(r == 0); + ceph_assert(r == 0); r = admin_socket->register_command("dump_historic_slow_ops", "dump_historic_slow_ops", admin_hook, "show recent slow ops"); - assert(r == 0); + ceph_assert(r == 0); lock.Lock(); @@ -1135,7 +1135,7 @@ set Monitor::get_sync_targets_names() svc->get_store_prefixes(targets); } ConfigKeyService *config_key_service_ptr = dynamic_cast(config_key_service); - assert(config_key_service_ptr); + ceph_assert(config_key_service_ptr); config_key_service_ptr->get_store_prefixes(targets); return targets; } @@ -1144,7 +1144,7 @@ set Monitor::get_sync_targets_names() void Monitor::sync_timeout() { dout(10) << __func__ << dendl; - assert(state == STATE_SYNCHRONIZING); + ceph_assert(state == STATE_SYNCHRONIZING); bootstrap(); } @@ -1162,7 +1162,7 @@ void Monitor::sync_obtain_latest_monmap(bufferlist &bl) derr << __func__ << " something wrong happened while reading the store: " << cpp_strerror(err) << dendl; - assert(0 == "error reading the store"); + ceph_assert(0 == "error reading the store"); } } else { latest_monmap.decode(monmon_bl); @@ -1176,9 +1176,9 @@ void Monitor::sync_obtain_latest_monmap(bufferlist &bl) derr << __func__ << " something wrong happened while reading the store: " << cpp_strerror(err) << dendl; - assert(0 == "error reading the store"); + ceph_assert(0 == "error reading the store"); } - assert(backup_bl.length() > 0); + ceph_assert(backup_bl.length() > 0); MonMap backup_monmap; backup_monmap.decode(backup_bl); @@ -1222,7 +1222,7 @@ void Monitor::sync_start(entity_inst_t &other, bool full) { dout(10) << __func__ << " " << other << (full ? " full" : " recent") << dendl; - assert(state == STATE_PROBING || + ceph_assert(state == STATE_PROBING || state == STATE_SYNCHRONIZING); state = STATE_SYNCHRONIZING; @@ -1244,7 +1244,7 @@ void Monitor::sync_start(entity_inst_t &other, bool full) store->apply_transaction(t); - assert(g_conf()->mon_sync_requester_kill_at != 1); + ceph_assert(g_conf()->mon_sync_requester_kill_at != 1); // clear the underlying store set targets = get_sync_targets_names(); @@ -1256,7 +1256,7 @@ void Monitor::sync_start(entity_inst_t &other, bool full) // deciding a partial or no sync is needed. paxos->init(); - assert(g_conf()->mon_sync_requester_kill_at != 2); + ceph_assert(g_conf()->mon_sync_requester_kill_at != 2); } // assume 'other' as the leader. We will update the leader once we receive @@ -1276,7 +1276,7 @@ void Monitor::sync_stash_critical_state(MonitorDBStore::TransactionRef t) dout(10) << __func__ << dendl; bufferlist backup_monmap; sync_obtain_latest_monmap(backup_monmap); - assert(backup_monmap.length() > 0); + ceph_assert(backup_monmap.length() > 0); t->put("mon_sync", "latest_monmap", backup_monmap); } @@ -1296,7 +1296,7 @@ void Monitor::sync_finish(version_t last_committed) { dout(10) << __func__ << " lc " << last_committed << " from " << sync_provider << dendl; - assert(g_conf()->mon_sync_requester_kill_at != 7); + ceph_assert(g_conf()->mon_sync_requester_kill_at != 7); if (sync_full) { // finalize the paxos commits @@ -1314,7 +1314,7 @@ void Monitor::sync_finish(version_t last_committed) store->apply_transaction(tx); } - assert(g_conf()->mon_sync_requester_kill_at != 8); + ceph_assert(g_conf()->mon_sync_requester_kill_at != 8); auto t(std::make_shared()); t->erase("mon_sync", "in_sync"); @@ -1322,11 +1322,11 @@ void Monitor::sync_finish(version_t last_committed) t->erase("mon_sync", "last_committed_floor"); store->apply_transaction(t); - assert(g_conf()->mon_sync_requester_kill_at != 9); + ceph_assert(g_conf()->mon_sync_requester_kill_at != 9); init_paxos(); - assert(g_conf()->mon_sync_requester_kill_at != 10); + ceph_assert(g_conf()->mon_sync_requester_kill_at != 10); bootstrap(); } @@ -1363,7 +1363,7 @@ void Monitor::handle_sync(MonOpRequestRef op) default: dout(0) << __func__ << " unknown op " << m->op << dendl; - assert(0 == "unknown op"); + ceph_assert(0 == "unknown op"); } } @@ -1384,7 +1384,7 @@ void Monitor::handle_sync_get_cookie(MonOpRequestRef op) return; } - assert(g_conf()->mon_sync_provider_kill_at != 1); + ceph_assert(g_conf()->mon_sync_provider_kill_at != 1); // make sure they can understand us. if ((required_features ^ m->get_connection()->get_features()) & @@ -1401,7 +1401,7 @@ void Monitor::handle_sync_get_cookie(MonOpRequestRef op) // process instance. there is no need to be unique *across* // monitors, though. uint64_t cookie = ((unsigned long long)elector.get_epoch() << 24) + ++sync_provider_count; - assert(sync_providers.count(cookie) == 0); + ceph_assert(sync_providers.count(cookie) == 0); dout(10) << __func__ << " cookie " << cookie << " for " << m->get_source_inst() << dendl; @@ -1440,7 +1440,7 @@ void Monitor::handle_sync_get_chunk(MonOpRequestRef op) return; } - assert(g_conf()->mon_sync_provider_kill_at != 2); + ceph_assert(g_conf()->mon_sync_provider_kill_at != 2); SyncProvider& sp = sync_providers[m->cookie]; sp.reset_timeout(g_ceph_context, g_conf()->mon_sync_timeout * 2); @@ -1463,7 +1463,7 @@ void Monitor::handle_sync_get_chunk(MonOpRequestRef op) sp.last_committed++; int err = store->get(paxos->get_name(), sp.last_committed, bl); - assert(err == 0); + ceph_assert(err == 0); tx->put(paxos->get_name(), sp.last_committed, bl); left -= bl.length(); @@ -1487,7 +1487,7 @@ void Monitor::handle_sync_get_chunk(MonOpRequestRef op) << " key " << sp.last_key << dendl; reply->op = MMonSync::OP_LAST_CHUNK; - assert(g_conf()->mon_sync_provider_kill_at != 3); + ceph_assert(g_conf()->mon_sync_provider_kill_at != 3); // clean up our local state sync_providers.erase(sp.cookie); @@ -1518,7 +1518,7 @@ void Monitor::handle_sync_cookie(MonOpRequestRef op) sync_reset_timeout(); sync_get_next_chunk(); - assert(g_conf()->mon_sync_requester_kill_at != 3); + ceph_assert(g_conf()->mon_sync_requester_kill_at != 3); } void Monitor::sync_get_next_chunk() @@ -1531,7 +1531,7 @@ void Monitor::sync_get_next_chunk() MMonSync *r = new MMonSync(MMonSync::OP_GET_CHUNK, sync_cookie); messenger->send_message(r, sync_provider); - assert(g_conf()->mon_sync_requester_kill_at != 4); + ceph_assert(g_conf()->mon_sync_requester_kill_at != 4); } void Monitor::handle_sync_chunk(MonOpRequestRef op) @@ -1548,8 +1548,8 @@ void Monitor::handle_sync_chunk(MonOpRequestRef op) return; } - assert(state == STATE_SYNCHRONIZING); - assert(g_conf()->mon_sync_requester_kill_at != 5); + ceph_assert(state == STATE_SYNCHRONIZING); + ceph_assert(g_conf()->mon_sync_requester_kill_at != 5); auto tx(std::make_shared()); tx->append_from_encoded(m->chunk_bl); @@ -1562,7 +1562,7 @@ void Monitor::handle_sync_chunk(MonOpRequestRef op) store->apply_transaction(tx); - assert(g_conf()->mon_sync_requester_kill_at != 6); + ceph_assert(g_conf()->mon_sync_requester_kill_at != 6); if (!sync_full) { dout(10) << __func__ << " applying recent paxos transactions as we go" << dendl; @@ -1643,8 +1643,8 @@ void Monitor::reset_probe_timeout() void Monitor::probe_timeout(int r) { dout(4) << "probe_timeout " << probe_timeout_event << dendl; - assert(is_probing() || is_synchronizing()); - assert(probe_timeout_event); + ceph_assert(is_probing() || is_synchronizing()); + ceph_assert(probe_timeout_event); probe_timeout_event = NULL; bootstrap(); } @@ -1794,7 +1794,7 @@ void Monitor::handle_probe_reply(MonOpRequestRef op) return; } - assert(paxos != NULL); + ceph_assert(paxos != NULL); if (is_synchronizing()) { dout(10) << " currently syncing" << dendl; @@ -1925,7 +1925,7 @@ void Monitor::win_standalone_election() elector.advance_epoch(); rank = monmap->get_rank(name); - assert(rank == 0); + ceph_assert(rank == 0); set q; q.insert(rank); @@ -1940,7 +1940,7 @@ void Monitor::win_standalone_election() const utime_t& Monitor::get_leader_since() const { - assert(state == STATE_LEADER); + ceph_assert(state == STATE_LEADER); return leader_since; } @@ -1951,7 +1951,7 @@ epoch_t Monitor::get_epoch() void Monitor::_finish_svc_election() { - assert(state == STATE_LEADER || state == STATE_PEON); + ceph_assert(state == STATE_LEADER || state == STATE_PEON); for (auto& svc : paxos_service) { // we already called election_finished() on monmon(); avoid callig twice @@ -1969,7 +1969,7 @@ void Monitor::win_election(epoch_t epoch, set& active, uint64_t features, << " features " << features << " mon_features " << mon_features << dendl; - assert(is_electing()); + ceph_assert(is_electing()); state = STATE_LEADER; leader_since = ceph_clock_now(); leader = rank; @@ -2031,7 +2031,7 @@ void Monitor::win_election(epoch_t epoch, set& active, uint64_t features, dout(20) << __func__ << " healthmon proposing, waiting" << dendl; healthmon()->wait_for_finished_proposal(nullptr, new C_MonContext(this, [this](int r){ - assert(lock.is_locked_by_me()); + ceph_assert(lock.is_locked_by_me()); do_health_to_clog_interval(); })); @@ -2159,31 +2159,31 @@ void Monitor::apply_monmap_to_compatset_features() * once you unset it. */ if (monmap_features.contains_all(ceph::features::mon::FEATURE_KRAKEN)) { - assert(ceph::features::mon::get_persistent().contains_all( + ceph_assert(ceph::features::mon::get_persistent().contains_all( ceph::features::mon::FEATURE_KRAKEN)); // this feature should only ever be set if the quorum supports it. - assert(HAVE_FEATURE(quorum_con_features, SERVER_KRAKEN)); + ceph_assert(HAVE_FEATURE(quorum_con_features, SERVER_KRAKEN)); new_features.incompat.insert(CEPH_MON_FEATURE_INCOMPAT_KRAKEN); } if (monmap_features.contains_all(ceph::features::mon::FEATURE_LUMINOUS)) { - assert(ceph::features::mon::get_persistent().contains_all( + ceph_assert(ceph::features::mon::get_persistent().contains_all( ceph::features::mon::FEATURE_LUMINOUS)); // this feature should only ever be set if the quorum supports it. - assert(HAVE_FEATURE(quorum_con_features, SERVER_LUMINOUS)); + ceph_assert(HAVE_FEATURE(quorum_con_features, SERVER_LUMINOUS)); new_features.incompat.insert(CEPH_MON_FEATURE_INCOMPAT_LUMINOUS); } if (monmap_features.contains_all(ceph::features::mon::FEATURE_MIMIC)) { - assert(ceph::features::mon::get_persistent().contains_all( + ceph_assert(ceph::features::mon::get_persistent().contains_all( ceph::features::mon::FEATURE_MIMIC)); // this feature should only ever be set if the quorum supports it. - assert(HAVE_FEATURE(quorum_con_features, SERVER_MIMIC)); + ceph_assert(HAVE_FEATURE(quorum_con_features, SERVER_MIMIC)); new_features.incompat.insert(CEPH_MON_FEATURE_INCOMPAT_MIMIC); } if (monmap_features.contains_all(ceph::features::mon::FEATURE_NAUTILUS)) { - assert(ceph::features::mon::get_persistent().contains_all( + ceph_assert(ceph::features::mon::get_persistent().contains_all( ceph::features::mon::FEATURE_NAUTILUS)); // this feature should only ever be set if the quorum supports it. - assert(HAVE_FEATURE(quorum_con_features, SERVER_NAUTILUS)); + ceph_assert(HAVE_FEATURE(quorum_con_features, SERVER_NAUTILUS)); new_features.incompat.insert(CEPH_MON_FEATURE_INCOMPAT_NAUTILUS); } @@ -2918,7 +2918,7 @@ struct C_MgrProxyCommand : public Context { void Monitor::handle_command(MonOpRequestRef op) { - assert(op->is_type_command()); + ceph_assert(op->is_type_command()); MMonCommand *m = static_cast(op->get_req()); if (m->fsid != monmap->fsid) { dout(0) << "handle_command on fsid " << m->fsid << " != " << monmap->fsid << dendl; @@ -3313,7 +3313,7 @@ void Monitor::handle_command(MonOpRequestRef op) ds << '\n'; } } else { - assert(0 == "We should never get here!"); + ceph_assert(0 == "We should never get here!"); return; } rdata.append(ds); @@ -3625,7 +3625,7 @@ void Monitor::reply_command(MonOpRequestRef op, int rc, const string &rs, bufferlist& rdata, version_t version) { MMonCommand *m = static_cast(op->get_req()); - assert(m->get_type() == MSG_MON_COMMAND); + ceph_assert(m->get_type() == MSG_MON_COMMAND); MMonCommandAck *reply = new MMonCommandAck(m->cmd, rc, rs, version); reply->set_tid(m->get_tid()); reply->set_data(rdata); @@ -3679,7 +3679,7 @@ void Monitor::forward_request_leader(MonOpRequestRef op) } send_mon_message(forward, mon); op->mark_forwarded(); - assert(op->get_req()->get_type() != 0); + ceph_assert(op->get_req()->get_type() != 0); } else { dout(10) << "forward_request no session for request " << *req << dendl; } @@ -3694,10 +3694,10 @@ struct AnonConnection : public Connection { socket_addr(sa) {} int send_message(Message *m) override { - assert(!"send_message on anonymous connection"); + ceph_assert(!"send_message on anonymous connection"); } void send_keepalive() override { - assert(!"send_keepalive on anonymous connection"); + ceph_assert(!"send_keepalive on anonymous connection"); } void mark_down() override { // silently ignore @@ -3720,7 +3720,7 @@ void Monitor::handle_forward(MonOpRequestRef op) << " " << m->client_addrs << " via " << m->get_source_inst() << dendl; MonSession *session = op->get_session(); - assert(session); + ceph_assert(session); if (!session->is_capable("mon", MON_CAP_X)) { dout(0) << "forward from entity with insufficient caps! " @@ -3729,7 +3729,7 @@ void Monitor::handle_forward(MonOpRequestRef op) // see PaxosService::dispatch(); we rely on this being anon // (c->msgr == NULL) PaxosServiceMessage *req = m->claim_message(); - assert(req != NULL); + ceph_assert(req != NULL); ConnectionRef c(new AnonConnection(cct, m->client_socket_addr)); MonSession *s = new MonSession(req->get_source(), @@ -3781,7 +3781,7 @@ void Monitor::send_reply(MonOpRequestRef op, Message *reply) op->mark_event(__func__); MonSession *session = op->get_session(); - assert(session); + ceph_assert(session); Message *req = op->get_req(); ConnectionRef con = op->get_connection(); @@ -3866,7 +3866,7 @@ void Monitor::handle_route(MonOpRequestRef op) osdmon()->send_incremental(m->send_osdmap_first, rr->session, true, MonOpRequestRef()); } - assert(rr->tid == m->session_mon_tid && rr->session->routed_request_tids.count(m->session_mon_tid)); + ceph_assert(rr->tid == m->session_mon_tid && rr->session->routed_request_tids.count(m->session_mon_tid)); routed_requests.erase(m->session_mon_tid); rr->session->routed_request_tids.erase(m->session_mon_tid); delete rr; @@ -3893,7 +3893,7 @@ void Monitor::resend_routed_requests() rr->op->mark_event("retry routed request"); retry.push_back(new C_RetryMessage(this, rr->op)); if (rr->session) { - assert(rr->session->routed_request_tids.count(p->first)); + ceph_assert(rr->session->routed_request_tids.count(p->first)); rr->session->routed_request_tids.erase(p->first); } delete rr; @@ -3924,12 +3924,12 @@ void Monitor::remove_session(MonSession *s) { dout(10) << "remove_session " << s << " " << s->name << " " << s->addrs << " features 0x" << std::hex << s->con_features << std::dec << dendl; - assert(s->con); - assert(!s->closed); + ceph_assert(s->con); + ceph_assert(!s->closed); for (set::iterator p = s->routed_request_tids.begin(); p != s->routed_request_tids.end(); ++p) { - assert(routed_requests.count(*p)); + ceph_assert(routed_requests.count(*p)); RoutedRequest *rr = routed_requests[*p]; dout(10) << " dropping routed request " << rr->tid << dendl; delete rr; @@ -4056,7 +4056,7 @@ void Monitor::_ms_dispatch(Message *m) m->get_source_addrs(), con.get()); } - assert(s); + ceph_assert(s); con->set_priv(RefCountedPtr{s, false}); dout(10) << __func__ << " new session " << s << " " << *s << " features 0x" << std::hex @@ -4078,7 +4078,7 @@ void Monitor::_ms_dispatch(Message *m) << dendl; } - assert(s); + ceph_assert(s); s->session_timeout = ceph_clock_now(); s->session_timeout += g_conf()->mon_session_timeout; @@ -4103,7 +4103,7 @@ void Monitor::dispatch_op(MonOpRequestRef op) { op->mark_event("mon:dispatch_op"); MonSession *s = op->get_session(); - assert(s); + ceph_assert(s); if (s->closed) { dout(10) << " session closed, dropping " << op->get_req() << dendl; return; @@ -4378,10 +4378,10 @@ void Monitor::timecheck_finish() void Monitor::timecheck_start_round() { dout(10) << __func__ << " curr " << timecheck_round << dendl; - assert(is_leader()); + ceph_assert(is_leader()); if (monmap->size() == 1) { - assert(0 == "We are alone; this shouldn't have been scheduled!"); + ceph_assert(0 == "We are alone; this shouldn't have been scheduled!"); return; } @@ -4399,7 +4399,7 @@ void Monitor::timecheck_start_round() } } - assert(timecheck_round % 2 == 0); + ceph_assert(timecheck_round % 2 == 0); timecheck_acks = 0; timecheck_round ++; timecheck_round_start = ceph_clock_now(); @@ -4414,13 +4414,13 @@ out: void Monitor::timecheck_finish_round(bool success) { dout(10) << __func__ << " curr " << timecheck_round << dendl; - assert(timecheck_round % 2); + ceph_assert(timecheck_round % 2); timecheck_round ++; timecheck_round_start = utime_t(); if (success) { - assert(timecheck_waiting.empty()); - assert(timecheck_acks == quorum.size()); + ceph_assert(timecheck_waiting.empty()); + ceph_assert(timecheck_acks == quorum.size()); timecheck_report(); timecheck_check_skews(); return; @@ -4487,13 +4487,13 @@ void Monitor::timecheck_reset_event() void Monitor::timecheck_check_skews() { dout(10) << __func__ << dendl; - assert(is_leader()); - assert((timecheck_round % 2) == 0); + ceph_assert(is_leader()); + ceph_assert((timecheck_round % 2) == 0); if (monmap->size() == 1) { - assert(0 == "We are alone; we shouldn't have gotten here!"); + ceph_assert(0 == "We are alone; we shouldn't have gotten here!"); return; } - assert(timecheck_latencies.size() == timecheck_skews.size()); + ceph_assert(timecheck_latencies.size() == timecheck_skews.size()); bool found_skew = false; for (auto& p : timecheck_skews) { @@ -4524,14 +4524,14 @@ void Monitor::timecheck_check_skews() void Monitor::timecheck_report() { dout(10) << __func__ << dendl; - assert(is_leader()); - assert((timecheck_round % 2) == 0); + ceph_assert(is_leader()); + ceph_assert((timecheck_round % 2) == 0); if (monmap->size() == 1) { - assert(0 == "We are alone; we shouldn't have gotten here!"); + ceph_assert(0 == "We are alone; we shouldn't have gotten here!"); return; } - assert(timecheck_latencies.size() == timecheck_skews.size()); + ceph_assert(timecheck_latencies.size() == timecheck_skews.size()); bool do_output = true; // only output report once for (set::iterator q = quorum.begin(); q != quorum.end(); ++q) { if (monmap->get_name(*q) == name) @@ -4563,12 +4563,12 @@ void Monitor::timecheck_report() void Monitor::timecheck() { dout(10) << __func__ << dendl; - assert(is_leader()); + ceph_assert(is_leader()); if (monmap->size() == 1) { - assert(0 == "We are alone; we shouldn't have gotten here!"); + ceph_assert(0 == "We are alone; we shouldn't have gotten here!"); return; } - assert(timecheck_round % 2 != 0); + ceph_assert(timecheck_round % 2 != 0); timecheck_acks = 1; // we ack ourselves @@ -4598,7 +4598,7 @@ health_status_t Monitor::timecheck_status(ostringstream &ss, const double latency) { health_status_t status = HEALTH_OK; - assert(latency >= 0); + ceph_assert(latency >= 0); double abs_skew; if (timecheck_has_skew(skew_bound, &abs_skew)) { @@ -4615,7 +4615,7 @@ void Monitor::handle_timecheck_leader(MonOpRequestRef op) MTimeCheck2 *m = static_cast(op->get_req()); dout(10) << __func__ << " " << *m << dendl; /* handles PONG's */ - assert(m->op == MTimeCheck2::OP_PONG); + ceph_assert(m->op == MTimeCheck2::OP_PONG); int other = m->get_source().num(); if (m->epoch < get_epoch()) { @@ -4625,7 +4625,7 @@ void Monitor::handle_timecheck_leader(MonOpRequestRef op) << " -- severely lagged? discard" << dendl; return; } - assert(m->epoch == get_epoch()); + ceph_assert(m->epoch == get_epoch()); if (m->round < timecheck_round) { dout(1) << __func__ << " got old round " << m->round @@ -4636,7 +4636,7 @@ void Monitor::handle_timecheck_leader(MonOpRequestRef op) utime_t curr_time = ceph_clock_now(); - assert(timecheck_waiting.count(other) > 0); + ceph_assert(timecheck_waiting.count(other) > 0); utime_t timecheck_sent = timecheck_waiting[other]; timecheck_waiting.erase(other); if (curr_time < timecheck_sent) { @@ -4695,7 +4695,7 @@ void Monitor::handle_timecheck_leader(MonOpRequestRef op) * may be masked by an even higher latency, but with high latencies * we probably have worse issues to deal with than just skewed clocks. */ - assert(latency >= 0); + ceph_assert(latency >= 0); double delta = ((double) m->timestamp) - ((double) curr_time); double abs_delta = (delta > 0 ? delta : -delta); @@ -4721,8 +4721,8 @@ void Monitor::handle_timecheck_leader(MonOpRequestRef op) if (timecheck_acks == quorum.size()) { dout(10) << __func__ << " got pongs from everybody (" << timecheck_acks << " total)" << dendl; - assert(timecheck_skews.size() == timecheck_acks); - assert(timecheck_waiting.empty()); + ceph_assert(timecheck_skews.size() == timecheck_acks); + ceph_assert(timecheck_waiting.empty()); // everyone has acked, so bump the round to finish it. timecheck_finish_round(); } @@ -4733,8 +4733,8 @@ void Monitor::handle_timecheck_peon(MonOpRequestRef op) MTimeCheck2 *m = static_cast(op->get_req()); dout(10) << __func__ << " " << *m << dendl; - assert(is_peon()); - assert(m->op == MTimeCheck2::OP_PING || m->op == MTimeCheck2::OP_REPORT); + ceph_assert(is_peon()); + ceph_assert(m->op == MTimeCheck2::OP_PING || m->op == MTimeCheck2::OP_REPORT); if (m->epoch != get_epoch()) { dout(1) << __func__ << " got wrong epoch " @@ -4753,13 +4753,13 @@ void Monitor::handle_timecheck_peon(MonOpRequestRef op) timecheck_round = m->round; if (m->op == MTimeCheck2::OP_REPORT) { - assert((timecheck_round % 2) == 0); + ceph_assert((timecheck_round % 2) == 0); timecheck_latencies.swap(m->latencies); timecheck_skews.swap(m->skews); return; } - assert((timecheck_round % 2) != 0); + ceph_assert((timecheck_round % 2) != 0); MTimeCheck2 *reply = new MTimeCheck2(MTimeCheck2::OP_PONG); utime_t curr_time = ceph_clock_now(); reply->timestamp = curr_time; @@ -4800,7 +4800,7 @@ void Monitor::handle_subscribe(MonOpRequestRef op) bool reply = false; MonSession *s = op->get_session(); - assert(s); + ceph_assert(s); for (map::iterator p = m->what.begin(); p != m->what.end(); @@ -4842,7 +4842,7 @@ void Monitor::handle_subscribe(MonOpRequestRef op) dout(10) << __func__ << ": MDS sub '" << p->first << "'" << dendl; if ((int)s->is_capable("mds", MON_CAP_R)) { Subscription *sub = s->sub_map[p->first]; - assert(sub != nullptr); + ceph_assert(sub != nullptr); mdsmon()->check_sub(sub); } } else if (p->first == "osdmap") { @@ -4888,7 +4888,7 @@ void Monitor::handle_get_version(MonOpRequestRef op) PaxosService *svc = NULL; MonSession *s = op->get_session(); - assert(s); + ceph_assert(s); if (!is_leader() && !is_peon()) { dout(10) << " waiting for quorum" << dendl; @@ -5014,7 +5014,7 @@ int Monitor::load_metadata() int Monitor::get_mon_metadata(int mon, Formatter *f, ostream& err) { - assert(f); + ceph_assert(f); if (!mon_metadata.count(mon)) { err << "mon." << mon << " not found"; return -EINVAL; @@ -5073,7 +5073,7 @@ int Monitor::print_nodes(Formatter *f, ostream& err) int Monitor::scrub_start() { dout(10) << __func__ << dendl; - assert(is_leader()); + ceph_assert(is_leader()); if (!scrub_result.empty()) { clog->info() << "scrub already in progress"; @@ -5090,8 +5090,8 @@ int Monitor::scrub_start() int Monitor::scrub() { - assert(is_leader()); - assert(scrub_state); + ceph_assert(is_leader()); + ceph_assert(scrub_state); scrub_cancel_timeout(); wait_for_paxos_write(); @@ -5127,7 +5127,7 @@ int Monitor::scrub() scrub_reset_timeout(); if (quorum.size() == 1) { - assert(scrub_state->finished == true); + ceph_assert(scrub_state->finished == true); scrub_finish(); } return 0; @@ -5168,7 +5168,7 @@ void Monitor::handle_scrub(MonOpRequestRef op) scrub_reset_timeout(); int from = m->get_source().num(); - assert(scrub_result.count(from) == 0); + ceph_assert(scrub_result.count(from) == 0); scrub_result[from] = m->result; if (scrub_result.size() == quorum.size()) { @@ -5188,9 +5188,9 @@ bool Monitor::_scrub(ScrubResult *r, pair *start, int *num_keys) { - assert(r != NULL); - assert(start != NULL); - assert(num_keys != NULL); + ceph_assert(r != NULL); + ceph_assert(start != NULL); + ceph_assert(num_keys != NULL); set prefixes = get_sync_targets_names(); prefixes.erase("paxos"); // exclude paxos, as this one may have extra states for proposals, etc. @@ -5221,7 +5221,7 @@ bool Monitor::_scrub(ScrubResult *r, bufferlist bl; int err = store->get(k.first, k.second, bl); - assert(err == 0); + ceph_assert(err == 0); uint32_t key_crc = bl.crc32c(0); dout(30) << __func__ << " " << k << " bl " << bl.length() << " bytes" @@ -5525,7 +5525,7 @@ int Monitor::check_fsid() int r = store->get(MONITOR_NAME, "cluster_uuid", ebl); if (r == -ENOENT) return r; - assert(r == 0); + ceph_assert(r == 0); string es(ebl.c_str(), ebl.length()); diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index df70638962433..e5311bb22327c 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -849,7 +849,7 @@ public: else if (r == -EAGAIN) mon->dispatch_op(op); else - assert(0 == "bad C_Command return value"); + ceph_assert(0 == "bad C_Command return value"); } }; @@ -866,7 +866,7 @@ public: else if (r == -ECANCELED) return; else - assert(0 == "bad C_RetryMessage return value"); + ceph_assert(0 == "bad C_RetryMessage return value"); } }; diff --git a/src/mon/MonitorDBStore.h b/src/mon/MonitorDBStore.h index 29ad0cda96b9a..730c5ff6721d4 100644 --- a/src/mon/MonitorDBStore.h +++ b/src/mon/MonitorDBStore.h @@ -308,7 +308,7 @@ class MonitorDBStore compact.pop_front(); } } else { - assert(0 == "failed to write to db"); + ceph_assert(0 == "failed to write to db"); } return r; } @@ -447,8 +447,8 @@ class MonitorDBStore * @param last_key[out] Last key in the chunk */ void get_chunk_tx(TransactionRef tx, uint64_t max) override { - assert(done == false); - assert(iter->valid() == true); + ceph_assert(done == false); + ceph_assert(iter->valid() == true); while (iter->valid()) { string prefix(iter->raw_key().first); @@ -460,12 +460,12 @@ class MonitorDBStore } iter->next(); } - assert(iter->valid() == false); + ceph_assert(iter->valid() == false); done = true; } pair get_next_key() override { - assert(iter->valid()); + ceph_assert(iter->valid()); for (; iter->valid(); iter->next()) { pair r = iter->raw_key(); @@ -498,7 +498,7 @@ class MonitorDBStore } KeyValueDB::Iterator get_iterator(const string &prefix) { - assert(!prefix.empty()); + ceph_assert(!prefix.empty()); KeyValueDB::Iterator iter = db->get_iterator(prefix); iter->seek_to_first(); return iter; @@ -512,7 +512,7 @@ class MonitorDBStore } int get(const string& prefix, const string& key, bufferlist& bl) { - assert(bl.length() == 0); + ceph_assert(bl.length() == 0); return db->get(prefix, key, &bl); } @@ -533,10 +533,10 @@ class MonitorDBStore generic_dout(0) << "MonitorDBStore::get() error obtaining" << " (" << prefix << ":" << key << "): " << cpp_strerror(err) << dendl; - assert(0 == "error obtaining key"); + ceph_assert(0 == "error obtaining key"); } - assert(bl.length()); + ceph_assert(bl.length()); version_t ver; auto p = bl.cbegin(); decode(ver, p); @@ -579,7 +579,7 @@ class MonitorDBStore dbt->rmkeys_by_prefix((*iter)); } int r = db->submit_transaction_sync(dbt); - assert(r >= 0); + ceph_assert(r >= 0); } void _open(string kv_type) { @@ -600,7 +600,7 @@ class MonitorDBStore derr << __func__ << " error initializing " << kv_type << " db back storage in " << full_path << dendl; - assert(0 == "MonitorDBStore: error initializing keyvaluedb back storage"); + ceph_assert(0 == "MonitorDBStore: error initializing keyvaluedb back storage"); } db.reset(db_ptr); @@ -761,7 +761,7 @@ class MonitorDBStore is_open(false) { } ~MonitorDBStore() { - assert(!is_open); + ceph_assert(!is_open); if (do_dump) { if (!g_conf()->mon_debug_dump_json) { ::close(dump_fd_binary); diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index a2cf06a92be10..818ef1a481801 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -67,8 +67,8 @@ void MonmapMonitor::update_from_paxos(bool *need_bootstrap) // read and decode monmap_bl.clear(); int ret = get_version(version, monmap_bl); - assert(ret == 0); - assert(monmap_bl.length()); + ceph_assert(ret == 0); + ceph_assert(monmap_bl.length()); dout(10) << __func__ << " got " << version << dendl; mon->monmap->decode(monmap_bl); @@ -94,7 +94,7 @@ void MonmapMonitor::encode_pending(MonitorDBStore::TransactionRef t) { dout(10) << __func__ << " epoch " << pending_map.epoch << dendl; - assert(mon->monmap->epoch + 1 == pending_map.epoch || + ceph_assert(mon->monmap->epoch + 1 == pending_map.epoch || pending_map.epoch == 1); // special case mkfs! bufferlist bl; pending_map.encode(bl, mon->get_quorum_con_features()); @@ -122,7 +122,7 @@ class C_ApplyFeatures : public Context { // established them in the first place. return; } else { - assert(0 == "bad C_ApplyFeatures return value"); + ceph_assert(0 == "bad C_ApplyFeatures return value"); } } }; @@ -135,11 +135,11 @@ void MonmapMonitor::apply_mon_features(const mon_feature_t& features) return; } - assert(is_writeable()); - assert(features.contains_all(pending_map.persistent_features)); + ceph_assert(is_writeable()); + ceph_assert(features.contains_all(pending_map.persistent_features)); // we should never hit this because `features` should be the result // of the quorum's supported features. But if it happens, die. - assert(ceph::features::mon::get_supported().contains_all(features)); + ceph_assert(ceph::features::mon::get_supported().contains_all(features)); mon_feature_t new_features = (pending_map.persistent_features ^ @@ -282,13 +282,13 @@ bool MonmapMonitor::preprocess_command(MonOpRequestRef op) ss << "there is no map for epoch " << epoch; goto reply; } - assert(r == 0); - assert(bl.length() > 0); + ceph_assert(r == 0); + ceph_assert(bl.length() > 0); p = new MonMap; p->decode(bl); } - assert(p); + ceph_assert(p); if (prefix == "mon getmap") { p->encode(rdata, m->get_connection()->get_features()); @@ -480,7 +480,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) * state, thus we are not bound by it. */ - assert(mon->monmap); + ceph_assert(mon->monmap); MonMap &monmap = *mon->monmap; diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index a3d91cda35583..97bb06a4703f5 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -347,7 +347,7 @@ void OSDMonitor::create_initial() int r = ceph_release_from_name( g_conf()->mon_osd_initial_require_min_compat_client.c_str()); if (r <= 0) { - assert(0 == "mon_osd_initial_require_min_compat_client is not valid"); + ceph_assert(0 == "mon_osd_initial_require_min_compat_client is not valid"); } newmap.require_min_compat_client = r; } @@ -378,7 +378,7 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) version_t version = get_last_committed(); if (version == osdmap.epoch) return; - assert(version > osdmap.epoch); + ceph_assert(version > osdmap.epoch); dout(15) << "update_from_paxos paxos e " << version << ", my e " << osdmap.epoch << dendl; @@ -431,7 +431,7 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) } } - assert(latest_full > 0); + ceph_assert(latest_full > 0); auto t(std::make_shared()); put_version_latest_full(t, latest_full); mon->store->apply_transaction(t); @@ -442,7 +442,7 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) if ((latest_full > 0) && (latest_full > osdmap.epoch)) { bufferlist latest_bl; get_version_full(latest_full, latest_bl); - assert(latest_bl.length() != 0); + ceph_assert(latest_bl.length() != 0); dout(7) << __func__ << " loading latest full map e" << latest_full << dendl; osdmap = OSDMap(); osdmap.decode(latest_bl); @@ -467,14 +467,14 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) while (version > osdmap.epoch) { bufferlist inc_bl; int err = get_version(osdmap.epoch+1, inc_bl); - assert(err == 0); - assert(inc_bl.length()); + ceph_assert(err == 0); + ceph_assert(inc_bl.length()); dout(7) << "update_from_paxos applying incremental " << osdmap.epoch+1 << dendl; OSDMap::Incremental inc(inc_bl); err = osdmap.apply_incremental(inc); - assert(err == 0); + ceph_assert(err == 0); if (!t) t.reset(new MonitorDBStore::Transaction); @@ -496,7 +496,7 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) get_version_full(osdmap.epoch, orig_full_bl); if (orig_full_bl.length()) { // the primary provided the full map - assert(inc.have_crc); + ceph_assert(inc.have_crc); if (inc.full_crc != osdmap.crc) { // This will happen if the mons were running mixed versions in // the past or some other circumstance made the full encoded @@ -527,7 +527,7 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) *_dout << dendl; } } else { - assert(!inc.have_crc); + ceph_assert(!inc.have_crc); put_version_full(t, osdmap.epoch, full_bl); } put_version_latest_full(t, osdmap.epoch); @@ -1028,7 +1028,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) pending_inc.modified = ceph_clock_now(); int r = pending_inc.propagate_snaps_to_tiers(cct, osdmap); - assert(r == 0); + ceph_assert(r == 0); if (mapping_job) { if (!mapping_job->is_done()) { @@ -1173,7 +1173,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) if (tmp.get_pg_pool(p)->has_flag(pg_pool_t::FLAG_FULL_QUOTA)) { // make sure FLAG_FULL is truly set, so we are safe not // to set a extra (redundant) FLAG_BACKFILLFULL flag - assert(tmp.get_pg_pool(p)->has_flag(pg_pool_t::FLAG_FULL)); + ceph_assert(tmp.get_pg_pool(p)->has_flag(pg_pool_t::FLAG_FULL)); continue; } if (tmp.get_pg_pool(p)->has_flag(pg_pool_t::FLAG_BACKFILLFULL)) { @@ -1216,7 +1216,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) if (tmp.get_pg_pool(p)->has_flag(pg_pool_t::FLAG_FULL_QUOTA)) { // make sure FLAG_FULL is truly set, so we are safe not // to set a extra (redundant) FLAG_NEARFULL flag - assert(tmp.get_pg_pool(p)->has_flag(pg_pool_t::FLAG_FULL)); + ceph_assert(tmp.get_pg_pool(p)->has_flag(pg_pool_t::FLAG_FULL)); continue; } if (tmp.get_pg_pool(p)->has_flag(pg_pool_t::FLAG_NEARFULL)) { @@ -1380,7 +1380,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) << " features " << features << dendl; // the features should be a subset of the mon quorum's features! - assert((features & ~mon->get_quorum_con_features()) == 0); + ceph_assert((features & ~mon->get_quorum_con_features()) == 0); bufferlist fullbl; encode(tmp, fullbl, features | CEPH_FEATURE_RESERVED); @@ -1393,7 +1393,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) } // encode - assert(get_last_committed() + 1 == pending_inc.epoch); + ceph_assert(get_last_committed() + 1 == pending_inc.epoch); bufferlist bl; encode(pending_inc, bl, features | CEPH_FEATURE_RESERVED); @@ -2174,13 +2174,13 @@ bool OSDMonitor::preprocess_get_osdmap(MonOpRequestRef op) e <= std::min(last, m->get_full_last()) && max > 0; ++e, --max) { int r = get_version_full(e, features, reply->maps[e]); - assert(r >= 0); + ceph_assert(r >= 0); } for (epoch_t e = std::max(first, m->get_inc_first()); e <= std::min(last, m->get_inc_last()) && max > 0; ++e, --max) { int r = get_version(e, features, reply->incremental_maps[e]); - assert(r >= 0); + ceph_assert(r >= 0); } reply->oldest_map = first; reply->newest_map = last; @@ -2353,8 +2353,8 @@ bool OSDMonitor::prepare_mark_me_down(MonOpRequestRef op) MOSDMarkMeDown *m = static_cast(op->get_req()); int target_osd = m->target_osd; - assert(osdmap.is_up(target_osd)); - assert(osdmap.get_addrs(target_osd) == m->target_addrs); + ceph_assert(osdmap.is_up(target_osd)); + ceph_assert(osdmap.get_addrs(target_osd) == m->target_addrs); mon->clog->info() << "osd." << target_osd << " marked itself down"; pending_inc.new_state[target_osd] = CEPH_OSD_UP; @@ -2516,7 +2516,7 @@ bool OSDMonitor::check_failure(utime_t now, int target_osd, failure_info_t& fi) // laggy. this is clearly not true in all cases, but will sometimes // help us localize the grace correction to a subset of the system // (say, a rack with a bad switch) that is unhappy. - assert(fi.reporters.size()); + ceph_assert(fi.reporters.size()); for (map::iterator p = fi.reporters.begin(); p != fi.reporters.end(); ++p) { @@ -2596,8 +2596,8 @@ bool OSDMonitor::prepare_failure(MonOpRequestRef op) int target_osd = m->get_target_osd(); int reporter = m->get_orig_source().num(); - assert(osdmap.is_up(target_osd)); - assert(osdmap.get_addrs(target_osd) == m->get_target_addrs()); + ceph_assert(osdmap.is_up(target_osd)); + ceph_assert(osdmap.get_addrs(target_osd) == m->get_target_addrs()); if (m->if_osd_failed()) { // calculate failure time @@ -2720,7 +2720,7 @@ bool OSDMonitor::preprocess_boot(MonOpRequestRef op) goto ignore; } - assert(m->get_orig_source_inst().name.is_osd()); + ceph_assert(m->get_orig_source_inst().name.is_osd()); // check if osd has required features to boot if (osdmap.require_osd_release >= CEPH_RELEASE_LUMINOUS && @@ -2826,7 +2826,7 @@ bool OSDMonitor::prepare_boot(MonOpRequestRef op) << " hb_front_addrs " << m->hb_front_addrs << dendl; - assert(m->get_orig_source().is_osd()); + ceph_assert(m->get_orig_source().is_osd()); int from = m->get_orig_source().num(); // does this osd exist? @@ -2845,9 +2845,9 @@ bool OSDMonitor::prepare_boot(MonOpRequestRef op) dout(7) << __func__ << " was up, first marking down osd." << from << " " << osdmap.get_addrs(from) << dendl; // preprocess should have caught these; if not, assert. - assert(osdmap.get_addrs(from) != m->get_orig_source_addrs() || + ceph_assert(osdmap.get_addrs(from) != m->get_orig_source_addrs() || osdmap.get_cluster_addrs(from) != m->cluster_addrs); - assert(osdmap.get_uuid(from) == m->sb.osd_fsid); + ceph_assert(osdmap.get_uuid(from) == m->sb.osd_fsid); if (pending_inc.new_state.count(from) == 0 || (pending_inc.new_state[from] & CEPH_OSD_UP) == 0) { @@ -2877,7 +2877,7 @@ bool OSDMonitor::prepare_boot(MonOpRequestRef op) << dendl; if (!osdmap.exists(from) || osdmap.get_uuid(from) != m->sb.osd_fsid) { // preprocess should have caught this; if not, assert. - assert(!osdmap.exists(from) || osdmap.get_uuid(from).is_zero()); + ceph_assert(!osdmap.exists(from) || osdmap.get_uuid(from).is_zero()); pending_inc.new_uuid[from] = m->sb.osd_fsid; } @@ -3495,14 +3495,14 @@ MOSDMap *OSDMonitor::build_incremental(epoch_t from, epoch_t to, uint64_t featur bufferlist bl; int err = get_version(e, features, bl); if (err == 0) { - assert(bl.length()); + ceph_assert(bl.length()); // if (get_version(e, bl) > 0) { dout(20) << "build_incremental inc " << e << " " << bl.length() << " bytes" << dendl; m->incremental_maps[e] = bl; } else { - assert(err == -ENOENT); - assert(!bl.length()); + ceph_assert(err == -ENOENT); + ceph_assert(!bl.length()); get_version_full(e, features, bl); if (bl.length() > 0) { //else if (get_version("full", e, bl) > 0) { @@ -3529,7 +3529,7 @@ void OSDMonitor::send_incremental(MonOpRequestRef op, epoch_t first) op->mark_osdmon_event(__func__); MonSession *s = op->get_session(); - assert(s); + ceph_assert(s); if (s->proxy_con) { // oh, we can tell the other mon to do it @@ -3575,8 +3575,8 @@ void OSDMonitor::send_incremental(epoch_t first, first = get_first_committed(); bufferlist bl; int err = get_version_full(first, features, bl); - assert(err == 0); - assert(bl.length()); + ceph_assert(err == 0); + ceph_assert(bl.length()); dout(20) << "send_incremental starting with base full " << first << " " << bl.length() << " bytes" << dendl; m->maps[first] = bl; @@ -3906,7 +3906,7 @@ void OSDMonitor::check_pg_creates_subs() if (!osdmap.get_num_up_osds()) { return; } - assert(osdmap.get_up_osd_features() & CEPH_FEATURE_MON_STATEFUL_SUB); + ceph_assert(osdmap.get_up_osd_features() & CEPH_FEATURE_MON_STATEFUL_SUB); mon->with_session_map([this](const MonSessionMap& session_map) { auto pg_creates_subs = session_map.subs.find("osd_pg_creates"); if (pg_creates_subs == session_map.subs.end()) { @@ -3921,7 +3921,7 @@ void OSDMonitor::check_pg_creates_subs() void OSDMonitor::check_pg_creates_sub(Subscription *sub) { dout(20) << __func__ << " .. " << sub->session->name << dendl; - assert(sub->type == "osd_pg_creates"); + ceph_assert(sub->type == "osd_pg_creates"); // only send these if the OSD is up. we will check_subs() when they do // come up so they will get the creates then. if (sub->session->name.is_osd() && @@ -3937,15 +3937,15 @@ void OSDMonitor::do_application_enable(int64_t pool_id, const std::string &app_key, const std::string &app_value) { - assert(paxos->is_plugged() && is_writeable()); + ceph_assert(paxos->is_plugged() && is_writeable()); dout(20) << __func__ << ": pool_id=" << pool_id << ", app_name=" << app_name << dendl; - assert(osdmap.require_osd_release >= CEPH_RELEASE_LUMINOUS); + ceph_assert(osdmap.require_osd_release >= CEPH_RELEASE_LUMINOUS); auto pp = osdmap.get_pg_pool(pool_id); - assert(pp != nullptr); + ceph_assert(pp != nullptr); pg_pool_t p = *pp; if (pending_inc.new_pools.count(pool_id)) { @@ -4060,7 +4060,7 @@ epoch_t OSDMonitor::send_pg_creates(int osd, Connection *con, epoch_t next) cons auto creating_pgs_by_epoch = creating_pgs_by_osd_epoch.find(osd); if (creating_pgs_by_epoch == creating_pgs_by_osd_epoch.end()) return next; - assert(!creating_pgs_by_epoch->second.empty()); + ceph_assert(!creating_pgs_by_epoch->second.empty()); MOSDPGCreate *oldm = nullptr; // for pre-mimic OSD compat MOSDPGCreate2 *m = nullptr; @@ -4085,7 +4085,7 @@ epoch_t OSDMonitor::send_pg_creates(int osd, Connection *con, epoch_t next) cons // Need the create time from the monitor using its clock to set // last_scrub_stamp upon pg creation. auto create = creating_pgs.pgs.find(pg.pgid); - assert(create != creating_pgs.pgs.end()); + ceph_assert(create != creating_pgs.pgs.end()); if (old) { if (!oldm) { oldm = new MOSDPGCreate(creating_pgs_epoch); @@ -4419,8 +4419,8 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) ss << "there is no map for epoch " << epoch; goto reply; } - assert(err == 0); - assert(osdmap_bl.length()); + ceph_assert(err == 0); + ceph_assert(osdmap_bl.length()); OSDMap *p; if (epoch == osdmap.get_epoch()) { @@ -5017,7 +5017,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) break; } } - assert(i != ALL_CHOICES.end()); + ceph_assert(i != ALL_CHOICES.end()); switch(*it) { case PG_NUM: f->dump_int("pg_num", p->get_pg_num()); @@ -5275,7 +5275,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) if (i->second == *it) break; } - assert(i != ALL_CHOICES.end()); + ceph_assert(i != ALL_CHOICES.end()); ss << i->first << ": " << (p->has_flag(pg_pool_t::get_flag_by_name(i->first)) ? "true" : "false") << "\n"; @@ -5305,7 +5305,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) if (i->second == *it) break; } - assert(i != ALL_CHOICES.end()); + ceph_assert(i != ALL_CHOICES.end()); { pool_opts_t::key_t key = pool_opts_t::get_opt_desc(i->first).key; if (p->opts.is_set(key)) { @@ -5331,7 +5331,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) int64_t poolid = osdmap.lookup_pg_pool_name(pool_name); if (poolid < 0) { - assert(poolid == -ENOENT); + ceph_assert(poolid == -ENOENT); ss << "unrecognized pool '" << pool_name << "'"; r = -ENOENT; goto reply; @@ -5709,7 +5709,7 @@ void OSDMonitor::set_pool_flags(int64_t pool_id, uint64_t flags) { pg_pool_t *pool = pending_inc.get_new_pool(pool_id, osdmap.get_pg_pool(pool_id)); - assert(pool); + ceph_assert(pool); pool->set_flag(flags); } @@ -5717,7 +5717,7 @@ void OSDMonitor::clear_pool_flags(int64_t pool_id, uint64_t flags) { pg_pool_t *pool = pending_inc.get_new_pool(pool_id, osdmap.get_pg_pool(pool_id)); - assert(pool); + ceph_assert(pool); pool->unset_flag(flags); } @@ -5842,7 +5842,7 @@ bool OSDMonitor::try_prune_purged_snaps() } if (pbegin && pbegin < end) { // the tail of [begin,end) is purged; shorten the range - assert(pbegin > begin); + ceph_assert(pbegin > begin); end = pbegin; } to_prune.insert(begin, end - begin); @@ -6235,7 +6235,7 @@ int OSDMonitor::parse_erasure_code_profile(const vector &erasure_code_pr true); if (r) return r; - assert((*erasure_code_profile_map).count("plugin")); + ceph_assert((*erasure_code_profile_map).count("plugin")); string default_plugin = (*erasure_code_profile_map)["plugin"]; map user_map; for (vector::const_iterator i = erasure_code_profile.begin(); @@ -6318,7 +6318,7 @@ int OSDMonitor::prepare_pool_stripe_width(const unsigned pool_type, if (it != profile.end()) { string err_str; stripe_unit = strict_iecstrtoll(it->second.c_str(), &err_str); - assert(err_str.empty()); + ceph_assert(err_str.empty()); } *stripe_width = data_chunks * erasure_code->get_chunk_size(stripe_unit * data_chunks); @@ -7114,7 +7114,7 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap, } break; default: - assert(!"unknown type"); + ceph_assert(!"unknown type"); } } else { ss << "unrecognized variable '" << var << "'"; @@ -7334,7 +7334,7 @@ int OSDMonitor::prepare_command_osd_crush_remove( if (err < 0) return err; - assert(err == 0); + ceph_assert(err == 0); do_osd_crush_remove(newcrush); return 0; @@ -7356,7 +7356,7 @@ int OSDMonitor::prepare_command_osd_remove(int32_t id) int32_t OSDMonitor::_allocate_osd_id(int32_t* existing_id) { - assert(existing_id); + ceph_assert(existing_id); *existing_id = -1; for (int32_t i = 0; i < osdmap.get_max_osd(); ++i) { @@ -7382,7 +7382,7 @@ void OSDMonitor::do_osd_create( int32_t* new_id) { dout(10) << __func__ << " uuid " << uuid << dendl; - assert(new_id); + ceph_assert(new_id); // We presume validation has been performed prior to calling this // function. We assert with prejudice. @@ -7392,7 +7392,7 @@ void OSDMonitor::do_osd_create( if (!uuid.is_zero()) { existing_id = osdmap.identify_osd(uuid); if (existing_id >= 0) { - assert(id < 0 || id == existing_id); + ceph_assert(id < 0 || id == existing_id); *new_id = existing_id; goto out; } else if (id >= 0) { @@ -7408,12 +7408,12 @@ void OSDMonitor::do_osd_create( dout(10) << __func__ << " allocated id " << allocated_id << " existing id " << existing_id << dendl; if (existing_id >= 0) { - assert(existing_id < osdmap.get_max_osd()); - assert(allocated_id < 0); + ceph_assert(existing_id < osdmap.get_max_osd()); + ceph_assert(allocated_id < 0); pending_inc.new_weight[existing_id] = CEPH_OSD_OUT; *new_id = existing_id; } else if (allocated_id >= 0) { - assert(existing_id < 0); + ceph_assert(existing_id < 0); // raise max_osd if (pending_inc.new_max_osd < 0) { pending_inc.new_max_osd = osdmap.get_max_osd() + 1; @@ -7421,9 +7421,9 @@ void OSDMonitor::do_osd_create( ++pending_inc.new_max_osd; } *new_id = pending_inc.new_max_osd - 1; - assert(*new_id == allocated_id); + ceph_assert(*new_id == allocated_id); } else { - assert(0 == "unexpected condition"); + ceph_assert(0 == "unexpected condition"); } out: @@ -7475,7 +7475,7 @@ int OSDMonitor::validate_osd_create( dout(10) << __func__ << " id " << id << " uuid " << uuid << " check_osd_exists " << check_osd_exists << dendl; - assert(existing_id); + ceph_assert(existing_id); if (id < 0 && uuid.is_zero()) { // we have nothing to validate @@ -7499,7 +7499,7 @@ int OSDMonitor::validate_osd_create( * provided, but we will always guarantee the idempotency of `osd new`. */ - assert(!uuid.is_zero()); + ceph_assert(!uuid.is_zero()); if (pending_inc.identify_osd(uuid) >= 0) { // osd is about to exist return -EAGAIN; @@ -7542,7 +7542,7 @@ int OSDMonitor::prepare_command_osd_create( stringstream& ss) { dout(10) << __func__ << " id " << id << " uuid " << uuid << dendl; - assert(existing_id); + ceph_assert(existing_id); if (osdmap.is_destroyed(id)) { ss << "ceph osd create has been deprecated. Please use ceph osd new " "instead."; @@ -7567,7 +7567,7 @@ int OSDMonitor::prepare_command_osd_new( string uuidstr; int64_t id = -1; - assert(paxos->is_plugged()); + ceph_assert(paxos->is_plugged()); dout(10) << __func__ << " " << op << dendl; @@ -7622,7 +7622,7 @@ int OSDMonitor::prepare_command_osd_new( if (err == EEXIST) { // this is idempotent from the osdmon's point-of-view may_be_idempotent = true; - assert(existing_id >= 0); + ceph_assert(existing_id >= 0); id = existing_id; } else if (err < 0) { return err; @@ -7649,7 +7649,7 @@ int OSDMonitor::prepare_command_osd_new( // find an `id` id = _allocate_osd_id(&existing_id); if (id < 0) { - assert(existing_id >= 0); + ceph_assert(existing_id >= 0); id = existing_id; } dout(10) << __func__ << " found id " << id << " to use" << dendl; @@ -7659,8 +7659,8 @@ int OSDMonitor::prepare_command_osd_new( dout(10) << __func__ << " creating new osd." << id << dendl; } } else { - assert(id >= 0); - assert(osdmap.exists(id)); + ceph_assert(id >= 0); + ceph_assert(osdmap.exists(id)); } // we are now able to either create a brand new osd or reuse an existing @@ -7671,7 +7671,7 @@ int OSDMonitor::prepare_command_osd_new( if (may_be_idempotent && params.empty()) { // nothing to do, really. dout(10) << __func__ << " idempotent and no params -- no op." << dendl; - assert(id >= 0); + ceph_assert(id >= 0); if (f) { f->open_object_section("created_osd"); f->dump_int("osdid", id); @@ -7732,7 +7732,7 @@ int OSDMonitor::prepare_command_osd_new( } else if (may_be_idempotent && err != EEXIST) { // for this to be idempotent, `id` should already be >= 0; no need // to use validate_id. - assert(id >= 0); + ceph_assert(id >= 0); ss << "osd." << id << " exists but secrets do not match"; return -EEXIST; } @@ -7743,14 +7743,14 @@ int OSDMonitor::prepare_command_osd_new( if (err < 0) { return err; } else if (may_be_idempotent && err != EEXIST) { - assert(id >= 0); + ceph_assert(id >= 0); ss << "osd." << id << " exists but dm-crypt key does not match."; return -EEXIST; } } } - assert(!has_secrets || !cephx_secret.empty()); - assert(!has_lockbox || !lockbox_secret.empty()); + ceph_assert(!has_secrets || !cephx_secret.empty()); + ceph_assert(!has_lockbox || !lockbox_secret.empty()); if (may_be_idempotent) { // we have nothing to do for either the osdmon or the authmon, @@ -7758,7 +7758,7 @@ int OSDMonitor::prepare_command_osd_new( // touched. This is therefore an idempotent operation, and we can // just return right away. dout(10) << __func__ << " idempotent -- no op." << dendl; - assert(id >= 0); + ceph_assert(id >= 0); if (f) { f->open_object_section("created_osd"); f->dump_int("osdid", id); @@ -7768,28 +7768,28 @@ int OSDMonitor::prepare_command_osd_new( } return EEXIST; } - assert(!may_be_idempotent); + ceph_assert(!may_be_idempotent); // perform updates. if (has_secrets) { - assert(!cephx_secret.empty()); - assert((lockbox_secret.empty() && dmcrypt_key.empty()) || + ceph_assert(!cephx_secret.empty()); + ceph_assert((lockbox_secret.empty() && dmcrypt_key.empty()) || (!lockbox_secret.empty() && !dmcrypt_key.empty())); err = mon->authmon()->do_osd_new(cephx_entity, lockbox_entity, has_lockbox); - assert(0 == err); + ceph_assert(0 == err); if (has_lockbox) { - assert(nullptr != svc); + ceph_assert(nullptr != svc); svc->do_osd_new(uuid, dmcrypt_key); } } if (is_recreate_destroyed) { - assert(id >= 0); - assert(osdmap.is_destroyed(id)); + ceph_assert(id >= 0); + ceph_assert(osdmap.is_destroyed(id)); pending_inc.new_weight[id] = CEPH_OSD_OUT; pending_inc.new_state[id] |= CEPH_OSD_DESTROYED; if ((osdmap.get_state(id) & CEPH_OSD_NEW) == 0) { @@ -7803,11 +7803,11 @@ int OSDMonitor::prepare_command_osd_new( } pending_inc.new_uuid[id] = uuid; } else { - assert(id >= 0); + ceph_assert(id >= 0); int32_t new_id = -1; do_osd_create(id, uuid, device_class, &new_id); - assert(new_id >= 0); - assert(id == new_id); + ceph_assert(new_id >= 0); + ceph_assert(id == new_id); } if (f) { @@ -7882,7 +7882,7 @@ int OSDMonitor::prepare_command_osd_destroy( int32_t id, stringstream& ss) { - assert(paxos->is_plugged()); + ceph_assert(paxos->is_plugged()); // we check if the osd exists for the benefit of `osd purge`, which may // have previously removed the osd. If the osd does not exist, return @@ -7925,14 +7925,14 @@ int OSDMonitor::prepare_command_osd_destroy( ConfigKeyService *svc = (ConfigKeyService*)mon->config_key_service; err = svc->validate_osd_destroy(id, uuid); if (err < 0) { - assert(err == -ENOENT); + ceph_assert(err == -ENOENT); err = 0; idempotent_cks = true; } if (!idempotent_auth) { err = mon->authmon()->do_osd_destroy(cephx_entity, lockbox_entity); - assert(0 == err); + ceph_assert(0 == err); } if (!idempotent_cks) { @@ -7946,7 +7946,7 @@ int OSDMonitor::prepare_command_osd_destroy( // defying PaxosService and all laws of nature. Therefore, as we may // be used during 'osd purge', let's keep the caller responsible for // proposing. - assert(err == 0); + ceph_assert(err == 0); return 0; } @@ -7954,10 +7954,10 @@ int OSDMonitor::prepare_command_osd_purge( int32_t id, stringstream& ss) { - assert(paxos->is_plugged()); + ceph_assert(paxos->is_plugged()); dout(10) << __func__ << " purging osd." << id << dendl; - assert(!osdmap.is_up(id)); + ceph_assert(!osdmap.is_up(id)); /* * This may look a bit weird, but this is what's going to happen: @@ -8003,7 +8003,7 @@ int OSDMonitor::prepare_command_osd_purge( may_be_idempotent = false; } } - assert(0 == err); + ceph_assert(0 == err); if (may_be_idempotent && !osdmap.exists(id)) { dout(10) << __func__ << " osd." << id << " does not exist and " @@ -8013,7 +8013,7 @@ int OSDMonitor::prepare_command_osd_purge( err = prepare_command_osd_remove(id); // we should not be busy, as we should have made sure this id is not up. - assert(0 == err); + ceph_assert(0 == err); do_osd_crush_remove(newcrush); return 0; @@ -9332,7 +9332,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, err = 0; } else { int ruleno = newcrush.get_rule_id(name); - assert(ruleno >= 0); + ceph_assert(ruleno >= 0); // make sure it is not in use. // FIXME: this is ok in some situations, but let's not bother with that @@ -9690,7 +9690,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, err = 0; goto reply; } - assert(osdmap.require_osd_release >= CEPH_RELEASE_LUMINOUS); + ceph_assert(osdmap.require_osd_release >= CEPH_RELEASE_LUMINOUS); if (!osdmap.get_num_up_osds() && sure != "--yes-i-really-mean-it") { ss << "Not advisable to continue since no OSDs are up. Pass " << "--yes-i-really-mean-it if you really wish to continue."; @@ -9829,7 +9829,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << ", "; ss << "osd." << osd << " is still up; must be down before removal. "; } else { - assert(err == 0); + ceph_assert(err == 0); if (any) { ss << ", osd." << osd; } else { @@ -9969,7 +9969,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, break; default: - assert(0 == "invalid option"); + ceph_assert(0 == "invalid option"); } } } @@ -10031,7 +10031,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, osdmap.get_noout_osds(&osds); break; default: - assert(0 == "invalid option"); + ceph_assert(0 == "invalid option"); } // cancel any pending noup/nodown/noin/noout requests too @@ -10069,7 +10069,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, break; default: - assert(0 == "invalid option"); + ceph_assert(0 == "invalid option"); } } @@ -10137,7 +10137,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, break; default: - assert(0 == "invalid option"); + ceph_assert(0 == "invalid option"); } } } @@ -10387,7 +10387,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, break; default: - assert(0 == "invalid option"); + ceph_assert(0 == "invalid option"); } switch (option) { @@ -10530,7 +10530,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, break; default: - assert(0 == "invalid option"); + ceph_assert(0 == "invalid option"); } goto update; @@ -10691,7 +10691,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, bool is_destroy = (prefix == "osd destroy-actual"); if (!is_destroy) { - assert("osd purge-actual" == prefix || + ceph_assert("osd purge-actual" == prefix || "osd purge-new" == prefix); } @@ -10731,7 +10731,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (is_destroy) { err = prepare_command_osd_destroy(id, ss); // we checked above that it should exist. - assert(err != -ENOENT); + ceph_assert(err != -ENOENT); } else { err = prepare_command_osd_purge(id, ss); if (err == -ENOENT) { @@ -11302,9 +11302,9 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, goto reply; } const pg_pool_t *p = osdmap.get_pg_pool(pool_id); - assert(p); + ceph_assert(p); const pg_pool_t *tp = osdmap.get_pg_pool(tierpool_id); - assert(tp); + ceph_assert(tp); if (!_check_become_tier(tierpool_id, tp, pool_id, p, &err, &ss)) { goto reply; @@ -11366,9 +11366,9 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, goto reply; } const pg_pool_t *p = osdmap.get_pg_pool(pool_id); - assert(p); + ceph_assert(p); const pg_pool_t *tp = osdmap.get_pg_pool(tierpool_id); - assert(tp); + ceph_assert(tp); if (!_check_remove_tier(pool_id, p, tp, &err, &ss)) { goto reply; @@ -11430,9 +11430,9 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, goto reply; } const pg_pool_t *p = osdmap.get_pg_pool(pool_id); - assert(p); + ceph_assert(p); const pg_pool_t *overlay_p = osdmap.get_pg_pool(overlaypool_id); - assert(overlay_p); + ceph_assert(overlay_p); if (p->tiers.count(overlaypool_id) == 0) { ss << "tier pool '" << overlaypoolstr << "' is not a tier of '" << poolstr << "'"; err = -EINVAL; @@ -11475,7 +11475,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, goto reply; } const pg_pool_t *p = osdmap.get_pg_pool(pool_id); - assert(p); + ceph_assert(p); if (!p->has_read_tier()) { err = 0; ss << "there is now (or already was) no overlay for '" << poolstr << "'"; @@ -11520,7 +11520,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, goto reply; } const pg_pool_t *p = osdmap.get_pg_pool(pool_id); - assert(p); + ceph_assert(p); if (!p->is_tier()) { ss << "pool '" << poolstr << "' is not a tier"; err = -EINVAL; @@ -11647,7 +11647,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << "' to " << pg_pool_t::get_cache_mode_name(mode); if (mode == pg_pool_t::CACHEMODE_NONE) { const pg_pool_t *base_pool = osdmap.get_pg_pool(np->tier_of); - assert(base_pool); + ceph_assert(base_pool); if (base_pool->read_tier == pool_id || base_pool->write_tier == pool_id) ss <<" (WARNING: pool is still configured as read or write tier)"; @@ -11678,9 +11678,9 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, goto reply; } const pg_pool_t *p = osdmap.get_pg_pool(pool_id); - assert(p); + ceph_assert(p); const pg_pool_t *tp = osdmap.get_pg_pool(tierpool_id); - assert(tp); + ceph_assert(tp); if (!_check_become_tier(tierpool_id, tp, pool_id, p, &err, &ss)) { goto reply; @@ -11779,7 +11779,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } else if (field == "max_bytes") { value = strict_iecstrtoll(val.c_str(), &tss); } else { - assert(0 == "unrecognized option"); + ceph_assert(0 == "unrecognized option"); } if (!tss.empty()) { ss << "error parsing value '" << val << "': " << tss; @@ -11793,7 +11793,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } else if (field == "max_bytes") { pi->quota_max_bytes = value; } else { - assert(0 == "unrecognized option"); + ceph_assert(0 == "unrecognized option"); } ss << "set-quota " << field << " = " << value << " for pool " << poolstr; rs = ss.str(); @@ -12244,7 +12244,7 @@ bool OSDMonitor::_check_become_tier( } if (base_pool->tiers.count(tier_pool_id)) { - assert(tier_pool->tier_of == base_pool_id); + ceph_assert(tier_pool->tier_of == base_pool_id); *err = 0; *ss << "pool '" << tier_pool_name << "' is now (or already was) a tier of '" << base_pool_name << "'"; diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 5e37af1b36855..9dfbf4c8a0ee8 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -491,7 +491,7 @@ private: else if (r == -EAGAIN) cmon->dispatch(op); else - assert(0 == "bad C_Booted return value"); + ceph_assert(0 == "bad C_Booted return value"); } }; @@ -508,7 +508,7 @@ private: else if (r == -EAGAIN) osdmon->dispatch(op); else - assert(0 == "bad C_ReplyMap return value"); + ceph_assert(0 == "bad C_ReplyMap return value"); } }; struct C_PoolOp : public C_MonOp { @@ -529,7 +529,7 @@ private: else if (r == -EAGAIN) osdmon->dispatch(op); else - assert(0 == "bad C_PoolOp return value"); + ceph_assert(0 == "bad C_PoolOp return value"); } }; diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index f063b32b47129..63939f600cb8e 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -494,7 +494,7 @@ void PGMapDigest::pool_recovery_rate_summary(Formatter *f, ostream *out, return; auto ts = per_pool_sum_deltas_stamps.find(p->first); - assert(ts != per_pool_sum_deltas_stamps.end()); + ceph_assert(ts != per_pool_sum_deltas_stamps.end()); recovery_rate_summary(f, out, p->second.first, ts->second); } @@ -556,7 +556,7 @@ void PGMapDigest::pool_client_io_rate_summary(Formatter *f, ostream *out, return; auto ts = per_pool_sum_deltas_stamps.find(p->first); - assert(ts != per_pool_sum_deltas_stamps.end()); + ceph_assert(ts != per_pool_sum_deltas_stamps.end()); client_io_rate_summary(f, out, p->second.first, ts->second); } @@ -653,7 +653,7 @@ void PGMapDigest::pool_cache_io_rate_summary(Formatter *f, ostream *out, return; auto ts = per_pool_sum_deltas_stamps.find(p->first); - assert(ts != per_pool_sum_deltas_stamps.end()); + ceph_assert(ts != per_pool_sum_deltas_stamps.end()); cache_io_rate_summary(f, out, p->second.first, ts->second); } @@ -675,8 +675,8 @@ static float pool_raw_used_rate(const OSDMap &osd_map, int64_t poolid) int k = atoi(pk->second.c_str()); int m = atoi(pm->second.c_str()); int mk = m + k; - assert(mk != 0); - assert(k != 0); + ceph_assert(mk != 0); + ceph_assert(k != 0); return (float)mk / k; } else { return 0.0; @@ -684,7 +684,7 @@ static float pool_raw_used_rate(const OSDMap &osd_map, int64_t poolid) } break; default: - assert(0 == "unrecognized pool type"); + ceph_assert(0 == "unrecognized pool type"); } } @@ -809,7 +809,7 @@ void PGMapDigest::dump_pool_stats_full( if (f) f->close_section(); else { - assert(ss != nullptr); + ceph_assert(ss != nullptr); *ss << "POOLS:\n"; tbl.set_indent(4); *ss << tbl; @@ -834,7 +834,7 @@ void PGMapDigest::dump_fs_stats(stringstream *ss, Formatter *f, bool verbose) co } f->close_section(); } else { - assert(ss != nullptr); + ceph_assert(ss != nullptr); TextTable tbl; tbl.define_column("SIZE", TextTable::LEFT, TextTable::RIGHT); tbl.define_column("AVAIL", TextTable::LEFT, TextTable::RIGHT); @@ -1047,7 +1047,7 @@ void PGMap::Incremental::generate_test_instances(list& o) void PGMap::apply_incremental(CephContext *cct, const Incremental& inc) { - assert(inc.version == version+1); + ceph_assert(inc.version == version+1); version++; pool_stat_t pg_sum_old = pg_sum; @@ -1226,7 +1226,7 @@ void PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, num_pg--; int end = --num_pg_by_state[s.state]; - assert(end >= 0); + ceph_assert(end >= 0); if (end == 0) num_pg_by_state.erase(s.state); end = --num_pg_by_pool[pgid.pool()]; @@ -1262,7 +1262,7 @@ void PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, p != s.blocked_by.end(); ++p) { auto q = blocked_by_sum.find(*p); - assert(q != blocked_by_sum.end()); + ceph_assert(q != blocked_by_sum.end()); --q->second; if (q->second == 0) blocked_by_sum.erase(q); @@ -1330,7 +1330,7 @@ void PGMap::stat_osd_sub(int osd, const osd_stat_t &s) { num_osd--; osd_sum.sub(s); - assert(osd < (int)osd_last_seq.size()); + ceph_assert(osd < (int)osd_last_seq.size()); osd_last_seq[osd] = 0; } @@ -1696,7 +1696,7 @@ void PGMap::get_stuck_stats( int types, const utime_t cutoff, mempool::pgmap::unordered_map& stuck_pgs) const { - assert(types != 0); + ceph_assert(types != 0); for (auto i = pg_stat.begin(); i != pg_stat.end(); ++i) { @@ -1986,8 +1986,8 @@ void PGMap::update_one_pool_delta( const pool_stat_t& old_pool_sum) { if (per_pool_sum_deltas.count(pool) == 0) { - assert(per_pool_sum_deltas_stamps.count(pool) == 0); - assert(per_pool_sum_delta.count(pool) == 0); + ceph_assert(per_pool_sum_deltas_stamps.count(pool) == 0); + ceph_assert(per_pool_sum_delta.count(pool) == 0); } auto& sum_delta = per_pool_sum_delta[pool]; @@ -3387,7 +3387,7 @@ void PGMapUpdater::check_down_pgs( } for (auto pgid : p->second) { const pg_stat_t &stat = pg_map.pg_stat.at(pgid); - assert(stat.acting_primary == osd); + ceph_assert(stat.acting_primary == osd); _try_mark_pg_stale(osdmap, pgid, stat, pending_inc); } } diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index dc87aa6e056c2..bd0f802244452 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -60,8 +60,8 @@ void Paxos::read_and_prepare_transactions(MonitorDBStore::TransactionRef tx, dout(30) << __func__ << " apply version " << v << dendl; bufferlist bl; int err = get_store()->get(get_name(), v, bl); - assert(err == 0); - assert(bl.length()); + ceph_assert(err == 0); + ceph_assert(bl.length()); decode_append_transaction(tx, bl); } dout(15) << __func__ << " total versions " << (last-first) << dendl; @@ -80,7 +80,7 @@ void Paxos::init() << " first_committed: " << first_committed << dendl; dout(10) << "init" << dendl; - assert(is_consistent()); + ceph_assert(is_consistent()); } void Paxos::init_logger() @@ -147,7 +147,7 @@ void Paxos::collect(version_t oldpn) { // we're recoverying, it seems! state = STATE_RECOVERING; - assert(mon->is_leader()); + ceph_assert(mon->is_leader()); // reset the number of lasts received uncommitted_v = 0; @@ -170,7 +170,7 @@ void Paxos::collect(version_t oldpn) uncommitted_v = last_committed+1; get_store()->get(get_name(), last_committed+1, uncommitted_value); - assert(uncommitted_value.length()); + ceph_assert(uncommitted_value.length()); dout(10) << "learned uncommitted " << (last_committed+1) << " pn " << uncommitted_pn << " (" << uncommitted_value.length() << " bytes) from myself" @@ -220,7 +220,7 @@ void Paxos::handle_collect(MonOpRequestRef op) MMonPaxos *collect = static_cast(op->get_req()); dout(10) << "handle_collect " << *collect << dendl; - assert(mon->is_peon()); // mon epoch filter should catch strays + ceph_assert(mon->is_peon()); // mon epoch filter should catch strays // we're recoverying, it seems! state = STATE_RECOVERING; @@ -291,7 +291,7 @@ void Paxos::handle_collect(MonOpRequestRef op) if (collect->last_committed <= last_committed && get_store()->exists(get_name(), last_committed+1)) { get_store()->get(get_name(), last_committed+1, bl); - assert(bl.length() > 0); + ceph_assert(bl.length() > 0); dout(10) << " sharing our accepted but uncommitted value for " << last_committed+1 << " (" << bl.length() << " bytes)" << dendl; last->values[last_committed+1] = bl; @@ -330,7 +330,7 @@ void Paxos::handle_collect(MonOpRequestRef op) void Paxos::share_state(MMonPaxos *m, version_t peer_first_committed, version_t peer_last_committed) { - assert(peer_last_committed < last_committed); + ceph_assert(peer_last_committed < last_committed); dout(10) << "share_state peer has fc " << peer_first_committed << " lc " << peer_last_committed << dendl; @@ -341,7 +341,7 @@ void Paxos::share_state(MMonPaxos *m, version_t peer_first_committed, for ( ; v <= last_committed; v++) { if (get_store()->exists(get_name(), v)) { get_store()->get(get_name(), v, m->values[v]); - assert(m->values[v].length()); + ceph_assert(m->values[v].length()); dout(10) << " sharing " << v << " (" << m->values[v].length() << " bytes)" << dendl; bytes += m->values[v].length() + 16; // paxos_ + 10 digits = 16 @@ -453,7 +453,7 @@ bool Paxos::store_state(MMonPaxos *m) void Paxos::_sanity_check_store() { version_t lc = get_store()->get(get_name(), "last_committed"); - assert(lc == last_committed); + ceph_assert(lc == last_committed); } @@ -488,12 +488,12 @@ void Paxos::handle_last(MonOpRequestRef op) return; } - assert(g_conf()->paxos_kill_at != 1); + ceph_assert(g_conf()->paxos_kill_at != 1); // store any committed values if any are specified in the message need_refresh = store_state(last); - assert(g_conf()->paxos_kill_at != 2); + ceph_assert(g_conf()->paxos_kill_at != 2); // is everyone contiguous and up to date? for (map::iterator p = peer_last_committed.begin(); @@ -597,7 +597,7 @@ void Paxos::collect_timeout() dout(1) << "collect timeout, calling fresh election" << dendl; collect_timeout_event = 0; logger->inc(l_paxos_collect_timeout); - assert(mon->is_leader()); + ceph_assert(mon->is_leader()); mon->bootstrap(); } @@ -609,15 +609,15 @@ void Paxos::begin(bufferlist& v) << v.length() << " bytes" << dendl; - assert(mon->is_leader()); - assert(is_updating() || is_updating_previous()); + ceph_assert(mon->is_leader()); + ceph_assert(is_updating() || is_updating_previous()); // we must already have a majority for this to work. - assert(mon->get_quorum().size() == 1 || + ceph_assert(mon->get_quorum().size() == 1 || num_last > (unsigned)mon->monmap->size()/2); // and no value, yet. - assert(new_value.length() == 0); + ceph_assert(new_value.length() == 0); // accept it ourselves accepted.clear(); @@ -667,7 +667,7 @@ void Paxos::begin(bufferlist& v) logger->tinc(l_paxos_begin_latency, to_timespan(end - start)); - assert(g_conf()->paxos_kill_at != 3); + ceph_assert(g_conf()->paxos_kill_at != 3); if (mon->get_quorum().size() == 1) { // we're alone, take it easy @@ -714,10 +714,10 @@ void Paxos::handle_begin(MonOpRequestRef op) op->mark_paxos_event("have higher pn, ignore"); return; } - assert(begin->pn == accepted_pn); - assert(begin->last_committed == last_committed); + ceph_assert(begin->pn == accepted_pn); + ceph_assert(begin->last_committed == last_committed); - assert(g_conf()->paxos_kill_at != 4); + ceph_assert(g_conf()->paxos_kill_at != 4); logger->inc(l_paxos_begin); @@ -751,7 +751,7 @@ void Paxos::handle_begin(MonOpRequestRef op) logger->tinc(l_paxos_begin_latency, to_timespan(end - start)); - assert(g_conf()->paxos_kill_at != 5); + ceph_assert(g_conf()->paxos_kill_at != 5); // reply MMonPaxos *accept = new MMonPaxos(mon->get_epoch(), MMonPaxos::OP_ACCEPT, @@ -781,15 +781,15 @@ void Paxos::handle_accept(MonOpRequestRef op) op->mark_paxos_event("old round, ignore"); return; } - assert(accept->last_committed == last_committed || // not committed + ceph_assert(accept->last_committed == last_committed || // not committed accept->last_committed == last_committed-1); // committed - assert(is_updating() || is_updating_previous()); - assert(accepted.count(from) == 0); + ceph_assert(is_updating() || is_updating_previous()); + ceph_assert(accepted.count(from) == 0); accepted.insert(from); dout(10) << " now " << accepted << " have accepted" << dendl; - assert(g_conf()->paxos_kill_at != 6); + ceph_assert(g_conf()->paxos_kill_at != 6); // only commit (and expose committed state) when we get *all* quorum // members to accept. otherwise, they may still be sharing the now @@ -808,8 +808,8 @@ void Paxos::accept_timeout() { dout(1) << "accept timeout, calling fresh election" << dendl; accept_timeout_event = 0; - assert(mon->is_leader()); - assert(is_updating() || is_updating_previous() || is_writing() || + ceph_assert(mon->is_leader()); + ceph_assert(is_updating() || is_updating_previous() || is_writing() || is_writing_previous()); logger->inc(l_paxos_accept_timeout); mon->bootstrap(); @@ -819,7 +819,7 @@ struct C_Committed : public Context { Paxos *paxos; explicit C_Committed(Paxos *p) : paxos(p) {} void finish(int r) override { - assert(r >= 0); + ceph_assert(r >= 0); Mutex::Locker l(paxos->mon->lock); if (paxos->is_shutdown()) { paxos->abort_commit(); @@ -831,7 +831,7 @@ struct C_Committed : public Context { void Paxos::abort_commit() { - assert(commits_started > 0); + ceph_assert(commits_started > 0); --commits_started; if (commits_started == 0) shutdown_cond.Signal(); @@ -841,7 +841,7 @@ void Paxos::commit_start() { dout(10) << __func__ << " " << (last_committed+1) << dendl; - assert(g_conf()->paxos_kill_at != 7); + ceph_assert(g_conf()->paxos_kill_at != 7); auto t(std::make_shared()); @@ -886,7 +886,7 @@ void Paxos::commit_finish() utime_t end = ceph_clock_now(); logger->tinc(l_paxos_commit_latency, end - commit_start_stamp); - assert(g_conf()->paxos_kill_at != 8); + ceph_assert(g_conf()->paxos_kill_at != 8); // cancel lease - it was for the old value. // (this would only happen if message layer lost the 'begin', but @@ -917,7 +917,7 @@ void Paxos::commit_finish() mon->send_mon_message(commit, *p); } - assert(g_conf()->paxos_kill_at != 9); + ceph_assert(g_conf()->paxos_kill_at != 9); // get ready for a new round. new_value.clear(); @@ -926,9 +926,9 @@ void Paxos::commit_finish() // among other things, this lets do_refresh() -> mon->bootstrap() -> // wait_for_paxos_write() know that it doesn't need to flush the store // queue. and it should not, as we are in the async completion thread now! - assert(is_writing() || is_writing_previous()); + ceph_assert(is_writing() || is_writing_previous()); state = STATE_REFRESH; - assert(commits_started > 0); + ceph_assert(commits_started > 0); --commits_started; if (do_refresh()) { @@ -937,7 +937,7 @@ void Paxos::commit_finish() extend_lease(); } - assert(g_conf()->paxos_kill_at != 10); + ceph_assert(g_conf()->paxos_kill_at != 10); finish_round(); } @@ -966,7 +966,7 @@ void Paxos::handle_commit(MonOpRequestRef op) void Paxos::extend_lease() { - assert(mon->is_leader()); + ceph_assert(mon->is_leader()); //assert(is_active()); lease_expire = ceph_clock_now(); @@ -1057,8 +1057,8 @@ bool Paxos::do_refresh() void Paxos::commit_proposal() { dout(10) << __func__ << dendl; - assert(mon->is_leader()); - assert(is_refresh()); + ceph_assert(mon->is_leader()); + ceph_assert(is_refresh()); finish_contexts(g_ceph_context, committing_finishers); } @@ -1066,7 +1066,7 @@ void Paxos::commit_proposal() void Paxos::finish_round() { dout(10) << __func__ << dendl; - assert(mon->is_leader()); + ceph_assert(mon->is_leader()); // ok, now go active! state = STATE_ACTIVE; @@ -1182,8 +1182,8 @@ void Paxos::handle_lease_ack(MonOpRequestRef op) void Paxos::lease_ack_timeout() { dout(1) << "lease_ack_timeout -- calling new election" << dendl; - assert(mon->is_leader()); - assert(is_active()); + ceph_assert(mon->is_leader()); + ceph_assert(is_active()); logger->inc(l_paxos_lease_ack_timeout); lease_ack_timeout_event = 0; mon->bootstrap(); @@ -1206,7 +1206,7 @@ void Paxos::reset_lease_timeout() void Paxos::lease_timeout() { dout(1) << "lease_timeout -- calling new election" << dendl; - assert(mon->is_peon()); + ceph_assert(mon->is_peon()); logger->inc(l_paxos_lease_timeout); lease_timeout_event = 0; mon->bootstrap(); @@ -1224,7 +1224,7 @@ void Paxos::lease_renew_timeout() */ void Paxos::trim() { - assert(should_trim()); + ceph_assert(should_trim()); version_t end = std::min(get_version() - g_conf()->paxos_min, get_first_committed() + g_conf()->paxos_trim_max); @@ -1410,7 +1410,7 @@ void Paxos::restart() void Paxos::dispatch(MonOpRequestRef op) { - assert(op->is_type_paxos()); + ceph_assert(op->is_type_paxos()); op->mark_paxos_event("dispatch"); PaxosServiceMessage *m = static_cast(op->get_req()); // election in progress? @@ -1420,7 +1420,7 @@ void Paxos::dispatch(MonOpRequestRef op) } // check sanity - assert(mon->is_leader() || + ceph_assert(mon->is_leader() || (mon->is_peon() && m->get_source().num() == mon->get_leader())); switch (m->get_type()) { @@ -1521,8 +1521,8 @@ bool Paxos::is_writeable() void Paxos::propose_pending() { - assert(is_active()); - assert(pending_proposal); + ceph_assert(is_active()); + ceph_assert(pending_proposal); cancel_events(); @@ -1547,16 +1547,16 @@ void Paxos::propose_pending() void Paxos::queue_pending_finisher(Context *onfinished) { dout(5) << __func__ << " " << onfinished << dendl; - assert(onfinished); + ceph_assert(onfinished); pending_finishers.push_back(onfinished); } MonitorDBStore::TransactionRef Paxos::get_pending_transaction() { - assert(mon->is_leader()); + ceph_assert(mon->is_leader()); if (!pending_proposal) { pending_proposal.reset(new MonitorDBStore::Transaction); - assert(pending_finishers.empty()); + ceph_assert(pending_finishers.empty()); } return pending_proposal; } diff --git a/src/mon/Paxos.h b/src/mon/Paxos.h index 01533fe45993a..ddb9fbbf02c7f 100644 --- a/src/mon/Paxos.h +++ b/src/mon/Paxos.h @@ -1206,11 +1206,11 @@ public: return plugged; } void plug() { - assert(plugged == false); + ceph_assert(plugged == false); plugged = true; } void unplug() { - assert(plugged == true); + ceph_assert(plugged == true); plugged = false; } @@ -1266,7 +1266,7 @@ public: * @param onreadable A callback */ void wait_for_readable(MonOpRequestRef op, Context *onreadable) { - assert(!is_readable()); + ceph_assert(!is_readable()); if (op) op->mark_event("paxos:wait_for_readable"); waiting_for_readable.push_back(onreadable); @@ -1308,7 +1308,7 @@ public: * @param c A callback */ void wait_for_writeable(MonOpRequestRef op, Context *c) { - assert(!is_writeable()); + ceph_assert(!is_writeable()); if (op) op->mark_event("paxos:wait_for_writeable"); waiting_for_writeable.push_back(c); diff --git a/src/mon/PaxosFSMap.h b/src/mon/PaxosFSMap.h index e1ee081424de6..0c8d5d75d7464 100644 --- a/src/mon/PaxosFSMap.h +++ b/src/mon/PaxosFSMap.h @@ -24,16 +24,16 @@ class PaxosFSMap { public: virtual ~PaxosFSMap() {} - const FSMap &get_pending_fsmap() const { assert(is_leader()); return pending_fsmap; } + const FSMap &get_pending_fsmap() const { ceph_assert(is_leader()); return pending_fsmap; } const FSMap &get_fsmap() const { return fsmap; } virtual bool is_leader() const = 0; protected: - FSMap &get_pending_fsmap_writeable() { assert(is_leader()); return pending_fsmap; } + FSMap &get_pending_fsmap_writeable() { ceph_assert(is_leader()); return pending_fsmap; } FSMap &create_pending() { - assert(is_leader()); + ceph_assert(is_leader()); pending_fsmap = fsmap; pending_fsmap.epoch++; return pending_fsmap; diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index 797d339acafa2..f4894b58bb26d 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -31,7 +31,7 @@ static ostream& _prefix(std::ostream *_dout, Monitor *mon, Paxos *paxos, string bool PaxosService::dispatch(MonOpRequestRef op) { - assert(op->is_type_service() || op->is_type_command()); + ceph_assert(op->is_type_service() || op->is_type_command()); PaxosServiceMessage *m = static_cast(op->get_req()); op->mark_event("psvc:dispatch"); @@ -124,7 +124,7 @@ bool PaxosService::dispatch(MonOpRequestRef op) } else if (r == -ECANCELED || r == -EAGAIN) { return; } else { - assert(0 == "bad return value for proposal_timer"); + ceph_assert(0 == "bad return value for proposal_timer"); } }); dout(10) << " setting proposal_timer " << do_propose @@ -185,10 +185,10 @@ bool PaxosService::should_propose(double& delay) void PaxosService::propose_pending() { dout(10) << __func__ << dendl; - assert(have_pending); - assert(!proposing); - assert(mon->is_leader()); - assert(is_active()); + ceph_assert(have_pending); + ceph_assert(!proposing); + ceph_assert(mon->is_leader()); + ceph_assert(is_active()); if (proposal_timer) { dout(10) << " canceling proposal_timer " << proposal_timer << dendl; @@ -240,7 +240,7 @@ void PaxosService::propose_pending() else if (r == -ECANCELED || r == -EAGAIN) return; else - assert(0 == "bad return value for C_Committed"); + ceph_assert(0 == "bad return value for C_Committed"); } }; paxos->queue_pending_finisher(new C_Committed(this)); @@ -409,7 +409,7 @@ void PaxosService::trim(MonitorDBStore::TransactionRef t, version_t from, version_t to) { dout(10) << __func__ << " from " << from << " to " << to << dendl; - assert(from != to); + ceph_assert(from != to); for (version_t v = from; v < to; ++v) { dout(20) << __func__ << " " << v << dendl; diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index bb5192c157f1a..07a51c8ebe6e2 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -120,7 +120,7 @@ public: else if (r == -ECANCELED) return; else - assert(0 == "bad C_RetryMessage return value"); + ceph_assert(0 == "bad C_RetryMessage return value"); } }; @@ -231,7 +231,7 @@ public: * request on hold, for instance. */ void request_proposal() { - assert(is_writeable()); + ceph_assert(is_writeable()); propose_pending(); } @@ -243,8 +243,8 @@ public: * set a flag stating we're waiting on a cross-proposal to be finished. */ void request_proposal(PaxosService *other) { - assert(other != NULL); - assert(other->is_writeable()); + ceph_assert(other != NULL); + ceph_assert(other->is_writeable()); other->request_proposal(); } diff --git a/src/mon/Session.h b/src/mon/Session.h index ca7013ebf4947..8bb4a1ce7927b 100644 --- a/src/mon/Session.h +++ b/src/mon/Session.h @@ -84,8 +84,8 @@ struct MonSession : public RefCountedObject { ~MonSession() override { //generic_dout(0) << "~MonSession " << this << dendl; // we should have been removed before we get destructed; see MonSessionMap::remove_session() - assert(!item.is_on_list()); - assert(sub_map.empty()); + ceph_assert(!item.is_on_list()); + ceph_assert(sub_map.empty()); delete auth_handler; } @@ -115,7 +115,7 @@ struct MonSessionMap { MonSessionMap() {} ~MonSessionMap() { while (!subs.empty()) { - assert(subs.begin()->second->empty()); + ceph_assert(subs.begin()->second->empty()); delete subs.begin()->second; subs.erase(subs.begin()); } @@ -126,7 +126,7 @@ struct MonSessionMap { } void remove_session(MonSession *s) { - assert(!s->closed); + ceph_assert(!s->closed); for (map::iterator p = s->sub_map.begin(); p != s->sub_map.end(); ++p) { p->second->type_item.remove_myself(); delete p->second; @@ -153,7 +153,7 @@ struct MonSessionMap { const entity_addrvec_t& av, Connection *c) { MonSession *s = new MonSession(n, av, c); - assert(s); + ceph_assert(s); sessions.push_back(&s->item); if (n.is_osd()) by_osd.insert(pair(n.num(), s)); diff --git a/src/mon/health_check.h b/src/mon/health_check.h index 71e301159c256..935432e36cea7 100644 --- a/src/mon/health_check.h +++ b/src/mon/health_check.h @@ -103,7 +103,7 @@ struct health_check_map_t { health_check_t& add(const std::string& code, health_status_t severity, const std::string& summary) { - assert(checks.count(code) == 0); + ceph_assert(checks.count(code) == 0); health_check_t& r = checks[code]; r.severity = severity; r.summary = summary; diff --git a/src/mon/mon_types.h b/src/mon/mon_types.h index 095e1874cdae1..bf0b99b73d300 100644 --- a/src/mon/mon_types.h +++ b/src/mon/mon_types.h @@ -73,9 +73,9 @@ struct FeatureMap { return; } auto p = m.find(type); - assert(p != m.end()); + ceph_assert(p != m.end()); auto q = p->second.find(features); - assert(q != p->second.end()); + ceph_assert(q != p->second.end()); if (--q->second == 0) { p->second.erase(q); if (p->second.empty()) { @@ -148,7 +148,7 @@ struct LevelDBStoreStats { {} void dump(Formatter *f) const { - assert(f != NULL); + ceph_assert(f != NULL); f->dump_int("bytes_total", bytes_total); f->dump_int("bytes_sst", bytes_sst); f->dump_int("bytes_log", bytes_log); @@ -197,7 +197,7 @@ struct DataStats { LevelDBStoreStats store_stats; void dump(Formatter *f) const { - assert(f != NULL); + ceph_assert(f != NULL); f->dump_int("kb_total", (fs_stats.byte_total/1024)); f->dump_int("kb_used", (fs_stats.byte_used/1024)); f->dump_int("kb_avail", (fs_stats.byte_avail/1024)); -- 2.39.5