]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: Use ceph_assert for asserts
authorAdam C. Emerson <aemerson@redhat.com>
Thu, 23 Aug 2018 15:17:26 +0000 (11:17 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Mon, 27 Aug 2018 13:09:01 +0000 (09:09 -0400)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
69 files changed:
src/common/AsyncOpTracker.cc
src/common/AsyncReserver.h
src/common/Checksummer.h
src/common/CommandTable.h
src/common/Cond.h
src/common/ConfUtils.cc
src/common/Continuation.h
src/common/Cycles.cc
src/common/Finisher.h
src/common/Formatter.cc
src/common/HeartbeatMap.cc
src/common/LogClient.cc
src/common/Mutex.cc
src/common/Mutex.h
src/common/PluginRegistry.cc
src/common/Preforker.h
src/common/PrioritizedQueue.h
src/common/QueueRing.h
src/common/RWLock.h
src/common/Readahead.cc
src/common/RefCountedObj.h
src/common/SubProcess.cc
src/common/TextTable.h
src/common/Thread.cc
src/common/Throttle.cc
src/common/Timer.cc
src/common/TracepointProvider.cc
src/common/TrackedOp.cc
src/common/TrackedOp.h
src/common/WeightedPriorityQueue.h
src/common/WorkQueue.cc
src/common/WorkQueue.h
src/common/assert.cc
src/common/async/detail/shared_mutex.h
src/common/autovector.h
src/common/bit_str.cc
src/common/bit_vector.hpp
src/common/bloom_filter.hpp
src/common/bounded_key_counter.h
src/common/buffer.cc
src/common/ceph_context.cc
src/common/ceph_crypto.cc
src/common/ceph_timer.h
src/common/cmdparse.cc
src/common/cohort_lru.h
src/common/condition_variable_debug.cc
src/common/config.cc
src/common/config_obs_mgr.h
src/common/dout.h
src/common/fork_function.h
src/common/fs_types.cc
src/common/hobject.cc
src/common/hobject.h
src/common/interval_map.h
src/common/lockdep.cc
src/common/lru_map.h
src/common/mClockPriorityQueue.h
src/common/mempool.cc
src/common/mutex_debug.cc
src/common/mutex_debug.h
src/common/obj_bencher.cc
src/common/perf_counters.cc
src/common/perf_histogram.cc
src/common/perf_histogram.h
src/common/shared_cache.hpp
src/common/shared_mutex_debug.cc
src/common/signal.cc
src/common/tracked_int_ptr.hpp
src/common/util.cc

index 10a72d2b135bb6472d762348e46f87ce2d271752..1223873b15463f4215e62f14f3db36cf14d920d5 100644 (file)
@@ -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;
index d5c7a852ddf145f682d92c1ce0a442264e615563..c88061e9647f3bc10b8cd4ef78e11af942251585 100644 (file)
@@ -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,
index c303ae2dd98884d1144e7161c6b3ca829321bba2..2137c1d6609e1c5d787b925d5234b3de707faff4 100644 (file)
@@ -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);
index e952ebe2f27895ebef745056b44a1056e4d89f9f..ed34488d1dff74b9972d47c15e2c02e735aace07 100644 (file)
@@ -63,7 +63,7 @@ public:
 
   ~CommandTable()
   {
-    assert(commands.empty());
+    ceph_assert(commands.empty());
   }
 
   T& start_command()
index 00c6cdcce2662ec4a4af3e578272b0d5fc333ab6..061370f1cf410925cfad696c07bd4207ed7d44ec 100644 (file)
@@ -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);
index c40cdce61bfa871ec8d5b4e05143ff0dbdbb6787..7c8f1cc78b7f02cdfea3dd26d49a31a9298216a8 100644 (file)
@@ -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.
   }
 }
index aa3e1ed50367d3d28d03b21eb6d1d201cf3f2a29..966b63d07acba9c0dadecf07648696002033269b 100644 (file)
@@ -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.
    */
index b1888d34cffc1179940de8a98d33e511876acdae..2d3e6ba7e7884574e1fd3b9f1b4dcb7eb4805f70 100644 (file)
@@ -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) +
index af1f8266d38669af45ab43c36fc13d65e0dc9a93..d463680a8c8cd7c62947b33ec24d837b605aa1b1 100644 (file)
@@ -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 {
index 2264c71171bc00a2ae6cecd74e8c3988ed77b142..34c81317263209d98f5a42da6bde90f83d9f0899 100644 (file)
@@ -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();
index cfd8779440abdd60632da5a88e5549f3a92c5d24..a6ca11dee382a2bf45b06674b5e39a3686239db3 100644 (file)
@@ -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;
 }
index 8702d71f0e5dd32659d783bf638cc1eb468230ac..15f188590ca7a33dda63142fbbac105ecf2287ba 100644 (file)
@@ -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);
index 1bb588902d00c5c1a8cfee9ee5b2f95374fef74a..4c449a06c4d61b20270c14ced70b6bc07b23a9bd 100644 (file)
@@ -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);
 }
index b7ceb67a581b05e198f61b15748de77125730f4e..b02ac3e38ab92f8c51972d0a37b5c6362c79aa75 100644 (file)
@@ -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();
index bf63634e2fd8dce3e26a483aceac079f3e3c0791..7faf0473be7e29471d5170577a13d9c43cbb572d 100644 (file)
@@ -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
index 8925d944daa3458f8a6e04f39d9939ac9a9c3e72..f9e1de170f3ed9dfcb2a49cd94d04dc39609b2ac 100644 (file)
@@ -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).
index 8af40334b33d21f69f749d68ea9a5c36b717b611..aade0b91b4f7888d3825b19a1ae8e5aae935563f 100644 (file)
@@ -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);
index 42582d24f4462c508ae357e8f9256aeda2d0540f..8be2365ee505b79f740035be18dc8d04c005a3db 100644 (file)
@@ -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();
index da4baefb83df88ff5735daf2b0f72686a28ad0ca..8a5a0e820764361a3d5534cd2a1ac144bca1e499 100644 (file)
@@ -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();
     }
index 7246dec62ab3e1481866bdb1d972585d1f4aba82..1b06c730dcc39024261a9fdc517488a269d6131a 100644 (file)
@@ -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));
index 325304c1441c30a1f1f7b69f80106c99c3d518c4..510a6682f9888fbf29cbcb24f709600005f65475 100644 (file)
@@ -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 {
index 30553d6b9e9a4f8e7728201a93dbfd7d607b3907..1190e6df70cee9a8bbb234f52d58aa620b632528 100644 (file)
@@ -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();
index 7fe3250603ba163444a5a4bb762def50d176f046..c60ba5f4490ef16716211c70460dcb185082580c 100644 (file)
@@ -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;
index 827443a13ee16c2012e6c6b28f4080680748d2d1..f8362a9a8dfb60f2565cd0340651d9f91e89f936 100644 (file)
@@ -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;
index 877ace344f1d9b37d8fda1e0b0427941d3d616fd..3186d8a22cbad091d864aa0b742104ebf62b1b5e 100644 (file)
@@ -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;
index 45305f553fa6c80ed45e23fd94a36ff598b68444..46061eb84df7afdfdda6c054a265aa5128d571db 100644 (file)
@@ -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;
index be982b0bc2a6cf6e34bfc29c319e5a3c50eaafc2..4c89038ced943af01522887ecbd76ae257d66add 100644 (file)
@@ -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);
 }
 
index 93df29736e182e12fd48f9f5009d9ccc735b0a1a..22f4eed25a80eefb7e4085b6dbc469d340918c85 100644 (file)
@@ -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) {
index a0790e48d9853653da99fa53df9a0c5d04972a19..704a92ee94ff5d971ce96899294f27d26ff3fc4b 100644 (file)
@@ -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)
   {
index c51a2b1f44508d38bf1007fd6091bdcbf38eb515..9ab8875ee246fad1ef27fd097d386012866f5b8f 100644 (file)
@@ -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);
       }
index d4154c3afef32dd606dd3e5c9af815c0b2c81944..2e68c8d6fa5893dbe3949aadba22bd7e269c67a6 100644 (file)
@@ -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);
index 9fbb9507275234c8931d30456eb9079a424cd264..a678f7150f4183e5bfdd4e8fdc3e2f4b3108c252 100644 (file)
@@ -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;
index 1530a6cba18dae11ab0a8fba9326871688a22d6f..623b3150b492640b599842b726fba3bd2f3b10d5 100644 (file)
@@ -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);
   }
index c44142d66104f29642f00fc4b6cec2dfac2b8796..100ec701909f7ba42d4687984b42a6ac4df33b4a 100644 (file)
@@ -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
index 5fbaa8328d2a88b8cb87d802a0131a69d848c2ec..503e239ce773b1164f37f008e0edb6ad1f24d278 100644 (file)
@@ -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 {
index e61e950de57289969db5d0374bd0bbc3d1b823c0..5f72d9983f7ff49a02e6f8cfdeef980f4f0a6a11 100644 (file)
@@ -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 << ")";
index 84fad5f916dc0d5d94b9607dc83dae75a2aef529..a07dc83b5322963a99b7472d67bebe6237c120eb 100644 (file)
@@ -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()) {
index 8b9e9a3b6f45e31a7fd3a74314b92675429377d1..8484d4edbe89250b46e81b6db19647924ba2fc33 100644 (file)
@@ -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)
index 0109a26ef1bcc36e69d58f83272f01d0af148bf2..e146a31f87630ac895f2e1d936eae7435b7cf7fc 100644 (file)
@@ -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();
index b9da5bf9c14e9a1a6004c390fd716882b8accbf9..ebd3aae511eee1a162dd3b3bc3d73acebd1d42c8 100644 (file)
@@ -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));
 }
index 513d92ee0113f5f7183b8d8c0a575c35cecd77ec..51d97e8199a63d4b49dcc202520546dfe73657da 100644 (file)
@@ -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();
 
index 055b57c3373a0857dc0c882882e2433a7c248847..38b47826e7abe653165054178d4940bba69b6c6a 100644 (file)
@@ -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) {
index 4b7438672d409bc78c2fd99c49758276eab54c28..bca800b88e4ea57b43dba5ba052a9dff29b6ae50 100644 (file)
@@ -188,7 +188,7 @@ namespace ceph {
          return;
 
        suspended = false;
-       assert(!thread.joinable());
+       ceph_assert(!thread.joinable());
        thread = std::thread(&timer::timer_thread, this);
       }
 
index 57502a25482a9a3417d9ad85b3697ac6107a1028..241aa3fa9ea0ad827a31837354abafe2e6db713d 100644 (file)
@@ -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")) {
index edd3e38828a9bded70b03a708f387944effcaaf8..db28a5827796dcc1c16694b52cfd510e45b31390 100644 (file)
@@ -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];
index ed459ea18cc115081c9caaf759214a22177055ac..ae5b7d25134a1193def147f30e34e5f44d7f74d6 100644 (file)
@@ -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);
index 0b9d35ff2f487b414d656a48ce153cd3db82f8f2..f11412f0cf6c7b6dcd28fadb4a92402f4f8d35d9 100644 (file)
@@ -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);
     }
index 170b4d63bd8a0a481b99ff04ab2d94613221eb6c..5240764524a1efd1634435d2986281c331774f5b 100644 (file)
@@ -76,7 +76,7 @@ void ObserverMgr<ConfigObs>::remove_observer(ConfigObs* observer)
       ++o;
     }
   }
-  assert(found_obs);
+  ceph_assert(found_obs);
 }
 
 template<class ConfigObs>
index 2085b56f0aec417a76d8defe4ce93d92dd01c4d8..0c2069bf340211fb088675d96d447ae65b10eb23 100644 (file)
@@ -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;
 }
 
index defea924121fe855ed1d2ed5f5e29eb11ac7c12f..137d9e6373d698dc5c2fd45cc04cf70aff70e758 100644 (file)
@@ -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";
index b62d6b0c45a4f11d7aa937a7c526033abbda2e9d..6ad4b24c31264789eebff66487f15fb7f028dc13 100644 (file)
@@ -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;
index 0474cc20a46a1da74e9769f5214c872881e2128c..e5da4a35d86b0855eba5e4f7da20ddfb36976075 100644 (file)
@@ -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) {
index 59a3109f4402bbbc5341090eb876093f87748c4b..b9f277bc8ef2782a7b59e51592adf5d0ac9ccd7a 100644 (file)
@@ -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 {
index 5357dff9fee781133199f5e283a023027655860d..320c884373275a30e930a203ef3eb0789cca48a8 100644 (file)
@@ -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) {
index cf0aba6dd4f50e6eb13d48dd4c00bb7de5f80536..8abcbc8e55b9b382258bd34214f6d958b70cca39 100644 (file)
@@ -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;
   }
 
index 35722fcd08ab1e14fe77f0f11b31691b50606a38..7dac49b4587d1ebb15167656d59fbf6e1bc5f1cf 100644 (file)
@@ -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();
   }
index 169fd08afd35635721bf8fc83007be032a5602d2..1e07ba92d4a410190f487a11ff2b6e7a5ab5231f 100644 (file)
@@ -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));
     }
index a05d72a4b3045a7946ea69368f8e3f908a143008..cb9de40da093d22de2a208e3f4adc8e7731b01ef 100644 (file)
@@ -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;
 }
 
index 49cc82b29ab52a137f8d8dfaf5642bc21659fd34..0024a25ae3492a3ae78d38cf8a0962a1ecf31a17 100644 (file)
@@ -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;
index 920776f0acba730ca59597c78d88aa4bfedb686a..e19344e88445b1ecbd54115be1fe4ab75343408c 100644 (file)
@@ -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() {
index 525734ea676496e8d2eff39f40cf943f73407732..c70209dd2a967a14440d3e6f0e46e4b843d2eb31 100644 (file)
@@ -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);
 }
 
index 2bfee69e7a5ecf13e191f7a2ae8446e90986b5b8..5fb9fa098cd1adf1a346dc89e91afd577dddfc21 100644 (file)
@@ -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;
index 035e326728464226f17c1a77a74db2e9c01452f1..13528764ade9ff77ea8728c1cfdd2baad589cc74 100644 (file)
@@ -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>>
index 0d5d630542571574bcaf2588cf2dd8d1b228461b..de442825bd1cf712ee2216036d951207336feb6f 100644 (file)
@@ -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...);
index af58eb1a5453afac39dc538d3823ac6caed595e8..e728984d6a2f6c0db53e1858b4cc47233d5f39d8 100644 (file)
@@ -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;
   }
index f0f8cb35b5cea3d0c6be37e6cf46293449f05f09..83ed3f5abe56a10c45e81b505449e7ce3cb79408 100644 (file)
@@ -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--;
   }
 }
index 406ff463567b746e8f9bb4ee14a2b0d40952cac5..31e33d46771306d6b19ca23c6f7a62856818a960 100644 (file)
@@ -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);
 }
index d797e01a3ff1defc16b1922a028a3a9b480a6e7c..fc54c4cb9d6717ff9f4f10863f5d8a7879b41ec6 100644 (file)
@@ -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;
index 6caae671d3aedf2df4798cdf289c855564a24dfa..faddeae86251878c6fe4ab504c010da219e71de9 100644 (file)
@@ -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) {