diff options
author | Adam C. Emerson <aemerson@redhat.com> | 2018-08-23 17:17:26 +0200 |
---|---|---|
committer | Adam C. Emerson <aemerson@redhat.com> | 2018-08-27 15:09:01 +0200 |
commit | 851813d434da7a7fdcaba5e435253747cd8c4207 (patch) | |
tree | fcde4249a35c490dd0382b2ad54ea50c77393aaa /src | |
parent | include: Use ceph_assert for asserts (diff) | |
download | ceph-851813d434da7a7fdcaba5e435253747cd8c4207.tar.xz ceph-851813d434da7a7fdcaba5e435253747cd8c4207.zip |
common: Use ceph_assert for asserts
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
Diffstat (limited to 'src')
69 files changed, 408 insertions, 397 deletions
diff --git a/src/common/AsyncOpTracker.cc b/src/common/AsyncOpTracker.cc index 10a72d2b135..1223873b154 100644 --- a/src/common/AsyncOpTracker.cc +++ b/src/common/AsyncOpTracker.cc @@ -10,7 +10,7 @@ AsyncOpTracker::AsyncOpTracker() AsyncOpTracker::~AsyncOpTracker() { Mutex::Locker locker(m_lock); - assert(m_pending_ops == 0); + ceph_assert(m_pending_ops == 0); } void AsyncOpTracker::start_op() { @@ -22,7 +22,7 @@ void AsyncOpTracker::finish_op() { Context *on_finish = nullptr; { Mutex::Locker locker(m_lock); - assert(m_pending_ops > 0); + ceph_assert(m_pending_ops > 0); if (--m_pending_ops == 0) { std::swap(on_finish, m_on_finish); } @@ -36,7 +36,7 @@ void AsyncOpTracker::finish_op() { void AsyncOpTracker::wait_for_ops(Context *on_finish) { { Mutex::Locker locker(m_lock); - assert(m_on_finish == nullptr); + ceph_assert(m_on_finish == nullptr); if (m_pending_ops > 0) { m_on_finish = on_finish; return; diff --git a/src/common/AsyncReserver.h b/src/common/AsyncReserver.h index d5c7a852ddf..c88061e9647 100644 --- a/src/common/AsyncReserver.h +++ b/src/common/AsyncReserver.h @@ -60,9 +60,9 @@ class AsyncReserver { set<pair<unsigned,T>> preempt_by_prio; ///< in_progress that can be preempted void preempt_one() { - assert(!preempt_by_prio.empty()); + ceph_assert(!preempt_by_prio.empty()); auto q = in_progress.find(preempt_by_prio.begin()->second); - assert(q != in_progress.end()); + ceph_assert(q != in_progress.end()); Reservation victim = q->second; rdout(10) << __func__ << " preempt " << victim << dendl; f->queue(victim.preempt); @@ -91,7 +91,7 @@ class AsyncReserver { // choose highest priority queue auto it = queues.end(); --it; - assert(!it->second.empty()); + ceph_assert(!it->second.empty()); if (it->first < min_priority) { break; } @@ -186,7 +186,7 @@ public: Mutex::Locker l(lock); Reservation r(item, prio, on_reserved, on_preempt); rdout(10) << __func__ << " queue " << r << dendl; - assert(!queue_pointers.count(item) && + ceph_assert(!queue_pointers.count(item) && !in_progress.count(item)); queues[prio].push_back(r); queue_pointers.insert(make_pair(item, diff --git a/src/common/Checksummer.h b/src/common/Checksummer.h index c303ae2dd98..2137c1d6609 100644 --- a/src/common/Checksummer.h +++ b/src/common/Checksummer.h @@ -207,15 +207,15 @@ public: size_t length, const bufferlist &bl, bufferptr* csum_data) { - assert(length % csum_block_size == 0); + ceph_assert(length % csum_block_size == 0); size_t blocks = length / csum_block_size; bufferlist::const_iterator p = bl.begin(); - assert(bl.length() >= length); + ceph_assert(bl.length() >= length); typename Alg::state_t state; Alg::init(&state); - assert(csum_data->length() >= (offset + length) / csum_block_size * + ceph_assert(csum_data->length() >= (offset + length) / csum_block_size * sizeof(typename Alg::value_t)); typename Alg::value_t *pv = @@ -238,9 +238,9 @@ public: const bufferptr& csum_data, uint64_t *bad_csum=0 ) { - assert(length % csum_block_size == 0); + ceph_assert(length % csum_block_size == 0); bufferlist::const_iterator p = bl.begin(); - assert(bl.length() >= length); + ceph_assert(bl.length() >= length); typename Alg::state_t state; Alg::init(&state); diff --git a/src/common/CommandTable.h b/src/common/CommandTable.h index e952ebe2f27..ed34488d1df 100644 --- a/src/common/CommandTable.h +++ b/src/common/CommandTable.h @@ -63,7 +63,7 @@ public: ~CommandTable() { - assert(commands.empty()); + ceph_assert(commands.empty()); } T& start_command() diff --git a/src/common/Cond.h b/src/common/Cond.h index 00c6cdcce26..061370f1cf4 100644 --- a/src/common/Cond.h +++ b/src/common/Cond.h @@ -30,8 +30,8 @@ class Cond { public: Cond() : waiter_mutex(NULL) { - [[maybe_unused]] int r = pthread_cond_init(&_c,NULL); - assert(r == 0); + int r = pthread_cond_init(&_c,NULL); + ceph_assert(r == 0); } virtual ~Cond() { pthread_cond_destroy(&_c); @@ -39,10 +39,10 @@ class Cond { int Wait(Mutex &mutex) { // make sure this cond is used with one mutex only - assert(waiter_mutex == NULL || waiter_mutex == &mutex); + ceph_assert(waiter_mutex == NULL || waiter_mutex == &mutex); waiter_mutex = &mutex; - assert(mutex.is_locked()); + ceph_assert(mutex.is_locked()); mutex._pre_unlock(); int r = pthread_cond_wait(&_c, &mutex._m); @@ -52,10 +52,10 @@ class Cond { int WaitUntil(Mutex &mutex, utime_t when) { // make sure this cond is used with one mutex only - assert(waiter_mutex == NULL || waiter_mutex == &mutex); + ceph_assert(waiter_mutex == NULL || waiter_mutex == &mutex); waiter_mutex = &mutex; - assert(mutex.is_locked()); + ceph_assert(mutex.is_locked()); struct timespec ts; when.to_timespec(&ts); @@ -93,7 +93,7 @@ class Cond { } int Signal() { // make sure signaler is holding the waiter's lock. - assert(waiter_mutex == NULL || + ceph_assert(waiter_mutex == NULL || waiter_mutex->is_locked()); int r = pthread_cond_broadcast(&_c); @@ -101,7 +101,7 @@ class Cond { } int SignalOne() { // make sure signaler is holding the waiter's lock. - assert(waiter_mutex == NULL || + ceph_assert(waiter_mutex == NULL || waiter_mutex->is_locked()); int r = pthread_cond_signal(&_c); @@ -109,7 +109,7 @@ class Cond { } int SignalAll() { // make sure signaler is holding the waiter's lock. - assert(waiter_mutex == NULL || + ceph_assert(waiter_mutex == NULL || waiter_mutex->is_locked()); int r = pthread_cond_broadcast(&_c); diff --git a/src/common/ConfUtils.cc b/src/common/ConfUtils.cc index c40cdce61bf..7c8f1cc78b7 100644 --- a/src/common/ConfUtils.cc +++ b/src/common/ConfUtils.cc @@ -285,7 +285,7 @@ load_from_buffer(const char *buf, size_t sz, std::deque<std::string> *errors, section_iter_t::value_type vt("global", ConfSection()); pair < section_iter_t, bool > vr(sections.insert(vt)); - assert(vr.second); + ceph_assert(vr.second); section_iter_t cur_section = vr.first; std::string acc; @@ -589,6 +589,6 @@ process_line(int line_no, const char *line, std::deque<std::string> *errors) ceph_abort(); break; } - assert(c != '\0'); // We better not go past the end of the input string. + ceph_assert(c != '\0'); // We better not go past the end of the input string. } } diff --git a/src/common/Continuation.h b/src/common/Continuation.h index aa3e1ed5036..966b63d07ac 100644 --- a/src/common/Continuation.h +++ b/src/common/Continuation.h @@ -72,8 +72,8 @@ protected: * @param r The return code that will be provided to the next stage */ bool immediate(int stage, int r) { - assert(!stages_in_flight.count(stage)); - assert(!stages_processing.count(stage)); + ceph_assert(!stages_in_flight.count(stage)); + ceph_assert(!stages_processing.count(stage)); stages_in_flight.insert(stage); stages_processing.insert(stage); return _continue_function(r, stage); @@ -104,7 +104,7 @@ protected: * @param func The function to use */ void set_callback(int stage, stagePtr func) { - assert(callbacks.find(stage) == callbacks.end()); + ceph_assert(callbacks.find(stage) == callbacks.end()); callbacks[stage] = func; } @@ -123,8 +123,8 @@ private: bool _continue_function(int r, int n) { set<int>::iterator stage_iter = stages_in_flight.find(n); - assert(stage_iter != stages_in_flight.end()); - assert(callbacks.count(n)); + ceph_assert(stage_iter != stages_in_flight.end()); + ceph_assert(callbacks.count(n)); stagePtr p = callbacks[n]; pair<set<int>::iterator,bool> insert_r = stages_processing.insert(n); @@ -166,7 +166,7 @@ public: /** * Clean up. */ - virtual ~Continuation() { assert(on_finish == NULL); } + virtual ~Continuation() { ceph_assert(on_finish == NULL); } /** * Begin running the Continuation. */ diff --git a/src/common/Cycles.cc b/src/common/Cycles.cc index b1888d34cff..2d3e6ba7e78 100644 --- a/src/common/Cycles.cc +++ b/src/common/Cycles.cc @@ -67,12 +67,12 @@ void Cycles::init() old_cycles = 0; while (1) { if (gettimeofday(&start_time, NULL) != 0) { - assert(0 == "couldn't read clock"); + ceph_assert(0 == "couldn't read clock"); } uint64_t start_cycles = rdtsc(); while (1) { if (gettimeofday(&stop_time, NULL) != 0) { - assert(0 == "couldn't read clock"); + ceph_assert(0 == "couldn't read clock"); } uint64_t stop_cycles = rdtsc(); micros = (stop_time.tv_usec - start_time.tv_usec) + diff --git a/src/common/Finisher.h b/src/common/Finisher.h index af1f8266d38..d463680a8c8 100644 --- a/src/common/Finisher.h +++ b/src/common/Finisher.h @@ -167,8 +167,8 @@ class C_OnFinisher : public Context { Finisher *fin; public: C_OnFinisher(Context *c, Finisher *f) : con(c), fin(f) { - assert(fin != NULL); - assert(con != NULL); + ceph_assert(fin != NULL); + ceph_assert(con != NULL); } ~C_OnFinisher() override { diff --git a/src/common/Formatter.cc b/src/common/Formatter.cc index 2264c71171b..34c81317263 100644 --- a/src/common/Formatter.cc +++ b/src/common/Formatter.cc @@ -225,7 +225,7 @@ void JSONFormatter::open_object_section_in_ns(const char *name, const char *ns) void JSONFormatter::close_section() { - assert(!m_stack.empty()); + ceph_assert(!m_stack.empty()); finish_pending_string(); struct json_formatter_stack_entry_d& entry = m_stack.back(); @@ -391,7 +391,7 @@ void XMLFormatter::open_array_section_in_ns(const char *name, const char *ns) void XMLFormatter::close_section() { - assert(!m_sections.empty()); + ceph_assert(!m_sections.empty()); finish_pending_string(); std::string section = m_sections.back(); diff --git a/src/common/HeartbeatMap.cc b/src/common/HeartbeatMap.cc index cfd8779440a..a6ca11dee38 100644 --- a/src/common/HeartbeatMap.cc +++ b/src/common/HeartbeatMap.cc @@ -35,7 +35,7 @@ HeartbeatMap::HeartbeatMap(CephContext *cct) HeartbeatMap::~HeartbeatMap() { - assert(m_workers.empty()); + ceph_assert(m_workers.empty()); } heartbeat_handle_d *HeartbeatMap::add_worker(const string& name, pthread_t thread_id) @@ -79,7 +79,7 @@ bool HeartbeatMap::_check(const heartbeat_handle_d *h, const char *who, << " had suicide timed out after " << h->suicide_grace << dendl; pthread_kill(h->thread_id, SIGABRT); sleep(1); - assert(0 == "hit suicide timeout"); + ceph_assert(0 == "hit suicide timeout"); } return healthy; } diff --git a/src/common/LogClient.cc b/src/common/LogClient.cc index 8702d71f0e5..15f188590ca 100644 --- a/src/common/LogClient.cc +++ b/src/common/LogClient.cc @@ -268,7 +268,7 @@ bool LogClient::are_pending() Message *LogClient::_get_mon_log_message() { - assert(log_lock.is_locked()); + ceph_assert(log_lock.is_locked()); if (log_queue.empty()) return NULL; @@ -291,15 +291,15 @@ Message *LogClient::_get_mon_log_message() << " num " << log_queue.size() << " unsent " << num_unsent << " sending " << num_send << dendl; - assert(num_unsent <= log_queue.size()); + ceph_assert(num_unsent <= log_queue.size()); std::deque<LogEntry>::iterator p = log_queue.begin(); std::deque<LogEntry> o; while (p->seq <= last_log_sent) { ++p; - assert(p != log_queue.end()); + ceph_assert(p != log_queue.end()); } while (num_send--) { - assert(p != log_queue.end()); + ceph_assert(p != log_queue.end()); o.push_back(*p); last_log_sent = p->seq; ldout(cct,10) << " will send " << *p << dendl; @@ -314,9 +314,9 @@ Message *LogClient::_get_mon_log_message() void LogClient::_send_to_mon() { - assert(log_lock.is_locked()); - assert(is_mon); - assert(messenger->get_myname().is_mon()); + ceph_assert(log_lock.is_locked()); + ceph_assert(is_mon); + ceph_assert(messenger->get_myname().is_mon()); ldout(cct,10) << __func__ << " log to self" << dendl; Message *log = _get_mon_log_message(); messenger->get_loopback_connection()->send_message(log); diff --git a/src/common/Mutex.cc b/src/common/Mutex.cc index 1bb588902d0..4c449a06c4d 100644 --- a/src/common/Mutex.cc +++ b/src/common/Mutex.cc @@ -71,7 +71,7 @@ Mutex::Mutex(const std::string &n, bool r, bool ld, } Mutex::~Mutex() { - assert(nlock == 0); + ceph_assert(nlock == 0); // helgrind gets confused by condition wakeups leading to mutex destruction ANNOTATE_BENIGN_RACE_SIZED(&_m, sizeof(_m), "Mutex primitive"); @@ -107,7 +107,7 @@ void Mutex::Lock(bool no_lockdep) { r = pthread_mutex_lock(&_m); } - assert(r == 0); + ceph_assert(r == 0); if (lockdep && g_lockdep) _locked(); _post_lock(); @@ -119,5 +119,5 @@ void Mutex::Unlock() { _pre_unlock(); if (lockdep && g_lockdep) _will_unlock(); int r = pthread_mutex_unlock(&_m); - assert(r == 0); + ceph_assert(r == 0); } diff --git a/src/common/Mutex.h b/src/common/Mutex.h index b7ceb67a581..b02ac3e38ab 100644 --- a/src/common/Mutex.h +++ b/src/common/Mutex.h @@ -87,19 +87,19 @@ public: void _post_lock() { if (!recursive) { - assert(nlock == 0); + ceph_assert(nlock == 0); locked_by = pthread_self(); }; nlock++; } void _pre_unlock() { - assert(nlock > 0); + ceph_assert(nlock > 0); --nlock; if (!recursive) { - assert(locked_by == pthread_self()); + ceph_assert(locked_by == pthread_self()); locked_by = 0; - assert(nlock == 0); + ceph_assert(nlock == 0); } } void Unlock(); diff --git a/src/common/PluginRegistry.cc b/src/common/PluginRegistry.cc index bf63634e2fd..7faf0473be7 100644 --- a/src/common/PluginRegistry.cc +++ b/src/common/PluginRegistry.cc @@ -61,7 +61,7 @@ PluginRegistry::~PluginRegistry() int PluginRegistry::remove(const std::string& type, const std::string& name) { - assert(lock.is_locked()); + ceph_assert(lock.is_locked()); std::map<std::string,std::map<std::string,Plugin*> >::iterator i = plugins.find(type); @@ -86,7 +86,7 @@ int PluginRegistry::add(const std::string& type, const std::string& name, Plugin* plugin) { - assert(lock.is_locked()); + ceph_assert(lock.is_locked()); if (plugins.count(type) && plugins[type].count(name)) { return -EEXIST; @@ -113,7 +113,7 @@ Plugin *PluginRegistry::get_with_load(const std::string& type, Plugin *PluginRegistry::get(const std::string& type, const std::string& name) { - assert(lock.is_locked()); + ceph_assert(lock.is_locked()); Plugin *ret = 0; std::map<std::string,Plugin*>::iterator j; @@ -135,7 +135,7 @@ Plugin *PluginRegistry::get(const std::string& type, int PluginRegistry::load(const std::string &type, const std::string &name) { - assert(lock.is_locked()); + ceph_assert(lock.is_locked()); ldout(cct, 1) << __func__ << " " << type << " " << name << dendl; // std::string fname = cct->_conf->plugin_dir + "/" + type + "/" PLUGIN_PREFIX diff --git a/src/common/Preforker.h b/src/common/Preforker.h index 8925d944daa..f9e1de170f3 100644 --- a/src/common/Preforker.h +++ b/src/common/Preforker.h @@ -33,7 +33,7 @@ public: {} int prefork(std::string &err) { - assert(!forked); + ceph_assert(!forked); int r = ::socketpair(AF_UNIX, SOCK_STREAM, 0, fd); std::ostringstream oss; if (r < 0) { @@ -72,7 +72,7 @@ public: } int parent_wait(std::string &err_msg) { - assert(forked); + ceph_assert(forked); int r = -1; std::ostringstream oss; @@ -119,7 +119,7 @@ public: } void daemonize() { - assert(forked); + ceph_assert(forked); static int r = -1; int r2 = ::write(fd[1], &r, sizeof(r)); r += r2; // make the compiler shut up about the unused return code from ::write(2). diff --git a/src/common/PrioritizedQueue.h b/src/common/PrioritizedQueue.h index 8af40334b33..aade0b91b4f 100644 --- a/src/common/PrioritizedQueue.h +++ b/src/common/PrioritizedQueue.h @@ -15,6 +15,8 @@ #ifndef PRIORITY_QUEUE_H #define PRIORITY_QUEUE_H +#include "include/assert.h" + #include "common/Formatter.h" #include "common/OpQueue.h" @@ -99,13 +101,13 @@ class PrioritizedQueue : public OpQueue <T, K> { size++; } std::pair<unsigned, T> &front() const { - assert(!(q.empty())); - assert(cur != q.end()); + ceph_assert(!(q.empty())); + ceph_assert(cur != q.end()); return cur->second.front(); } T pop_front() { - assert(!(q.empty())); - assert(cur != q.end()); + ceph_assert(!(q.empty())); + ceph_assert(cur != q.end()); T ret = std::move(cur->second.front().second); cur->second.pop_front(); if (cur->second.empty()) { @@ -120,7 +122,7 @@ class PrioritizedQueue : public OpQueue <T, K> { return ret; } unsigned length() const { - assert(size >= 0); + ceph_assert(size >= 0); return (unsigned)size; } bool empty() const { @@ -176,10 +178,10 @@ class PrioritizedQueue : public OpQueue <T, K> { } void remove_queue(unsigned priority) { - assert(queue.count(priority)); + ceph_assert(queue.count(priority)); queue.erase(priority); total_priority -= priority; - assert(total_priority >= 0); + ceph_assert(total_priority >= 0); } void distribute_tokens(unsigned cost) { @@ -205,13 +207,13 @@ public: for (typename SubQueues::const_iterator i = queue.begin(); i != queue.end(); ++i) { - assert(i->second.length()); + ceph_assert(i->second.length()); total += i->second.length(); } for (typename SubQueues::const_iterator i = high_queue.begin(); i != high_queue.end(); ++i) { - assert(i->second.length()); + ceph_assert(i->second.length()); total += i->second.length(); } return total; @@ -267,13 +269,13 @@ public: } bool empty() const final { - assert(total_priority >= 0); - assert((total_priority == 0) || !(queue.empty())); + ceph_assert(total_priority >= 0); + ceph_assert((total_priority == 0) || !(queue.empty())); return queue.empty() && high_queue.empty(); } T dequeue() final { - assert(!empty()); + ceph_assert(!empty()); if (!(high_queue.empty())) { T ret = std::move(high_queue.rbegin()->second.front().second); @@ -290,7 +292,7 @@ public: for (typename SubQueues::iterator i = queue.begin(); i != queue.end(); ++i) { - assert(!(i->second.empty())); + ceph_assert(!(i->second.empty())); if (i->second.front().first < i->second.num_tokens()) { unsigned cost = i->second.front().first; i->second.take_tokens(cost); diff --git a/src/common/QueueRing.h b/src/common/QueueRing.h index 42582d24f44..8be2365ee50 100644 --- a/src/common/QueueRing.h +++ b/src/common/QueueRing.h @@ -34,7 +34,7 @@ class QueueRing { if (entries.empty()) { cond.Wait(lock); }; - assert(!entries.empty()); + ceph_assert(!entries.empty()); *entry = entries.front(); entries.pop_front(); lock.Unlock(); diff --git a/src/common/RWLock.h b/src/common/RWLock.h index da4baefb83d..8a5a0e82076 100644 --- a/src/common/RWLock.h +++ b/src/common/RWLock.h @@ -67,19 +67,19 @@ public: } bool is_locked() const { - assert(track); + ceph_assert(track); return (nrlock > 0) || (nwlock > 0); } bool is_wlocked() const { - assert(track); + ceph_assert(track); return (nwlock > 0); } ~RWLock() { // The following check is racy but we are about to destroy // the object and we assume that there are no other users. if (track) - assert(!is_locked()); + ceph_assert(!is_locked()); pthread_rwlock_destroy(&L); if (lockdep && g_lockdep) { lockdep_unregister(id); @@ -91,21 +91,21 @@ public: if (nwlock > 0) { nwlock--; } else { - assert(nrlock > 0); + ceph_assert(nrlock > 0); nrlock--; } } if (lockdep && this->lockdep && g_lockdep) id = lockdep_will_unlock(name.c_str(), id); int r = pthread_rwlock_unlock(&L); - assert(r == 0); + ceph_assert(r == 0); } // read void get_read() const { if (lockdep && g_lockdep) id = lockdep_will_lock(name.c_str(), id); int r = pthread_rwlock_rdlock(&L); - assert(r == 0); + ceph_assert(r == 0); if (lockdep && g_lockdep) id = lockdep_locked(name.c_str(), id); if (track) nrlock++; @@ -128,7 +128,7 @@ public: if (lockdep && this->lockdep && g_lockdep) id = lockdep_will_lock(name.c_str(), id); int r = pthread_rwlock_wrlock(&L); - assert(r == 0); + ceph_assert(r == 0); if (lockdep && this->lockdep && g_lockdep) id = lockdep_locked(name.c_str(), id); if (track) @@ -169,7 +169,7 @@ public: locked = true; } void unlock() { - assert(locked); + ceph_assert(locked); m_lock.unlock(); locked = false; } @@ -191,7 +191,7 @@ public: locked = true; } void unlock() { - assert(locked); + ceph_assert(locked); m_lock.unlock(); locked = false; } @@ -220,27 +220,27 @@ public: Context(RWLock& l, LockState s) : lock(l), state(s) {} void get_write() { - assert(state == Untaken); + ceph_assert(state == Untaken); lock.get_write(); state = TakenForWrite; } void get_read() { - assert(state == Untaken); + ceph_assert(state == Untaken); lock.get_read(); state = TakenForRead; } void unlock() { - assert(state != Untaken); + ceph_assert(state != Untaken); lock.unlock(); state = Untaken; } void promote() { - assert(state == TakenForRead); + ceph_assert(state == TakenForRead); unlock(); get_write(); } diff --git a/src/common/Readahead.cc b/src/common/Readahead.cc index 7246dec62ab..1b06c730dcc 100644 --- a/src/common/Readahead.cc +++ b/src/common/Readahead.cc @@ -97,12 +97,12 @@ Readahead::extent_t Readahead::_compute_readahead(uint64_t limit) { uint64_t dist_next = align_next - readahead_end; if (dist_prev < readahead_length / 2 && dist_prev < dist_next) { // we can snap to the previous alignment point by a less than 50% reduction in size - assert(align_prev > readahead_offset); + ceph_assert(align_prev > readahead_offset); readahead_length = align_prev - readahead_offset; break; } else if(dist_next < readahead_length / 2) { // we can snap to the next alignment point by a less than 50% increase in size - assert(align_next > readahead_offset); + ceph_assert(align_next > readahead_offset); readahead_length = align_next - readahead_offset; break; } @@ -121,16 +121,16 @@ Readahead::extent_t Readahead::_compute_readahead(uint64_t limit) { } void Readahead::inc_pending(int count) { - assert(count > 0); + ceph_assert(count > 0); m_pending_lock.Lock(); m_pending += count; m_pending_lock.Unlock(); } void Readahead::dec_pending(int count) { - assert(count > 0); + ceph_assert(count > 0); m_pending_lock.Lock(); - assert(m_pending >= count); + ceph_assert(m_pending >= count); m_pending -= count; if (m_pending == 0) { std::list<Context *> pending_waiting(std::move(m_pending_waiting)); diff --git a/src/common/RefCountedObj.h b/src/common/RefCountedObj.h index 325304c1441..510a6682f98 100644 --- a/src/common/RefCountedObj.h +++ b/src/common/RefCountedObj.h @@ -32,7 +32,7 @@ private: public: RefCountedObject(CephContext *c = NULL, int n=1) : nref(n), cct(c) {} virtual ~RefCountedObject() { - assert(nref == 0); + ceph_assert(nref == 0); } const RefCountedObject *get() const { diff --git a/src/common/SubProcess.cc b/src/common/SubProcess.cc index 30553d6b9e9..1190e6df70c 100644 --- a/src/common/SubProcess.cc +++ b/src/common/SubProcess.cc @@ -25,14 +25,14 @@ SubProcess::SubProcess(const char *cmd_, std_fd_op stdin_op_, std_fd_op stdout_o } SubProcess::~SubProcess() { - assert(!is_spawned()); - assert(stdin_pipe_out_fd == -1); - assert(stdout_pipe_in_fd == -1); - assert(stderr_pipe_in_fd == -1); + ceph_assert(!is_spawned()); + ceph_assert(stdin_pipe_out_fd == -1); + ceph_assert(stdout_pipe_in_fd == -1); + ceph_assert(stderr_pipe_in_fd == -1); } void SubProcess::add_cmd_args(const char *arg, ...) { - assert(!is_spawned()); + ceph_assert(!is_spawned()); va_list ap; va_start(ap, arg); @@ -45,28 +45,28 @@ void SubProcess::add_cmd_args(const char *arg, ...) { } void SubProcess::add_cmd_arg(const char *arg) { - assert(!is_spawned()); + ceph_assert(!is_spawned()); cmd_args.push_back(arg); } int SubProcess::get_stdin() const { - assert(is_spawned()); - assert(stdin_op == PIPE); + ceph_assert(is_spawned()); + ceph_assert(stdin_op == PIPE); return stdin_pipe_out_fd; } int SubProcess::get_stdout() const { - assert(is_spawned()); - assert(stdout_op == PIPE); + ceph_assert(is_spawned()); + ceph_assert(stdout_op == PIPE); return stdout_pipe_in_fd; } int SubProcess::get_stderr() const { - assert(is_spawned()); - assert(stderr_op == PIPE); + ceph_assert(is_spawned()); + ceph_assert(stderr_op == PIPE); return stderr_pipe_in_fd; } @@ -80,31 +80,31 @@ void SubProcess::close(int &fd) { } void SubProcess::close_stdin() { - assert(is_spawned()); - assert(stdin_op == PIPE); + ceph_assert(is_spawned()); + ceph_assert(stdin_op == PIPE); close(stdin_pipe_out_fd); } void SubProcess::close_stdout() { - assert(is_spawned()); - assert(stdout_op == PIPE); + ceph_assert(is_spawned()); + ceph_assert(stdout_op == PIPE); close(stdout_pipe_in_fd); } void SubProcess::close_stderr() { - assert(is_spawned()); - assert(stderr_op == PIPE); + ceph_assert(is_spawned()); + ceph_assert(stderr_op == PIPE); close(stderr_pipe_in_fd); } void SubProcess::kill(int signo) const { - assert(is_spawned()); + ceph_assert(is_spawned()); int ret = ::kill(pid, signo); - assert(ret == 0); + ceph_assert(ret == 0); } const std::string SubProcess::err() const { @@ -131,10 +131,10 @@ protected: }; int SubProcess::spawn() { - assert(!is_spawned()); - assert(stdin_pipe_out_fd == -1); - assert(stdout_pipe_in_fd == -1); - assert(stderr_pipe_in_fd == -1); + ceph_assert(!is_spawned()); + ceph_assert(stdin_pipe_out_fd == -1); + ceph_assert(stdout_pipe_in_fd == -1); + ceph_assert(stderr_pipe_in_fd == -1); enum { IN = 0, OUT = 1 }; @@ -215,7 +215,7 @@ fail: } void SubProcess::exec() { - assert(is_child()); + ceph_assert(is_child()); std::vector<const char *> args; args.push_back(cmd.c_str()); @@ -227,14 +227,14 @@ void SubProcess::exec() { args.push_back(NULL); int ret = execvp(cmd.c_str(), (char * const *)&args[0]); - assert(ret == -1); + ceph_assert(ret == -1); std::cerr << cmd << ": exec failed: " << cpp_strerror(errno) << "\n"; _exit(EXIT_FAILURE); } int SubProcess::join() { - assert(is_spawned()); + ceph_assert(is_spawned()); close(stdin_pipe_out_fd); close(stdout_pipe_in_fd); @@ -243,7 +243,7 @@ int SubProcess::join() { int status; while (waitpid(pid, &status, 0) == -1) - assert(errno == EINTR); + ceph_assert(errno == EINTR); pid = -1; @@ -275,7 +275,7 @@ void timeout_sighandler(int sig) { static void dummy_sighandler(int sig) {} void SubProcessTimed::exec() { - assert(is_child()); + ceph_assert(is_child()); if (timeout <= 0) { SubProcess::exec(); diff --git a/src/common/TextTable.h b/src/common/TextTable.h index 7fe3250603b..c60ba5f4490 100644 --- a/src/common/TextTable.h +++ b/src/common/TextTable.h @@ -108,7 +108,7 @@ public: } // inserting more items than defined columns is a coding error - assert(curcol + 1 <= col.size()); + ceph_assert(curcol + 1 <= col.size()); // get rendered width of item alone std::ostringstream oss; diff --git a/src/common/Thread.cc b/src/common/Thread.cc index 827443a13ee..f8362a9a8df 100644 --- a/src/common/Thread.cc +++ b/src/common/Thread.cc @@ -141,7 +141,7 @@ int Thread::try_create(size_t stacksize) void Thread::create(const char *name, size_t stacksize) { - assert(strlen(name) < 16); + ceph_assert(strlen(name) < 16); thread_name = name; int ret = try_create(stacksize); @@ -150,14 +150,14 @@ void Thread::create(const char *name, size_t stacksize) snprintf(buf, sizeof(buf), "Thread::try_create(): pthread_create " "failed with error %d", ret); dout_emergency(buf); - assert(ret == 0); + ceph_assert(ret == 0); } } int Thread::join(void **prval) { if (thread_id == 0) { - assert("join on thread that was never started" == 0); + ceph_assert("join on thread that was never started" == 0); return -EINVAL; } @@ -167,7 +167,7 @@ int Thread::join(void **prval) snprintf(buf, sizeof(buf), "Thread::join(): pthread_join " "failed with error %d\n", status); dout_emergency(buf); - assert(status == 0); + ceph_assert(status == 0); } thread_id = 0; diff --git a/src/common/Throttle.cc b/src/common/Throttle.cc index 877ace344f1..3186d8a22cb 100644 --- a/src/common/Throttle.cc +++ b/src/common/Throttle.cc @@ -41,7 +41,7 @@ Throttle::Throttle(CephContext *cct, const std::string& n, int64_t m, bool _use_perf) : cct(cct), name(n), max(m), use_perf(_use_perf) { - assert(m >= 0); + ceph_assert(m >= 0); if (!use_perf) return; @@ -70,7 +70,7 @@ Throttle::Throttle(CephContext *cct, const std::string& n, int64_t m, Throttle::~Throttle() { auto l = uniquely_lock(lock); - assert(conds.empty()); + ceph_assert(conds.empty()); } void Throttle::_reset_max(int64_t m) @@ -122,7 +122,7 @@ bool Throttle::wait(int64_t m) auto l = uniquely_lock(lock); if (m) { - assert(m > 0); + ceph_assert(m > 0); _reset_max(m); } ldout(cct, 10) << "wait" << dendl; @@ -134,7 +134,7 @@ int64_t Throttle::take(int64_t c) if (0 == max) { return 0; } - assert(c >= 0); + ceph_assert(c >= 0); ldout(cct, 10) << "take " << c << dendl; { auto l = uniquely_lock(lock); @@ -154,7 +154,7 @@ bool Throttle::get(int64_t c, int64_t m) return false; } - assert(c >= 0); + ceph_assert(c >= 0); ldout(cct, 10) << "get " << c << " (" << count.load() << " -> " << (count.load() + c) << ")" << dendl; if (logger) { logger->inc(l_throttle_get_started); @@ -163,7 +163,7 @@ bool Throttle::get(int64_t c, int64_t m) { auto l = uniquely_lock(lock); if (m) { - assert(m > 0); + ceph_assert(m > 0); _reset_max(m); } waited = _wait(c, l); @@ -214,7 +214,7 @@ int64_t Throttle::put(int64_t c) return 0; } - assert(c >= 0); + ceph_assert(c >= 0); ldout(cct, 10) << "put " << c << " (" << count.load() << " -> " << (count.load()-c) << ")" << dendl; auto l = uniquely_lock(lock); @@ -222,7 +222,7 @@ int64_t Throttle::put(int64_t c) if (!conds.empty()) conds.front().notify_one(); // if count goes negative, we failed somewhere! - assert(count >= c); + ceph_assert(count >= c); count -= c; if (logger) { logger->inc(l_throttle_put); @@ -289,7 +289,7 @@ BackoffThrottle::BackoffThrottle(CephContext *cct, const std::string& n, BackoffThrottle::~BackoffThrottle() { auto l = uniquely_lock(lock); - assert(waiters.empty()); + ceph_assert(waiters.empty()); } bool BackoffThrottle::set_params( @@ -456,7 +456,7 @@ std::chrono::duration<double> BackoffThrottle::get(uint64_t c) } else { break; } - assert(ticket == waiters.begin()); + ceph_assert(ticket == waiters.begin()); delay = _get_delay(c) - (std::chrono::system_clock::now() - start); } waiters.pop_front(); @@ -477,7 +477,7 @@ std::chrono::duration<double> BackoffThrottle::get(uint64_t c) uint64_t BackoffThrottle::put(uint64_t c) { locker l(lock); - assert(current >= c); + ceph_assert(current >= c); current -= c; _kick_waiters(); @@ -522,8 +522,8 @@ SimpleThrottle::SimpleThrottle(uint64_t max, bool ignore_enoent) SimpleThrottle::~SimpleThrottle() { auto l = uniquely_lock(m_lock); - assert(m_current == 0); - assert(waiters == 0); + ceph_assert(m_current == 0); + ceph_assert(waiters == 0); } void SimpleThrottle::start_op() @@ -568,11 +568,11 @@ OrderedThrottle::OrderedThrottle(uint64_t max, bool ignore_enoent) OrderedThrottle::~OrderedThrottle() { auto l = uniquely_lock(m_lock); - assert(waiters == 0); + ceph_assert(waiters == 0); } C_OrderedThrottle *OrderedThrottle::start_op(Context *on_finish) { - assert(on_finish); + ceph_assert(on_finish); auto l = uniquely_lock(m_lock); uint64_t tid = m_next_tid++; @@ -593,7 +593,7 @@ C_OrderedThrottle *OrderedThrottle::start_op(Context *on_finish) { void OrderedThrottle::end_op(int r) { auto l = uniquely_lock(m_lock); - assert(m_current > 0); + ceph_assert(m_current > 0); if (r < 0 && m_ret_val == 0 && (r != -ENOENT || !m_ignore_enoent)) { m_ret_val = r; @@ -606,7 +606,7 @@ void OrderedThrottle::finish_op(uint64_t tid, int r) { auto l = uniquely_lock(m_lock); auto it = m_tid_result.find(tid); - assert(it != m_tid_result.end()); + ceph_assert(it != m_tid_result.end()); it->second.finished = true; it->second.ret_val = r; diff --git a/src/common/Timer.cc b/src/common/Timer.cc index 45305f553fa..46061eb84df 100644 --- a/src/common/Timer.cc +++ b/src/common/Timer.cc @@ -47,7 +47,7 @@ SafeTimer::SafeTimer(CephContext *cct_, Mutex &l, bool safe_callbacks) SafeTimer::~SafeTimer() { - assert(thread == NULL); + ceph_assert(thread == NULL); } void SafeTimer::init() @@ -61,7 +61,7 @@ void SafeTimer::shutdown() { ldout(cct,10) << "shutdown" << dendl; if (thread) { - assert(lock.is_locked()); + ceph_assert(lock.is_locked()); cancel_all_events(); stopping = true; cond.Signal(); @@ -116,7 +116,7 @@ void SafeTimer::timer_thread() Context* SafeTimer::add_event_after(double seconds, Context *callback) { - assert(lock.is_locked()); + ceph_assert(lock.is_locked()); utime_t when = ceph_clock_now(); when += seconds; @@ -125,7 +125,7 @@ Context* SafeTimer::add_event_after(double seconds, Context *callback) Context* SafeTimer::add_event_at(utime_t when, Context *callback) { - assert(lock.is_locked()); + ceph_assert(lock.is_locked()); ldout(cct,10) << __func__ << " " << when << " -> " << callback << dendl; if (stopping) { ldout(cct,5) << __func__ << " already shutdown, event not added" << dendl; @@ -139,7 +139,7 @@ Context* SafeTimer::add_event_at(utime_t when, Context *callback) pair < event_lookup_map_t::iterator, bool > rval(events.insert(e_val)); /* If you hit this, you tried to insert the same Context* twice. */ - assert(rval.second); + ceph_assert(rval.second); /* If the event we have just inserted comes before everything else, we need to * adjust our timeout. */ @@ -150,7 +150,7 @@ Context* SafeTimer::add_event_at(utime_t when, Context *callback) bool SafeTimer::cancel_event(Context *callback) { - assert(lock.is_locked()); + ceph_assert(lock.is_locked()); auto p = events.find(callback); if (p == events.end()) { @@ -169,8 +169,8 @@ bool SafeTimer::cancel_event(Context *callback) void SafeTimer::cancel_all_events() { ldout(cct,10) << "cancel_all_events" << dendl; - assert(lock.is_locked()); - + ceph_assert(lock.is_locked()); + while (!events.empty()) { auto p = events.begin(); ldout(cct,10) << " cancelled " << p->second->first << " -> " << p->first << dendl; diff --git a/src/common/TracepointProvider.cc b/src/common/TracepointProvider.cc index be982b0bc2a..4c89038ced9 100644 --- a/src/common/TracepointProvider.cc +++ b/src/common/TracepointProvider.cc @@ -40,6 +40,6 @@ void TracepointProvider::verify_config(const ConfigProxy& conf) { } m_handle = dlopen(m_library.c_str(), RTLD_NOW | RTLD_NODELETE); - assert(m_handle); + ceph_assert(m_handle); } diff --git a/src/common/TrackedOp.cc b/src/common/TrackedOp.cc index 93df29736e1..22f4eed25a8 100644 --- a/src/common/TrackedOp.cc +++ b/src/common/TrackedOp.cc @@ -160,7 +160,7 @@ OpTracker::OpTracker(CephContext *cct_, bool tracking, uint32_t num_shards): OpTracker::~OpTracker() { while (!sharded_in_flight_list.empty()) { - assert((sharded_in_flight_list.back())->ops_in_flight_sharded.empty()); + ceph_assert((sharded_in_flight_list.back())->ops_in_flight_sharded.empty()); delete sharded_in_flight_list.back(); sharded_in_flight_list.pop_back(); } @@ -224,7 +224,7 @@ bool OpTracker::dump_ops_in_flight(Formatter *f, bool print_only_blocked, set<st utime_t now = ceph_clock_now(); for (uint32_t i = 0; i < num_optracker_shards; i++) { ShardedTrackingData* sdata = sharded_in_flight_list[i]; - assert(NULL != sdata); + ceph_assert(NULL != sdata); Mutex::Locker locker(sdata->ops_in_flight_lock_sharded); for (auto& op : sdata->ops_in_flight_sharded) { if (print_only_blocked && (now - op.get_initiated() <= complaint_time)) @@ -256,7 +256,7 @@ bool OpTracker::register_inflight_op(TrackedOp *i) uint64_t current_seq = ++seq; uint32_t shard_index = current_seq % num_optracker_shards; ShardedTrackingData* sdata = sharded_in_flight_list[shard_index]; - assert(NULL != sdata); + ceph_assert(NULL != sdata); { Mutex::Locker locker(sdata->ops_in_flight_lock_sharded); sdata->ops_in_flight_sharded.push_back(*i); @@ -268,11 +268,11 @@ bool OpTracker::register_inflight_op(TrackedOp *i) void OpTracker::unregister_inflight_op(TrackedOp* const i) { // caller checks; - assert(i->state); + ceph_assert(i->state); uint32_t shard_index = i->seq % num_optracker_shards; ShardedTrackingData* sdata = sharded_in_flight_list[shard_index]; - assert(NULL != sdata); + ceph_assert(NULL != sdata); { Mutex::Locker locker(sdata->ops_in_flight_lock_sharded); auto p = sdata->ops_in_flight_sharded.iterator_to(*i); @@ -298,7 +298,7 @@ bool OpTracker::visit_ops_in_flight(utime_t* oldest_secs, RWLock::RLocker l(lock); for (const auto sdata : sharded_in_flight_list) { - assert(sdata); + ceph_assert(sdata); Mutex::Locker locker(sdata->ops_in_flight_lock_sharded); if (!sdata->ops_in_flight_sharded.empty()) { utime_t oldest_op_tmp = @@ -321,7 +321,7 @@ bool OpTracker::visit_ops_in_flight(utime_t* oldest_secs, for (uint32_t iter = 0; iter < num_optracker_shards; iter++) { ShardedTrackingData* sdata = sharded_in_flight_list[iter]; - assert(NULL != sdata); + ceph_assert(NULL != sdata); Mutex::Locker locker(sdata->ops_in_flight_lock_sharded); for (auto& op : sdata->ops_in_flight_sharded) { if (!visit(op)) @@ -419,7 +419,7 @@ void OpTracker::get_age_ms_histogram(pow2_hist_t *h) for (uint32_t iter = 0; iter < num_optracker_shards; iter++) { ShardedTrackingData* sdata = sharded_in_flight_list[iter]; - assert(NULL != sdata); + ceph_assert(NULL != sdata); Mutex::Locker locker(sdata->ops_in_flight_lock_sharded); for (auto& i : sdata->ops_in_flight_sharded) { diff --git a/src/common/TrackedOp.h b/src/common/TrackedOp.h index a0790e48d98..704a92ee94f 100644 --- a/src/common/TrackedOp.h +++ b/src/common/TrackedOp.h @@ -71,9 +71,9 @@ public: opsvc.create("OpHistorySvc"); } ~OpHistory() { - assert(arrived.empty()); - assert(duration.empty()); - assert(slow_op.empty()); + ceph_assert(arrived.empty()); + ceph_assert(duration.empty()); + ceph_assert(slow_op.empty()); } void insert(const utime_t& now, TrackedOpRef op) { diff --git a/src/common/WeightedPriorityQueue.h b/src/common/WeightedPriorityQueue.h index c51a2b1f445..9ab8875ee24 100644 --- a/src/common/WeightedPriorityQueue.h +++ b/src/common/WeightedPriorityQueue.h @@ -21,6 +21,8 @@ #include <boost/intrusive/rbtree.hpp> #include <boost/intrusive/avl_set.hpp> +#include "include/assert.h" + namespace bi = boost::intrusive; template <typename T, typename S> @@ -84,11 +86,11 @@ class WeightedPriorityQueue : public OpQueue <T, K> } //Get the cost of the next item to dequeue unsigned get_cost() const { - assert(!empty()); + ceph_assert(!empty()); return lp.begin()->cost; } T pop() { - assert(!lp.empty()); + ceph_assert(!lp.empty()); T ret = std::move(lp.begin()->item); lp.erase_and_dispose(lp.begin(), DelItem<ListPair>()); return ret; @@ -151,7 +153,7 @@ class WeightedPriorityQueue : public OpQueue <T, K> ret.first->insert(cost, std::move(item), front); } unsigned get_cost() const { - assert(!empty()); + ceph_assert(!empty()); return next->get_cost(); } T pop() { @@ -312,7 +314,7 @@ class WeightedPriorityQueue : public OpQueue <T, K> normal.insert(p, cl, cost, std::move(item), true); } T dequeue() override { - assert(strict.size + normal.size > 0); + ceph_assert(strict.size + normal.size > 0); if (!strict.empty()) { return strict.pop(true); } diff --git a/src/common/WorkQueue.cc b/src/common/WorkQueue.cc index d4154c3afef..2e68c8d6fa5 100644 --- a/src/common/WorkQueue.cc +++ b/src/common/WorkQueue.cc @@ -58,7 +58,7 @@ void ThreadPool::TPHandle::reset_tp_timeout() ThreadPool::~ThreadPool() { - assert(_threads.empty()); + ceph_assert(_threads.empty()); delete[] _conf_keys; } @@ -68,7 +68,7 @@ void ThreadPool::handle_conf_change(const ConfigProxy& conf, if (changed.count(_thread_num_option)) { char *buf; int r = conf.get_val(_thread_num_option.c_str(), &buf, -1); - assert(r >= 0); + ceph_assert(r >= 0); int v = atoi(buf); free(buf); if (v >= 0) { @@ -151,7 +151,7 @@ void ThreadPool::worker(WorkThread *wt) void ThreadPool::start_threads() { - assert(_lock.is_locked()); + ceph_assert(_lock.is_locked()); while (_threads.size() < _num_threads) { WorkThread *wt = new WorkThread(this); ldout(cct, 10) << "start_threads creating and starting " << wt << dendl; @@ -168,7 +168,7 @@ void ThreadPool::start_threads() void ThreadPool::join_old_threads() { - assert(_lock.is_locked()); + ceph_assert(_lock.is_locked()); while (!_old_threads.empty()) { ldout(cct, 10) << "join_old_threads joining and deleting " << _old_threads.front() << dendl; _old_threads.front()->join(); @@ -244,7 +244,7 @@ void ThreadPool::unpause() { ldout(cct,10) << "unpause" << dendl; _lock.Lock(); - assert(_pause > 0); + ceph_assert(_pause > 0); _pause--; _cond.Signal(); _lock.Unlock(); @@ -293,7 +293,7 @@ ShardedThreadPool::ShardedThreadPool(CephContext *pcct_, string nm, string tn, void ShardedThreadPool::shardedthreadpool_worker(uint32_t thread_index) { - assert(wq != NULL); + ceph_assert(wq != NULL); ldout(cct,10) << "worker start" << dendl; std::stringstream ss; @@ -349,7 +349,7 @@ void ShardedThreadPool::shardedthreadpool_worker(uint32_t thread_index) void ShardedThreadPool::start_threads() { - assert(shardedpool_lock.is_locked()); + ceph_assert(shardedpool_lock.is_locked()); int32_t thread_index = 0; while (threads_shardedpool.size() < num_threads) { @@ -375,7 +375,7 @@ void ShardedThreadPool::stop() { ldout(cct,10) << "stop" << dendl; stop_threads = true; - assert(wq != NULL); + ceph_assert(wq != NULL); wq->return_waiting_threads(); for (vector<WorkThreadSharded*>::iterator p = threads_shardedpool.begin(); p != threads_shardedpool.end(); @@ -392,7 +392,7 @@ void ShardedThreadPool::pause() ldout(cct,10) << "pause" << dendl; shardedpool_lock.Lock(); pause_threads = true; - assert(wq != NULL); + ceph_assert(wq != NULL); wq->return_waiting_threads(); while (num_threads != num_paused){ wait_cond.Wait(shardedpool_lock); @@ -406,7 +406,7 @@ void ShardedThreadPool::pause_new() ldout(cct,10) << "pause_new" << dendl; shardedpool_lock.Lock(); pause_threads = true; - assert(wq != NULL); + ceph_assert(wq != NULL); wq->return_waiting_threads(); shardedpool_lock.Unlock(); ldout(cct,10) << "paused_new" << dendl; @@ -428,7 +428,7 @@ void ShardedThreadPool::drain() ldout(cct,10) << "drain" << dendl; shardedpool_lock.Lock(); drain_threads = true; - assert(wq != NULL); + ceph_assert(wq != NULL); wq->return_waiting_threads(); while (num_threads != num_drained) { wait_cond.Wait(shardedpool_lock); diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h index 9fbb9507275..a678f7150f4 100644 --- a/src/common/WorkQueue.h +++ b/src/common/WorkQueue.h @@ -202,7 +202,7 @@ public: } void _void_process(void *, TPHandle &handle) override { _lock.Lock(); - assert(!to_process.empty()); + ceph_assert(!to_process.empty()); U u = to_process.front(); to_process.pop_front(); _lock.Unlock(); @@ -216,7 +216,7 @@ public: void _void_process_finish(void *) override { _lock.Lock(); - assert(!to_finish.empty()); + ceph_assert(!to_finish.empty()); U u = to_finish.front(); to_finish.pop_front(); _lock.Unlock(); @@ -348,7 +348,7 @@ public: public: ~PointerWQ() override { m_pool->remove_work_queue(this); - assert(m_processing == 0); + ceph_assert(m_processing == 0); } void drain() { { @@ -378,15 +378,15 @@ public: m_pool->add_work_queue(this); } void _clear() override { - assert(m_pool->_lock.is_locked()); + ceph_assert(m_pool->_lock.is_locked()); m_items.clear(); } bool _empty() override { - assert(m_pool->_lock.is_locked()); + ceph_assert(m_pool->_lock.is_locked()); return m_items.empty(); } void *_void_dequeue() override { - assert(m_pool->_lock.is_locked()); + ceph_assert(m_pool->_lock.is_locked()); if (m_items.empty()) { return NULL; } @@ -400,8 +400,8 @@ public: process(reinterpret_cast<T *>(item)); } void _void_process_finish(void *item) override { - assert(m_pool->_lock.is_locked()); - assert(m_processing > 0); + ceph_assert(m_pool->_lock.is_locked()); + ceph_assert(m_processing > 0); --m_processing; } @@ -412,7 +412,7 @@ public: } T *front() { - assert(m_pool->_lock.is_locked()); + ceph_assert(m_pool->_lock.is_locked()); if (m_items.empty()) { return NULL; } @@ -482,7 +482,7 @@ public: i++; for (i++; i < work_queues.size(); i++) work_queues[i-1] = work_queues[i]; - assert(i == work_queues.size()); + ceph_assert(i == work_queues.size()); work_queues.resize(i-1); } @@ -551,7 +551,7 @@ public: return _queue.empty(); } GenContext<ThreadPool::TPHandle&> *_dequeue() override { - assert(!_queue.empty()); + ceph_assert(!_queue.empty()); GenContext<ThreadPool::TPHandle&> *c = _queue.front(); _queue.pop_front(); return c; diff --git a/src/common/assert.cc b/src/common/assert.cc index 1530a6cba18..623b3150b49 100644 --- a/src/common/assert.cc +++ b/src/common/assert.cc @@ -18,7 +18,7 @@ namespace ceph { static CephContext *g_assert_context = NULL; - /* If you register an assert context, assert() will try to lock the dout + /* If you register an assert context, ceph_assert() will try to lock the dout * stream of that context before starting an assert. This is nice because the * output looks better. Your assert will not be interleaved with other dout * statements. @@ -29,7 +29,7 @@ namespace ceph { */ void register_assert_context(CephContext *cct) { - assert(!g_assert_context); + ceph_assert(!g_assert_context); g_assert_context = cct; } @@ -51,7 +51,7 @@ namespace ceph { char buf[8096]; snprintf(buf, sizeof(buf), "%s: In function '%s' thread %llx time %s\n" - "%s: %d: FAILED assert(%s)\n", + "%s: %d: FAILED ceph_assert(%s)\n", file, func, (unsigned long long)pthread_self(), tss.str().c_str(), file, line, assertion); dout_emergency(buf); @@ -128,7 +128,7 @@ namespace ceph { BufAppender ba(buf, sizeof(buf)); BackTrace *bt = new BackTrace(1); ba.printf("%s: In function '%s' thread %llx time %s\n" - "%s: %d: FAILED assert(%s)\n", + "%s: %d: FAILED ceph_assert(%s)\n", file, func, (unsigned long long)pthread_self(), tss.str().c_str(), file, line, assertion); ba.printf("Assertion details: "); @@ -163,7 +163,7 @@ namespace ceph { { char buf[8096]; snprintf(buf, sizeof(buf), - "WARNING: assert(%s) at: %s: %d: %s()\n", + "WARNING: ceph_assert(%s) at: %s: %d: %s()\n", assertion, file, line, func); dout_emergency(buf); } diff --git a/src/common/async/detail/shared_mutex.h b/src/common/async/detail/shared_mutex.h index c44142d6610..100ec701909 100644 --- a/src/common/async/detail/shared_mutex.h +++ b/src/common/async/detail/shared_mutex.h @@ -22,6 +22,8 @@ #include <boost/intrusive_ptr.hpp> #include <boost/intrusive/list.hpp> +#include "include/assert.h" + #include "common/async/completion.h" namespace ceph::async::detail { @@ -110,9 +112,9 @@ class AsyncRequest : public LockRequest { inline SharedMutexImpl::~SharedMutexImpl() { - assert(state == Unlocked); - assert(shared_queue.empty()); - assert(exclusive_queue.empty()); + ceph_assert(state == Unlocked); + ceph_assert(shared_queue.empty()); + ceph_assert(exclusive_queue.empty()); } template <typename Mutex, typename CompletionToken> @@ -185,7 +187,7 @@ void SharedMutexImpl::unlock() RequestList granted; { std::lock_guard lock{mutex}; - assert(state == Exclusive); + ceph_assert(state == Exclusive); if (!exclusive_queue.empty()) { // grant next exclusive lock @@ -274,7 +276,7 @@ inline bool SharedMutexImpl::try_lock_shared() inline void SharedMutexImpl::unlock_shared() { std::lock_guard lock{mutex}; - assert(state != Unlocked && state <= MaxShared); + ceph_assert(state != Unlocked && state <= MaxShared); if (state == 1 && !exclusive_queue.empty()) { // grant next exclusive lock diff --git a/src/common/autovector.h b/src/common/autovector.h index 5fbaa8328d2..503e239ce77 100644 --- a/src/common/autovector.h +++ b/src/common/autovector.h @@ -13,6 +13,8 @@ #include <stdexcept> #include <vector> +#include "include/assert.h" + // A vector that leverages pre-allocated stack-based array to achieve better // performance for array with small amount of items. // @@ -97,7 +99,7 @@ class autovector { } difference_type operator-(const self_type& other) const { - assert(vect_ == other.vect_); + ceph_assert(vect_ == other.vect_); return index_ - other.index_; } @@ -117,51 +119,51 @@ class autovector { // -- Reference reference operator*() { - assert(vect_->size() >= index_); + ceph_assert(vect_->size() >= index_); return (*vect_)[index_]; } const_reference operator*() const { - assert(vect_->size() >= index_); + ceph_assert(vect_->size() >= index_); return (*vect_)[index_]; } pointer operator->() { - assert(vect_->size() >= index_); + ceph_assert(vect_->size() >= index_); return &(*vect_)[index_]; } const_pointer operator->() const { - assert(vect_->size() >= index_); + ceph_assert(vect_->size() >= index_); return &(*vect_)[index_]; } // -- Logical Operators bool operator==(const self_type& other) const { - assert(vect_ == other.vect_); + ceph_assert(vect_ == other.vect_); return index_ == other.index_; } bool operator!=(const self_type& other) const { return !(*this == other); } bool operator>(const self_type& other) const { - assert(vect_ == other.vect_); + ceph_assert(vect_ == other.vect_); return index_ > other.index_; } bool operator<(const self_type& other) const { - assert(vect_ == other.vect_); + ceph_assert(vect_ == other.vect_); return index_ < other.index_; } bool operator>=(const self_type& other) const { - assert(vect_ == other.vect_); + ceph_assert(vect_ == other.vect_); return index_ >= other.index_; } bool operator<=(const self_type& other) const { - assert(vect_ == other.vect_); + ceph_assert(vect_ == other.vect_); return index_ <= other.index_; } @@ -209,42 +211,42 @@ class autovector { bool empty() const { return size() == 0; } const_reference operator[](size_type n) const { - assert(n < size()); + ceph_assert(n < size()); return n < kSize ? values_[n] : vect_[n - kSize]; } reference operator[](size_type n) { - assert(n < size()); + ceph_assert(n < size()); return n < kSize ? values_[n] : vect_[n - kSize]; } const_reference at(size_type n) const { - assert(n < size()); + ceph_assert(n < size()); return (*this)[n]; } reference at(size_type n) { - assert(n < size()); + ceph_assert(n < size()); return (*this)[n]; } reference front() { - assert(!empty()); + ceph_assert(!empty()); return *begin(); } const_reference front() const { - assert(!empty()); + ceph_assert(!empty()); return *begin(); } reference back() { - assert(!empty()); + ceph_assert(!empty()); return *(end() - 1); } const_reference back() const { - assert(!empty()); + ceph_assert(!empty()); return *(end() - 1); } @@ -271,7 +273,7 @@ class autovector { } void pop_back() { - assert(!empty()); + ceph_assert(!empty()); if (!vect_.empty()) { vect_.pop_back(); } else { diff --git a/src/common/bit_str.cc b/src/common/bit_str.cc index e61e950de57..5f72d9983f7 100644 --- a/src/common/bit_str.cc +++ b/src/common/bit_str.cc @@ -37,7 +37,7 @@ static void _dump_bit_str( *out << "(" << r << ")"; } } else { - assert(f != NULL); + ceph_assert(f != NULL); if (dump_bit_val) { f->dump_stream("bit_flag") << func(r) << "(" << r << ")"; diff --git a/src/common/bit_vector.hpp b/src/common/bit_vector.hpp index 84fad5f916d..a07dc83b532 100644 --- a/src/common/bit_vector.hpp +++ b/src/common/bit_vector.hpp @@ -107,7 +107,7 @@ public: uint64_t index; compute_index(m_offset, &index, &m_shift); - assert(index == m_index || index == m_index + 1); + ceph_assert(index == m_index || index == m_index + 1); if (index > m_index) { m_index = index; ++m_data_iterator; @@ -304,8 +304,8 @@ uint64_t BitVector<_b>::get_header_length() const { template <uint8_t _b> void BitVector<_b>::encode_data(bufferlist& bl, uint64_t byte_offset, uint64_t byte_length) const { - assert(byte_offset % BLOCK_SIZE == 0); - assert(byte_offset + byte_length == m_data.length() || + ceph_assert(byte_offset % BLOCK_SIZE == 0); + ceph_assert(byte_offset + byte_length == m_data.length() || byte_length % BLOCK_SIZE == 0); uint64_t end_offset = byte_offset + byte_length; @@ -323,7 +323,7 @@ void BitVector<_b>::encode_data(bufferlist& bl, uint64_t byte_offset, template <uint8_t _b> void BitVector<_b>::decode_data(bufferlist::const_iterator& it, uint64_t byte_offset) { - assert(byte_offset % BLOCK_SIZE == 0); + ceph_assert(byte_offset % BLOCK_SIZE == 0); if (it.end()) { return; } @@ -359,7 +359,7 @@ void BitVector<_b>::decode_data(bufferlist::const_iterator& it, uint64_t byte_of tail.substr_of(m_data, end_offset, m_data.length() - end_offset); data.append(tail); } - assert(data.length() == m_data.length()); + ceph_assert(data.length() == m_data.length()); data.swap(m_data); } @@ -368,7 +368,7 @@ void BitVector<_b>::get_data_extents(uint64_t offset, uint64_t length, uint64_t *byte_offset, uint64_t *byte_length) const { // read BLOCK_SIZE-aligned chunks - assert(length > 0 && offset + length <= m_size); + ceph_assert(length > 0 && offset + length <= m_size); uint64_t shift; compute_index(offset, byte_offset, &shift); *byte_offset -= (*byte_offset % BLOCK_SIZE); @@ -376,7 +376,7 @@ void BitVector<_b>::get_data_extents(uint64_t offset, uint64_t length, uint64_t end_offset; compute_index(offset + length - 1, &end_offset, &shift); end_offset += (BLOCK_SIZE - (end_offset % BLOCK_SIZE)); - assert(*byte_offset <= end_offset); + ceph_assert(*byte_offset <= end_offset); *byte_length = end_offset - *byte_offset; if (*byte_offset + *byte_length > m_data.length()) { diff --git a/src/common/bloom_filter.hpp b/src/common/bloom_filter.hpp index 8b9e9a3b6f4..8484d4edbe8 100644 --- a/src/common/bloom_filter.hpp +++ b/src/common/bloom_filter.hpp @@ -75,7 +75,7 @@ public: target_element_count_(predicted_inserted_element_count), random_seed_((random_seed) ? random_seed : 0xA5A5A5A5) { - assert(false_positive_probability > 0.0); + ceph_assert(false_positive_probability > 0.0); find_optimal_parameters(predicted_inserted_element_count, false_positive_probability, &salt_count_, &table_size_); init(); @@ -156,7 +156,7 @@ public: * @param val integer value to insert */ inline void insert(uint32_t val) { - assert(bit_table_); + ceph_assert(bit_table_); std::size_t bit_index = 0; std::size_t bit = 0; for (std::size_t i = 0; i < salt_.size(); ++i) @@ -169,7 +169,7 @@ public: inline void insert(const unsigned char* key_begin, const std::size_t& length) { - assert(bit_table_); + ceph_assert(bit_table_); std::size_t bit_index = 0; std::size_t bit = 0; for (std::size_t i = 0; i < salt_.size(); ++i) diff --git a/src/common/bounded_key_counter.h b/src/common/bounded_key_counter.h index 0109a26ef1b..e146a31f876 100644 --- a/src/common/bounded_key_counter.h +++ b/src/common/bounded_key_counter.h @@ -158,7 +158,7 @@ class BoundedKeyCounter { sorted.assign(const_pointer_iterator{counters.cbegin()}, const_pointer_iterator{counters.cend()}); // entire range is unsorted - assert(sorted_position == sorted.begin()); + ceph_assert(sorted_position == sorted.begin()); } const size_t sorted_count = get_num_sorted(); diff --git a/src/common/buffer.cc b/src/common/buffer.cc index b9da5bf9c14..ebd3aae511e 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -18,6 +18,7 @@ #include <sys/uio.h> +#include "include/assert.h" #include "include/types.h" #include "include/buffer_raw.h" #include "include/compat.h" @@ -280,7 +281,7 @@ using namespace ceph; raw_posix_aligned(unsigned l, unsigned _align) : raw(l) { align = _align; - assert((align >= sizeof(void *)) && (align & (align - 1)) == 0); + ceph_assert((align >= sizeof(void *)) && (align & (align - 1)) == 0); #ifdef DARWIN data = (char *) valloc(len); #else @@ -323,7 +324,7 @@ using namespace ceph; //cout << "hack aligned " << (unsigned)data //<< " in raw " << (unsigned)realdata //<< " off " << off << std::endl; - assert(((unsigned)data & (align-1)) == 0); + ceph_assert(((unsigned)data & (align-1)) == 0); } ~raw_hack_aligned() { delete[] realdata; @@ -403,7 +404,7 @@ using namespace ceph; } int zero_copy_to_fd(int fd, loff_t *offset) override { - assert(!source_consumed); + ceph_assert(!source_consumed); int flags = SPLICE_F_NONBLOCK; ssize_t r = safe_splice_exact(pipefds[0], NULL, fd, offset, len, flags); if (r < 0) { @@ -465,8 +466,8 @@ using namespace ceph; int tmpfd[2]; int r; - assert(!source_consumed); - assert(fds[0] >= 0); + ceph_assert(!source_consumed); + ceph_assert(fds[0] >= 0); if (::pipe(tmpfd) == -1) { r = -errno; @@ -768,8 +769,8 @@ using namespace ceph; buffer::ptr::ptr(const ptr& p, unsigned o, unsigned l) : _raw(p._raw), _off(p._off + o), _len(l) { - assert(o+l <= p._len); - assert(_raw); + ceph_assert(o+l <= p._len); + ceph_assert(_raw); _raw->nref++; bdout << "ptr " << this << " get " << _raw << bendl; } @@ -877,25 +878,25 @@ using namespace ceph; } const char *buffer::ptr::c_str() const { - assert(_raw); + ceph_assert(_raw); if (buffer_track_c_str) buffer_c_str_accesses++; return _raw->get_data() + _off; } char *buffer::ptr::c_str() { - assert(_raw); + ceph_assert(_raw); if (buffer_track_c_str) buffer_c_str_accesses++; return _raw->get_data() + _off; } const char *buffer::ptr::end_c_str() const { - assert(_raw); + ceph_assert(_raw); if (buffer_track_c_str) buffer_c_str_accesses++; return _raw->get_data() + _off + _len; } char *buffer::ptr::end_c_str() { - assert(_raw); + ceph_assert(_raw); if (buffer_track_c_str) buffer_c_str_accesses++; return _raw->get_data() + _off + _len; @@ -910,23 +911,23 @@ using namespace ceph; } const char& buffer::ptr::operator[](unsigned n) const { - assert(_raw); - assert(n < _len); + ceph_assert(_raw); + ceph_assert(n < _len); return _raw->get_data()[_off + n]; } char& buffer::ptr::operator[](unsigned n) { - assert(_raw); - assert(n < _len); + ceph_assert(_raw); + ceph_assert(n < _len); return _raw->get_data()[_off + n]; } - const char *buffer::ptr::raw_c_str() const { assert(_raw); return _raw->data; } - unsigned buffer::ptr::raw_length() const { assert(_raw); return _raw->len; } - int buffer::ptr::raw_nref() const { assert(_raw); return _raw->nref; } + const char *buffer::ptr::raw_c_str() const { ceph_assert(_raw); return _raw->data; } + unsigned buffer::ptr::raw_length() const { ceph_assert(_raw); return _raw->len; } + int buffer::ptr::raw_nref() const { ceph_assert(_raw); return _raw->nref; } void buffer::ptr::copy_out(unsigned o, unsigned l, char *dest) const { - assert(_raw); + ceph_assert(_raw); if (o+l > _len) throw end_of_buffer(); char* src = _raw->data + _off + o; @@ -960,8 +961,8 @@ using namespace ceph; unsigned buffer::ptr::append(char c) { - assert(_raw); - assert(1 <= unused_tail_length()); + ceph_assert(_raw); + ceph_assert(1 <= unused_tail_length()); char* ptr = _raw->data + _off + _len; *ptr = c; _len++; @@ -970,8 +971,8 @@ using namespace ceph; unsigned buffer::ptr::append(const char *p, unsigned l) { - assert(_raw); - assert(l <= unused_tail_length()); + ceph_assert(_raw); + ceph_assert(l <= unused_tail_length()); char* c = _raw->data + _off + _len; maybe_inline_memcpy(c, p, l, 32); _len += l; @@ -980,8 +981,8 @@ using namespace ceph; unsigned buffer::ptr::append_zeros(unsigned l) { - assert(_raw); - assert(l <= unused_tail_length()); + ceph_assert(_raw); + ceph_assert(l <= unused_tail_length()); char* c = _raw->data + _off + _len; memset(c, 0, l); _len += l; @@ -995,9 +996,9 @@ using namespace ceph; void buffer::ptr::copy_in(unsigned o, unsigned l, const char *src, bool crc_reset) { - assert(_raw); - assert(o <= _len); - assert(o+l <= _len); + ceph_assert(_raw); + ceph_assert(o <= _len); + ceph_assert(o+l <= _len); char* dest = _raw->data + _off + o; if (crc_reset) _raw->invalidate_crc(); @@ -1023,7 +1024,7 @@ using namespace ceph; void buffer::ptr::zero(unsigned o, unsigned l, bool crc_reset) { - assert(o+l <= _len); + ceph_assert(o+l <= _len); if (crc_reset) _raw->invalidate_crc(); memset(c_str()+o, 0, l); @@ -1093,7 +1094,7 @@ using namespace ceph; off -= d; o += d; } else if (off > 0) { - assert(p != ls->begin()); + ceph_assert(p != ls->begin()); p--; p_off = p->length(); } else { @@ -1145,7 +1146,7 @@ using namespace ceph; while (len > 0) { if (p == ls->end()) throw end_of_buffer(); - assert(p->length() > 0); + ceph_assert(p->length() > 0); unsigned howmuch = p->length() - p_off; if (len < howmuch) howmuch = len; @@ -1171,7 +1172,7 @@ using namespace ceph; } if (p == ls->end()) throw end_of_buffer(); - assert(p->length() > 0); + ceph_assert(p->length() > 0); dest = create(len); copy(len, dest.c_str()); } @@ -1184,7 +1185,7 @@ using namespace ceph; } if (p == ls->end()) throw end_of_buffer(); - assert(p->length() > 0); + ceph_assert(p->length() > 0); unsigned howmuch = p->length() - p_off; if (howmuch < len) { dest = create(len); @@ -1242,7 +1243,7 @@ using namespace ceph; while (1) { if (p == ls->end()) return; - assert(p->length() > 0); + ceph_assert(p->length() > 0); unsigned howmuch = p->length() - p_off; const char *c_str = p->c_str(); @@ -1466,7 +1467,7 @@ using namespace ceph; ++b; } } - assert(b == other._buffers.end()); + ceph_assert(b == other._buffers.end()); return true; } @@ -1554,7 +1555,7 @@ using namespace ceph; void buffer::list::zero(unsigned o, unsigned l) { - assert(o+l <= _len); + ceph_assert(o+l <= _len); unsigned p = 0; for (std::list<ptr>::iterator it = _buffers.begin(); it != _buffers.end(); @@ -1857,7 +1858,7 @@ using namespace ceph; void buffer::list::append(const ptr& bp, unsigned off, unsigned len) { - assert(len+off <= bp.length()); + ceph_assert(len+off <= bp.length()); if (!_buffers.empty()) { ptr &l = _buffers.back(); if (l.get_raw() == bp.get_raw() && @@ -1995,7 +1996,7 @@ using namespace ceph; } while (curbuf != _buffers.end() && l > 0); - assert(l == 0); + ceph_assert(l == 0); tmp.rebuild(); _buffers.insert(curbuf, tmp._buffers.front()); @@ -2023,7 +2024,7 @@ using namespace ceph; off -= (*curbuf).length(); ++curbuf; } - assert(len == 0 || curbuf != other._buffers.end()); + ceph_assert(len == 0 || curbuf != other._buffers.end()); while (len > 0) { // partial? @@ -2054,13 +2055,13 @@ using namespace ceph; if (off >= length()) throw end_of_buffer(); - assert(len > 0); + ceph_assert(len > 0); //cout << "splice off " << off << " len " << len << " ... mylen = " << length() << std::endl; // skip off std::list<ptr>::iterator curbuf = _buffers.begin(); while (off > 0) { - assert(curbuf != _buffers.end()); + ceph_assert(curbuf != _buffers.end()); if (off >= (*curbuf).length()) { // skip this buffer //cout << "off = " << off << " skipping over " << *curbuf << std::endl; @@ -2147,7 +2148,7 @@ void buffer::list::decode_base64(buffer::list& e) hexdump(oss); throw buffer::malformed_input(oss.str().c_str()); } - assert(l <= (int)bp.length()); + ceph_assert(l <= (int)bp.length()); bp.set_length(l); push_back(std::move(bp)); } diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc index 513d92ee011..51d97e8199a 100644 --- a/src/common/ceph_context.cc +++ b/src/common/ceph_context.cc @@ -88,7 +88,7 @@ public: "dump_mempools", this, "get mempool stats"); - assert(r == 0); + ceph_assert(r == 0); } ~MempoolObs() override { cct->_conf.remove_observer(this); @@ -394,7 +394,7 @@ void CephContext::do_command(std::string_view command, const cmdmap_t& cmdmap, lgeneric_dout(this, 1) << "do_command '" << command << "' '" << ss.str() << dendl; if (command == "assert" && _conf->debug_asok_assert_abort) { - assert(0 == "assert"); + ceph_assert(0 == "assert"); } if (command == "abort" && _conf->debug_asok_assert_abort) { abort(); @@ -534,7 +534,7 @@ void CephContext::do_command(std::string_view command, const cmdmap_t& cmdmap, _log->reopen_log_file(); } else { - assert(0 == "registered under wrong command?"); + ceph_assert(0 == "registered under wrong command?"); } f->close_section(); } @@ -667,7 +667,7 @@ CephContext::~CephContext() delete _crypto_none; delete _crypto_aes; if (_crypto_inited > 0) { - assert(_crypto_inited == 1); // or else someone explicitly did + ceph_assert(_crypto_inited == 1); // or else someone explicitly did // init but not shutdown shutdown_crypto(); } @@ -774,7 +774,7 @@ void CephContext::enable_perf_counter() PerfCounters *perf_tmp = plb.create_perf_counters(); std::unique_lock<ceph::spinlock> lg(_cct_perf_lock); - assert(_cct_perf == NULL); + ceph_assert(_cct_perf == NULL); _cct_perf = perf_tmp; lg.unlock(); diff --git a/src/common/ceph_crypto.cc b/src/common/ceph_crypto.cc index 055b57c3373..38b47826e7a 100644 --- a/src/common/ceph_crypto.cc +++ b/src/common/ceph_crypto.cc @@ -51,13 +51,13 @@ void ceph::crypto::init(CephContext *cct) SECMOD_DB, &init_params, flags); } pthread_mutex_unlock(&crypto_init_mutex); - assert(crypto_context != NULL); + ceph_assert(crypto_context != NULL); } void ceph::crypto::shutdown(bool shared) { pthread_mutex_lock(&crypto_init_mutex); - assert(crypto_refs > 0); + ceph_assert(crypto_refs > 0); if (--crypto_refs == 0) { NSS_ShutdownContext(crypto_context); if (!shared) { diff --git a/src/common/ceph_timer.h b/src/common/ceph_timer.h index 4b7438672d4..bca800b88e4 100644 --- a/src/common/ceph_timer.h +++ b/src/common/ceph_timer.h @@ -188,7 +188,7 @@ namespace ceph { return; suspended = false; - assert(!thread.joinable()); + ceph_assert(!thread.joinable()); thread = std::thread(&timer::timer_thread, this); } diff --git a/src/common/cmdparse.cc b/src/common/cmdparse.cc index 57502a25482..241aa3fa9ea 100644 --- a/src/common/cmdparse.cc +++ b/src/common/cmdparse.cc @@ -135,7 +135,7 @@ dump_cmddesc_to_json(Formatter *jf, void cmdmap_dump(const cmdmap_t &cmdmap, Formatter *f) { - assert(f != nullptr); + ceph_assert(f != nullptr); class dump_visitor : public boost::static_visitor<void> { @@ -458,7 +458,7 @@ bool validate_str_arg(std::string_view value, } } else if (type == "CephChoices") { auto choices = desc.find("strings"); - assert(choices != end(desc)); + ceph_assert(choices != end(desc)); auto strings = choices->second; if (find_first_in(strings, "|", [=](auto choice) { return (value == choice); @@ -527,8 +527,8 @@ bool validate_cmd(CephContext* cct, if (arg_desc.empty()) { return false; } - assert(arg_desc.count("name")); - assert(arg_desc.count("type")); + ceph_assert(arg_desc.count("name")); + ceph_assert(arg_desc.count("type")); auto name = arg_desc["name"]; auto type = arg_desc["type"]; if (arg_desc.count("n")) { diff --git a/src/common/cohort_lru.h b/src/common/cohort_lru.h index edd3e38828a..db28a582779 100644 --- a/src/common/cohort_lru.h +++ b/src/common/cohort_lru.h @@ -149,8 +149,8 @@ namespace cohort { --(o->lru_refcnt); /* assertions that o state has not changed across * relock */ - assert(o->lru_refcnt == SENTINEL_REFCNT); - assert(o->lru_flags & FLAG_INLRU); + ceph_assert(o->lru_refcnt == SENTINEL_REFCNT); + ceph_assert(o->lru_flags & FLAG_INLRU); Object::Queue::iterator it = Object::Queue::s_iterator_to(*o); lane.q.erase(it); @@ -173,7 +173,7 @@ namespace cohort { LRU(int lanes, uint32_t _hiwat) : n_lanes(lanes), evict_lane(0), lane_hiwat(_hiwat) { - assert(n_lanes > 0); + ceph_assert(n_lanes > 0); qlane = new Lane[n_lanes]; } @@ -336,7 +336,7 @@ namespace cohort { } TreeX(int n_part=1, int csz=127) : n_part(n_part), csz(csz) { - assert(n_part > 0); + ceph_assert(n_part > 0); part = new Partition[n_part]; for (int ix = 0; ix < n_part; ++ix) { Partition& p = part[ix]; diff --git a/src/common/condition_variable_debug.cc b/src/common/condition_variable_debug.cc index ed459ea18cc..ae5b7d25134 100644 --- a/src/common/condition_variable_debug.cc +++ b/src/common/condition_variable_debug.cc @@ -20,10 +20,10 @@ condition_variable_debug::~condition_variable_debug() void condition_variable_debug::wait(std::unique_lock<mutex_debug>& lock) { // make sure this cond is used with one mutex only - assert(waiter_mutex == nullptr || + ceph_assert(waiter_mutex == nullptr || waiter_mutex == lock.mutex()); waiter_mutex = lock.mutex(); - assert(waiter_mutex->is_locked()); + ceph_assert(waiter_mutex->is_locked()); waiter_mutex->_pre_unlock(); if (int r = pthread_cond_wait(&cond, waiter_mutex->native_handle()); r != 0) { @@ -35,7 +35,7 @@ void condition_variable_debug::wait(std::unique_lock<mutex_debug>& lock) void condition_variable_debug::notify_one() { // make sure signaler is holding the waiter's lock. - assert(waiter_mutex == nullptr || + ceph_assert(waiter_mutex == nullptr || waiter_mutex->is_locked()); if (int r = pthread_cond_signal(&cond); r != 0) { throw std::system_error(r, std::generic_category()); @@ -45,7 +45,7 @@ void condition_variable_debug::notify_one() void condition_variable_debug::notify_all(bool sloppy) { // make sure signaler is holding the waiter's lock. - assert(waiter_mutex == NULL || + ceph_assert(waiter_mutex == NULL || waiter_mutex->is_locked()); if (int r = pthread_cond_broadcast(&cond); r != 0 && !sloppy) { throw std::system_error(r, std::generic_category()); @@ -56,10 +56,10 @@ std::cv_status condition_variable_debug::_wait_until(mutex_debug* mutex, timespec* ts) { // make sure this cond is used with one mutex only - assert(waiter_mutex == nullptr || + ceph_assert(waiter_mutex == nullptr || waiter_mutex == mutex); waiter_mutex = mutex; - assert(waiter_mutex->is_locked()); + ceph_assert(waiter_mutex->is_locked()); waiter_mutex->_pre_unlock(); int r = pthread_cond_timedwait(&cond, waiter_mutex->native_handle(), ts); diff --git a/src/common/config.cc b/src/common/config.cc index 0b9d35ff2f4..f11412f0cf6 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -256,10 +256,10 @@ void md_config_t::set_val_default(ConfigValues& values, const string& name, const std::string& val) { const Option *o = find_option(name); - assert(o); + ceph_assert(o); string err; int r = _set_val(values, tracker, val, *o, CONF_DEFAULT, &err); - assert(r >= 0); + ceph_assert(r >= 0); } int md_config_t::set_mon_vals(CephContext *cct, @@ -469,7 +469,7 @@ void md_config_t::parse_env(ConfigValues& values, for (auto name : { "erasure_code_dir", "plugin_dir", "osd_class_dir" }) { std::string err; const Option *o = find_option(name); - assert(o); + ceph_assert(o); _set_val(values, tracker, dir, *o, CONF_ENV, &err); } } @@ -694,7 +694,7 @@ int md_config_t::parse_option(ConfigValues& values, } if (ret < 0 || !error_message.empty()) { - assert(!option_name.empty()); + ceph_assert(!option_name.empty()); if (oss) { *oss << "Parse error setting " << option_name << " to '" << val << "' using injectargs"; @@ -786,7 +786,7 @@ void md_config_t::set_val_or_die(ConfigValues& values, if (ret != 0) { std::cerr << "set_val_or_die(" << key << "): " << err.str(); } - assert(ret == 0); + ceph_assert(ret == 0); } int md_config_t::set_val(ConfigValues& values, @@ -1044,7 +1044,7 @@ Option::value_t md_config_t::_expand_meta( string out; decltype(pos) last_pos = 0; while (pos != std::string::npos) { - assert((*str)[pos] == '$'); + ceph_assert((*str)[pos] == '$'); if (pos > last_pos) { out += str->substr(last_pos, pos - last_pos); } diff --git a/src/common/config_obs_mgr.h b/src/common/config_obs_mgr.h index 170b4d63bd8..5240764524a 100644 --- a/src/common/config_obs_mgr.h +++ b/src/common/config_obs_mgr.h @@ -76,7 +76,7 @@ void ObserverMgr<ConfigObs>::remove_observer(ConfigObs* observer) ++o; } } - assert(found_obs); + ceph_assert(found_obs); } template<class ConfigObs> diff --git a/src/common/dout.h b/src/common/dout.h index 2085b56f0ae..0c2069bf340 100644 --- a/src/common/dout.h +++ b/src/common/dout.h @@ -32,7 +32,7 @@ extern void dout_emergency(const std::string &str); class _bad_endl_use_dendl_t { public: _bad_endl_use_dendl_t(int) {} }; static const _bad_endl_use_dendl_t endl = 0; inline std::ostream& operator<<(std::ostream& out, _bad_endl_use_dendl_t) { - assert(0 && "you are using the wrong endl.. use std::endl or dendl"); + ceph_assert(0 && "you are using the wrong endl.. use std::endl or dendl"); return out; } diff --git a/src/common/fork_function.h b/src/common/fork_function.h index defea924121..137d9e6373d 100644 --- a/src/common/fork_function.h +++ b/src/common/fork_function.h @@ -10,6 +10,8 @@ #include <sys/wait.h> #include <sys/types.h> #include <ostream> + +#include "include/assert.h" #include "common/errno.h" static void _fork_function_dummy_sighandler(int sig) {} @@ -29,7 +31,7 @@ static inline int fork_function( // just wait int status; while (waitpid(forker_pid, &status, 0) == -1) { - assert(errno == EINTR); + ceph_assert(errno == EINTR); } if (WIFSIGNALED(status)) { errstr << ": got signal: " << WTERMSIG(status) << "\n"; diff --git a/src/common/fs_types.cc b/src/common/fs_types.cc index b62d6b0c45a..6ad4b24c312 100644 --- a/src/common/fs_types.cc +++ b/src/common/fs_types.cc @@ -73,7 +73,7 @@ void file_layout_t::encode(bufferlist& bl, uint64_t features) const using ceph::encode; if ((features & CEPH_FEATURE_FS_FILE_LAYOUT_V2) == 0) { ceph_file_layout fl; - assert((stripe_unit & 0xff) == 0); // first byte must be 0 + ceph_assert((stripe_unit & 0xff) == 0); // first byte must be 0 to_legacy(&fl); encode(fl, bl); return; diff --git a/src/common/hobject.cc b/src/common/hobject.cc index 0474cc20a46..e5da4a35d86 100644 --- a/src/common/hobject.cc +++ b/src/common/hobject.cc @@ -111,7 +111,7 @@ void hobject_t::encode(bufferlist& bl) const encode(max, bl); encode(nspace, bl); encode(pool, bl); - assert(!max || (*this == hobject_t(hobject_t::get_max()))); + ceph_assert(!max || (*this == hobject_t(hobject_t::get_max()))); ENCODE_FINISH(bl); } @@ -140,7 +140,7 @@ void hobject_t::decode(bufferlist::const_iterator& bl) !max && oid.name.empty()) { pool = INT64_MIN; - assert(is_min()); + ceph_assert(is_min()); } // for compatibility with some earlier verisons which might encoded @@ -440,7 +440,7 @@ void ghobject_t::decode(bufferlist::const_iterator& bl) !hobj.max && hobj.oid.name.empty()) { hobj.pool = INT64_MIN; - assert(hobj.is_min()); + ceph_assert(hobj.is_min()); } } if (struct_v >= 5) { diff --git a/src/common/hobject.h b/src/common/hobject.h index 59a3109f440..b9f277bc8ef 100644 --- a/src/common/hobject.h +++ b/src/common/hobject.h @@ -187,7 +187,7 @@ public: } bool is_max() const { - assert(!max || (*this == hobject_t(hobject_t::get_max()))); + ceph_assert(!max || (*this == hobject_t(hobject_t::get_max()))); return max; } bool is_min() const { @@ -219,7 +219,7 @@ public: // filestore nibble-based key uint32_t get_nibblewise_key_u32() const { - assert(!max); + ceph_assert(!max); return nibblewise_key_cache; } uint64_t get_nibblewise_key() const { @@ -228,7 +228,7 @@ public: // newer bit-reversed key uint32_t get_bitwise_key_u32() const { - assert(!max); + ceph_assert(!max); return hash_reverse_bits; } uint64_t get_bitwise_key() const { diff --git a/src/common/interval_map.h b/src/common/interval_map.h index 5357dff9fee..320c8843732 100644 --- a/src/common/interval_map.h +++ b/src/common/interval_map.h @@ -77,7 +77,7 @@ class interval_map { std::make_pair( off, std::make_pair(len, std::move(n)))); - assert(p.second); + ceph_assert(p.second); niter = p.first; } } @@ -97,7 +97,7 @@ class interval_map { std::make_pair( off, std::make_pair(len, std::move(n)))); - assert(p.second); + ceph_assert(p.second); } } public: @@ -158,11 +158,11 @@ public: m.insert(to_insert.begin(), to_insert.end()); } void insert(K off, K len, V &&v) { - assert(len > 0); - assert(len == s.length(v)); + ceph_assert(len > 0); + ceph_assert(len == s.length(v)); erase(off, len); auto p = m.insert(make_pair(off, std::make_pair(len, std::forward<V>(v)))); - assert(p.second); + ceph_assert(p.second); try_merge(p.first); } void insert(interval_map &&other) { @@ -173,11 +173,11 @@ public: } } void insert(K off, K len, const V &v) { - assert(len > 0); - assert(len == s.length(v)); + ceph_assert(len > 0); + ceph_assert(len == s.length(v)); erase(off, len); auto p = m.insert(make_pair(off, std::make_pair(len, v))); - assert(p.second); + ceph_assert(p.second); try_merge(p.first); } void insert(const interval_map &other) { diff --git a/src/common/lockdep.cc b/src/common/lockdep.cc index cf0aba6dd4f..8abcbc8e55b 100644 --- a/src/common/lockdep.cc +++ b/src/common/lockdep.cc @@ -373,7 +373,7 @@ int lockdep_will_unlock(const char *name, int id) if (id < 0) { //id = lockdep_register(name); - assert(id == -1); + ceph_assert(id == -1); return id; } diff --git a/src/common/lru_map.h b/src/common/lru_map.h index 35722fcd08a..7dac49b4587 100644 --- a/src/common/lru_map.h +++ b/src/common/lru_map.h @@ -102,7 +102,7 @@ void lru_map<K, V>::_add(const K& key, V& value) while (entries.size() > max) { typename std::list<K>::reverse_iterator riter = entries_lru.rbegin(); iter = entries.find(*riter); - // assert(iter != entries.end()); + // ceph_assert(iter != entries.end()); entries.erase(iter); entries_lru.pop_back(); } diff --git a/src/common/mClockPriorityQueue.h b/src/common/mClockPriorityQueue.h index 169fd08afd3..1e07ba92d4a 100644 --- a/src/common/mClockPriorityQueue.h +++ b/src/common/mClockPriorityQueue.h @@ -128,20 +128,20 @@ namespace ceph { } const std::pair<cost_t, T>& front() const { - assert(!(q.empty())); - assert(cur != q.end()); + ceph_assert(!(q.empty())); + ceph_assert(cur != q.end()); return cur->second.front(); } std::pair<cost_t, T>& front() { - assert(!(q.empty())); - assert(cur != q.end()); + ceph_assert(!(q.empty())); + ceph_assert(cur != q.end()); return cur->second.front(); } void pop_front() { - assert(!(q.empty())); - assert(cur != q.end()); + ceph_assert(!(q.empty())); + ceph_assert(cur != q.end()); cur->second.pop_front(); if (cur->second.empty()) { auto i = cur; @@ -157,7 +157,7 @@ namespace ceph { } unsigned length() const { - assert(size >= 0); + ceph_assert(size >= 0); return (unsigned)size; } @@ -234,7 +234,7 @@ namespace ceph { total += queue_front.size(); total += queue.request_count(); for (auto i = high_queue.cbegin(); i != high_queue.cend(); ++i) { - assert(i->second.length()); + ceph_assert(i->second.length()); total += i->second.length(); } return total; @@ -323,7 +323,7 @@ namespace ceph { } T dequeue() override final { - assert(!empty()); + ceph_assert(!empty()); if (!high_queue.empty()) { T ret = std::move(high_queue.rbegin()->second.front().second); @@ -341,7 +341,7 @@ namespace ceph { } auto pr = queue.pull_request(); - assert(pr.is_retn()); + ceph_assert(pr.is_retn()); auto& retn = pr.get_retn(); return std::move(*(retn.request)); } diff --git a/src/common/mempool.cc b/src/common/mempool.cc index a05d72a4b30..cb9de40da09 100644 --- a/src/common/mempool.cc +++ b/src/common/mempool.cc @@ -70,7 +70,7 @@ size_t mempool::pool_t::allocated_bytes() const for (size_t i = 0; i < num_shards; ++i) { result += shard[i].bytes; } - assert(result >= 0); + ceph_assert(result >= 0); return (size_t) result; } @@ -80,7 +80,7 @@ size_t mempool::pool_t::allocated_items() const for (size_t i = 0; i < num_shards; ++i) { result += shard[i].items; } - assert(result >= 0); + ceph_assert(result >= 0); return (size_t) result; } diff --git a/src/common/mutex_debug.cc b/src/common/mutex_debug.cc index 49cc82b29ab..0024a25ae34 100644 --- a/src/common/mutex_debug.cc +++ b/src/common/mutex_debug.cc @@ -50,7 +50,7 @@ mutex_debugging_base::mutex_debugging_base(const std::string &n, bool bt, } mutex_debugging_base::~mutex_debugging_base() { - assert(nlock == 0); + ceph_assert(nlock == 0); if (cct && logger) { cct->get_perfcounters_collection()->remove(logger); delete logger; diff --git a/src/common/mutex_debug.h b/src/common/mutex_debug.h index 920776f0acb..e19344e8844 100644 --- a/src/common/mutex_debug.h +++ b/src/common/mutex_debug.h @@ -80,17 +80,17 @@ public: void _post_lock() { if (!impl->recursive) - assert(nlock == 0); + ceph_assert(nlock == 0); locked_by = std::this_thread::get_id(); nlock++; } void _pre_unlock() { - assert(nlock > 0); + ceph_assert(nlock > 0); --nlock; - assert(locked_by == std::this_thread::get_id()); + ceph_assert(locked_by == std::this_thread::get_id()); if (!impl->recursive) - assert(nlock == 0); + ceph_assert(nlock == 0); if (nlock == 0) locked_by = std::thread::id(); } @@ -146,14 +146,14 @@ public: r = pthread_mutexattr_settype(&a, PTHREAD_MUTEX_RECURSIVE); else r = pthread_mutexattr_settype(&a, PTHREAD_MUTEX_ERRORCHECK); - assert(r == 0); + ceph_assert(r == 0); r = pthread_mutex_init(&m, &a); - assert(r == 0); + ceph_assert(r == 0); } // Mutex is Destructible ~mutex_debug_impl() { int r = pthread_mutex_destroy(&m); - assert(r == 0); + ceph_assert(r == 0); } // Mutex concept is non-Copyable @@ -172,12 +172,12 @@ public: r == EBUSY)) { throw std::system_error(r, std::generic_category()); } - assert(r == 0); + ceph_assert(r == 0); } void unlock_impl() noexcept { int r = pthread_mutex_unlock(&m); - assert(r == 0); + ceph_assert(r == 0); } bool try_lock_impl() { diff --git a/src/common/obj_bencher.cc b/src/common/obj_bencher.cc index 525734ea676..c70209dd2a9 100644 --- a/src/common/obj_bencher.cc +++ b/src/common/obj_bencher.cc @@ -64,7 +64,7 @@ static std::string generate_object_name_fast(int objnum, int pid = 0) char name[512]; int n = snprintf(&name[0], sizeof(name), BENCH_OBJ_NAME.c_str(), cached_hostname, cached_pid, objnum); - assert(n > 0 && n < (int)sizeof(name)); + ceph_assert(n > 0 && n < (int)sizeof(name)); return std::string(&name[0], (size_t)n); } diff --git a/src/common/perf_counters.cc b/src/common/perf_counters.cc index 2bfee69e7a5..5fb9fa098cd 100644 --- a/src/common/perf_counters.cc +++ b/src/common/perf_counters.cc @@ -72,7 +72,7 @@ void PerfCountersCollection::remove(class PerfCounters *l) } perf_counters_set_t::iterator i = m_loggers.find(l); - assert(i != m_loggers.end()); + ceph_assert(i != m_loggers.end()); m_loggers.erase(i); } @@ -167,8 +167,8 @@ void PerfCounters::inc(int idx, uint64_t amt) if (!m_cct->_conf->perf) return; - assert(idx > m_lower_bound); - assert(idx < m_upper_bound); + ceph_assert(idx > m_lower_bound); + ceph_assert(idx < m_upper_bound); perf_counter_data_any_d& data(m_data[idx - m_lower_bound - 1]); if (!(data.type & PERFCOUNTER_U64)) return; @@ -186,10 +186,10 @@ void PerfCounters::dec(int idx, uint64_t amt) if (!m_cct->_conf->perf) return; - assert(idx > m_lower_bound); - assert(idx < m_upper_bound); + ceph_assert(idx > m_lower_bound); + ceph_assert(idx < m_upper_bound); perf_counter_data_any_d& data(m_data[idx - m_lower_bound - 1]); - assert(!(data.type & PERFCOUNTER_LONGRUNAVG)); + ceph_assert(!(data.type & PERFCOUNTER_LONGRUNAVG)); if (!(data.type & PERFCOUNTER_U64)) return; data.u64 -= amt; @@ -200,8 +200,8 @@ void PerfCounters::set(int idx, uint64_t amt) if (!m_cct->_conf->perf) return; - assert(idx > m_lower_bound); - assert(idx < m_upper_bound); + ceph_assert(idx > m_lower_bound); + ceph_assert(idx < m_upper_bound); perf_counter_data_any_d& data(m_data[idx - m_lower_bound - 1]); if (!(data.type & PERFCOUNTER_U64)) return; @@ -222,8 +222,8 @@ uint64_t PerfCounters::get(int idx) const if (!m_cct->_conf->perf) return 0; - assert(idx > m_lower_bound); - assert(idx < m_upper_bound); + ceph_assert(idx > m_lower_bound); + ceph_assert(idx < m_upper_bound); const perf_counter_data_any_d& data(m_data[idx - m_lower_bound - 1]); if (!(data.type & PERFCOUNTER_U64)) return 0; @@ -235,8 +235,8 @@ void PerfCounters::tinc(int idx, utime_t amt) if (!m_cct->_conf->perf) return; - assert(idx > m_lower_bound); - assert(idx < m_upper_bound); + ceph_assert(idx > m_lower_bound); + ceph_assert(idx < m_upper_bound); perf_counter_data_any_d& data(m_data[idx - m_lower_bound - 1]); if (!(data.type & PERFCOUNTER_TIME)) return; @@ -254,8 +254,8 @@ void PerfCounters::tinc(int idx, ceph::timespan amt) if (!m_cct->_conf->perf) return; - assert(idx > m_lower_bound); - assert(idx < m_upper_bound); + ceph_assert(idx > m_lower_bound); + ceph_assert(idx < m_upper_bound); perf_counter_data_any_d& data(m_data[idx - m_lower_bound - 1]); if (!(data.type & PERFCOUNTER_TIME)) return; @@ -273,8 +273,8 @@ void PerfCounters::tset(int idx, utime_t amt) if (!m_cct->_conf->perf) return; - assert(idx > m_lower_bound); - assert(idx < m_upper_bound); + ceph_assert(idx > m_lower_bound); + ceph_assert(idx < m_upper_bound); perf_counter_data_any_d& data(m_data[idx - m_lower_bound - 1]); if (!(data.type & PERFCOUNTER_TIME)) return; @@ -288,8 +288,8 @@ utime_t PerfCounters::tget(int idx) const if (!m_cct->_conf->perf) return utime_t(); - assert(idx > m_lower_bound); - assert(idx < m_upper_bound); + ceph_assert(idx > m_lower_bound); + ceph_assert(idx < m_upper_bound); const perf_counter_data_any_d& data(m_data[idx - m_lower_bound - 1]); if (!(data.type & PERFCOUNTER_TIME)) return utime_t(); @@ -302,12 +302,12 @@ void PerfCounters::hinc(int idx, int64_t x, int64_t y) if (!m_cct->_conf->perf) return; - assert(idx > m_lower_bound); - assert(idx < m_upper_bound); + ceph_assert(idx > m_lower_bound); + ceph_assert(idx < m_upper_bound); perf_counter_data_any_d& data(m_data[idx - m_lower_bound - 1]); - assert(data.type == (PERFCOUNTER_HISTOGRAM | PERFCOUNTER_COUNTER | PERFCOUNTER_U64)); - assert(data.histogram); + ceph_assert(data.type == (PERFCOUNTER_HISTOGRAM | PERFCOUNTER_COUNTER | PERFCOUNTER_U64)); + ceph_assert(data.histogram); data.histogram->inc(x, y); } @@ -317,8 +317,8 @@ pair<uint64_t, uint64_t> PerfCounters::get_tavg_ns(int idx) const if (!m_cct->_conf->perf) return make_pair(0, 0); - assert(idx > m_lower_bound); - assert(idx < m_upper_bound); + ceph_assert(idx > m_lower_bound); + ceph_assert(idx < m_upper_bound); const perf_counter_data_any_d& data(m_data[idx - m_lower_bound - 1]); if (!(data.type & PERFCOUNTER_TIME)) return make_pair(0, 0); @@ -431,8 +431,8 @@ void PerfCounters::dump_formatted_generic(Formatter *f, bool schema, } f->close_section(); } else if (d->type & PERFCOUNTER_HISTOGRAM) { - assert(d->type == (PERFCOUNTER_HISTOGRAM | PERFCOUNTER_COUNTER | PERFCOUNTER_U64)); - assert(d->histogram); + ceph_assert(d->type == (PERFCOUNTER_HISTOGRAM | PERFCOUNTER_COUNTER | PERFCOUNTER_U64)); + ceph_assert(d->histogram); f->open_object_section(d->name); d->histogram->dump_formatted(f); f->close_section(); @@ -537,17 +537,17 @@ void PerfCountersBuilder::add_impl( const char *description, const char *nick, int prio, int ty, int unit, unique_ptr<PerfHistogram<>> histogram) { - assert(idx > m_perf_counters->m_lower_bound); - assert(idx < m_perf_counters->m_upper_bound); + ceph_assert(idx > m_perf_counters->m_lower_bound); + ceph_assert(idx < m_perf_counters->m_upper_bound); PerfCounters::perf_counter_data_vec_t &vec(m_perf_counters->m_data); PerfCounters::perf_counter_data_any_d &data(vec[idx - m_perf_counters->m_lower_bound - 1]); - assert(data.type == PERFCOUNTER_NONE); + ceph_assert(data.type == PERFCOUNTER_NONE); data.name = name; data.description = description; // nick must be <= 4 chars if (nick) { - assert(strlen(nick) <= 4); + ceph_assert(strlen(nick) <= 4); } data.nick = nick; data.prio = prio ? prio : prio_default; @@ -561,8 +561,8 @@ PerfCounters *PerfCountersBuilder::create_perf_counters() PerfCounters::perf_counter_data_vec_t::const_iterator d = m_perf_counters->m_data.begin(); PerfCounters::perf_counter_data_vec_t::const_iterator d_end = m_perf_counters->m_data.end(); for (; d != d_end; ++d) { - assert(d->type != PERFCOUNTER_NONE); - assert(d->type & (PERFCOUNTER_U64 | PERFCOUNTER_TIME)); + ceph_assert(d->type != PERFCOUNTER_NONE); + ceph_assert(d->type & (PERFCOUNTER_U64 | PERFCOUNTER_TIME)); } PerfCounters *ret = m_perf_counters; diff --git a/src/common/perf_histogram.cc b/src/common/perf_histogram.cc index 035e3267284..13528764ade 100644 --- a/src/common/perf_histogram.cc +++ b/src/common/perf_histogram.cc @@ -33,7 +33,7 @@ void PerfHistogramCommon::dump_formatted_axis( f->dump_string("scale_type", "log2"); break; default: - assert(false && "Invalid scale type"); + ceph_assert(false && "Invalid scale type"); } { @@ -63,7 +63,7 @@ int64_t get_quants(int64_t i, PerfHistogramCommon::scale_type_d st) { case PerfHistogramCommon::SCALE_LOG2: return int64_t(1) << (i - 1); } - assert(false && "Invalid scale type"); + ceph_assert(false && "Invalid scale type"); } int64_t PerfHistogramCommon::get_bucket_for_axis( @@ -87,7 +87,7 @@ int64_t PerfHistogramCommon::get_bucket_for_axis( } return ac.m_buckets - 1; } - assert(false && "Invalid scale type"); + ceph_assert(false && "Invalid scale type"); } std::vector<std::pair<int64_t, int64_t>> diff --git a/src/common/perf_histogram.h b/src/common/perf_histogram.h index 0d5d6305425..de442825bd1 100644 --- a/src/common/perf_histogram.h +++ b/src/common/perf_histogram.h @@ -74,13 +74,13 @@ class PerfHistogram : public PerfHistogramCommon { public: /// Initialize new histogram object PerfHistogram(std::initializer_list<axis_config_d> axes_config) { - assert(axes_config.size() == DIM && - "Invalid number of axis configuration objects"); + ceph_assert(axes_config.size() == DIM && + "Invalid number of axis configuration objects"); int i = 0; for (const auto &ac : axes_config) { - assert(ac.m_buckets > 0 && "Must have at least one bucket on axis"); - assert(ac.m_quant_size > 0 && + ceph_assert(ac.m_buckets > 0 && "Must have at least one bucket on axis"); + ceph_assert(ac.m_quant_size > 0 && "Quantization unit must be non-zero positive integer value"); m_axes_config[i++] = ac; @@ -178,8 +178,8 @@ protected: static_assert(sizeof...(T) == DIM, "Incorrect number of arguments"); return get_raw_index_internal<0>( [](int64_t bucket, const axis_config_d &ac) { - assert(bucket >= 0 && "Bucket index can not be negative"); - assert(bucket < ac.m_buckets && "Bucket index too large"); + ceph_assert(bucket >= 0 && "Bucket index can not be negative"); + ceph_assert(bucket < ac.m_buckets && "Bucket index too large"); return bucket; }, 0, buckets...); diff --git a/src/common/shared_cache.hpp b/src/common/shared_cache.hpp index af58eb1a545..e728984d6a2 100644 --- a/src/common/shared_cache.hpp +++ b/src/common/shared_cache.hpp @@ -113,7 +113,7 @@ public: dump_weak_refs(*_dout); *_dout << dendl; if (cct->_conf.get_val<bool>("debug_asserts_on_shutdown")) { - assert(weak_refs.empty()); + ceph_assert(weak_refs.empty()); } } } @@ -260,7 +260,7 @@ public: if (!found || !next) return found; next->first = r.first; - assert(r.second); + ceph_assert(r.second); next->second = *(r.second); return found; } diff --git a/src/common/shared_mutex_debug.cc b/src/common/shared_mutex_debug.cc index f0f8cb35b5c..83ed3f5abe5 100644 --- a/src/common/shared_mutex_debug.cc +++ b/src/common/shared_mutex_debug.cc @@ -130,10 +130,10 @@ void shared_mutex_debug::unlock_shared() void shared_mutex_debug::_pre_unlock() { if (track) { - assert(nlock > 0); + ceph_assert(nlock > 0); --nlock; - assert(locked_by == std::this_thread::get_id()); - assert(nlock == 0); + ceph_assert(locked_by == std::this_thread::get_id()); + ceph_assert(nlock == 0); locked_by = std::thread::id(); } } @@ -141,7 +141,7 @@ void shared_mutex_debug::_pre_unlock() void shared_mutex_debug::_post_lock() { if (track) { - assert(nlock == 0); + ceph_assert(nlock == 0); locked_by = std::this_thread::get_id(); ++nlock; } @@ -151,7 +151,7 @@ void shared_mutex_debug::_post_lock() void shared_mutex_debug::_pre_unlock_shared() { if (track) { - assert(nrlock > 0); + ceph_assert(nrlock > 0); nrlock--; } } diff --git a/src/common/signal.cc b/src/common/signal.cc index 406ff463567..31e33d46771 100644 --- a/src/common/signal.cc +++ b/src/common/signal.cc @@ -61,13 +61,13 @@ void block_signals(const int *siglist, sigset_t *old_sigset) } } int ret = pthread_sigmask(SIG_BLOCK, &sigset, old_sigset); - assert(ret == 0); + ceph_assert(ret == 0); } void restore_sigset(const sigset_t *old_sigset) { int ret = pthread_sigmask(SIG_SETMASK, old_sigset, NULL); - assert(ret == 0); + ceph_assert(ret == 0); } void unblock_all_signals(sigset_t *old_sigset) @@ -76,5 +76,5 @@ void unblock_all_signals(sigset_t *old_sigset) sigfillset(&sigset); sigdelset(&sigset, SIGKILL); int ret = pthread_sigmask(SIG_UNBLOCK, &sigset, old_sigset); - assert(ret == 0); + ceph_assert(ret == 0); } diff --git a/src/common/tracked_int_ptr.hpp b/src/common/tracked_int_ptr.hpp index d797e01a3ff..fc54c4cb9d6 100644 --- a/src/common/tracked_int_ptr.hpp +++ b/src/common/tracked_int_ptr.hpp @@ -27,7 +27,7 @@ public: if (ptr) put_with_id(ptr, id); else - assert(id == 0); + ceph_assert(id == 0); } void swap(TrackedIntPtr &other) { T *optr = other.ptr; diff --git a/src/common/util.cc b/src/common/util.cc index 6caae671d3a..faddeae8625 100644 --- a/src/common/util.cc +++ b/src/common/util.cc @@ -232,7 +232,7 @@ void collect_sys_info(map<string, string> *m, CephContext *cct) void dump_services(Formatter* f, const map<string, list<int> >& services, const char* type) { - assert(f); + ceph_assert(f); f->open_object_section(type); for (map<string, list<int> >::const_iterator host = services.begin(); @@ -250,7 +250,7 @@ void dump_services(Formatter* f, const map<string, list<int> >& services, const void dump_services(Formatter* f, const map<string, list<string> >& services, const char* type) { - assert(f); + ceph_assert(f); f->open_object_section(type); for (const auto& host : services) { |