]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/mon/PaxosService.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / mon / PaxosService.cc
index e2b9376bdc70b52e87b4aa67c03584cd18fd6421..06776635f94966ddeea1c2ab387252614bdedd7c 100644 (file)
@@ -16,7 +16,7 @@
 #include "common/Clock.h"
 #include "common/config.h"
 #include "include/stringify.h"
-#include "include/assert.h"
+#include "include/ceph_assert.h"
 #include "mon/MonOpRequest.h"
 
 #define dout_subsys ceph_subsys_paxos
@@ -31,7 +31,7 @@ static ostream& _prefix(std::ostream *_dout, Monitor *mon, Paxos *paxos, string
 
 bool PaxosService::dispatch(MonOpRequestRef op)
 {
-  assert(op->is_type_service() || op->is_type_command());
+  ceph_assert(op->is_type_service() || op->is_type_command());
   PaxosServiceMessage *m = static_cast<PaxosServiceMessage*>(op->get_req());
   op->mark_event("psvc:dispatch");
 
@@ -124,7 +124,7 @@ bool PaxosService::dispatch(MonOpRequestRef op)
         } else if (r == -ECANCELED || r == -EAGAIN) {
           return;
         } else {
-          assert(0 == "bad return value for proposal_timer");
+          ceph_abort_msg("bad return value for proposal_timer");
         }
     });
     dout(10) << " setting proposal_timer " << do_propose
@@ -172,10 +172,10 @@ bool PaxosService::should_propose(double& delay)
     delay = 0.0;
   } else {
     utime_t now = ceph_clock_now();
-    if ((now - paxos->last_commit_time) > g_conf->paxos_propose_interval)
-      delay = (double)g_conf->paxos_min_wait;
+    if ((now - paxos->last_commit_time) > g_conf()->paxos_propose_interval)
+      delay = (double)g_conf()->paxos_min_wait;
     else
-      delay = (double)(g_conf->paxos_propose_interval + paxos->last_commit_time
+      delay = (double)(g_conf()->paxos_propose_interval + paxos->last_commit_time
                       - now);
   }
   return true;
@@ -185,10 +185,10 @@ bool PaxosService::should_propose(double& delay)
 void PaxosService::propose_pending()
 {
   dout(10) << __func__ << dendl;
-  assert(have_pending);
-  assert(!proposing);
-  assert(mon->is_leader());
-  assert(is_active());
+  ceph_assert(have_pending);
+  ceph_assert(!proposing);
+  ceph_assert(mon->is_leader());
+  ceph_assert(is_active());
 
   if (proposal_timer) {
     dout(10) << " canceling proposal_timer " << proposal_timer << dendl;
@@ -240,7 +240,7 @@ void PaxosService::propose_pending()
       else if (r == -ECANCELED || r == -EAGAIN)
        return;
       else
-       assert(0 == "bad return value for C_Committed");
+       ceph_abort_msg("bad return value for C_Committed");
     }
   };
   paxos->queue_pending_finisher(new C_Committed(this));
@@ -257,7 +257,7 @@ bool PaxosService::should_stash_full()
    */
   return (!latest_full ||
          (latest_full <= get_trim_to()) ||
-         (get_last_committed() - latest_full > (version_t)g_conf->paxos_stash_full_interval));
+         (get_last_committed() - latest_full > (version_t)g_conf()->paxos_stash_full_interval));
 }
 
 void PaxosService::restart()
@@ -335,9 +335,7 @@ void PaxosService::_active()
       return;
     }
   } else {
-    if (!mon->is_leader()) {
-      dout(7) << __func__ << " we are not the leader, hence we propose nothing!" << dendl;
-    }
+    dout(7) << __func__ << " we are not the leader, hence we propose nothing!" << dendl;
   }
 
   // wake up anyone who came in while we were proposing.  note that
@@ -379,20 +377,20 @@ void PaxosService::maybe_trim()
     return;
 
   version_t to_remove = trim_to - get_first_committed();
-  if (g_conf->paxos_service_trim_min > 0 &&
-      to_remove < (version_t)g_conf->paxos_service_trim_min) {
+  if (g_conf()->paxos_service_trim_min > 0 &&
+      to_remove < (version_t)g_conf()->paxos_service_trim_min) {
     dout(10) << __func__ << " trim_to " << trim_to << " would only trim " << to_remove
-            << " < paxos_service_trim_min " << g_conf->paxos_service_trim_min << dendl;
+            << " < paxos_service_trim_min " << g_conf()->paxos_service_trim_min << dendl;
     return;
   }
 
-  if (g_conf->paxos_service_trim_max > 0 &&
-      to_remove > (version_t)g_conf->paxos_service_trim_max) {
+  if (g_conf()->paxos_service_trim_max > 0 &&
+      to_remove > (version_t)g_conf()->paxos_service_trim_max) {
     dout(10) << __func__ << " trim_to " << trim_to << " would only trim " << to_remove
-            << " > paxos_service_trim_max, limiting to " << g_conf->paxos_service_trim_max
+            << " > paxos_service_trim_max, limiting to " << g_conf()->paxos_service_trim_max
             << dendl;
-    trim_to = get_first_committed() + g_conf->paxos_service_trim_max;
-    to_remove = g_conf->paxos_service_trim_max;
+    trim_to = get_first_committed() + g_conf()->paxos_service_trim_max;
+    to_remove = g_conf()->paxos_service_trim_max;
   }
 
   dout(10) << __func__ << " trimming to " << trim_to << ", " << to_remove << " states" << dendl;
@@ -411,7 +409,7 @@ void PaxosService::trim(MonitorDBStore::TransactionRef t,
                        version_t from, version_t to)
 {
   dout(10) << __func__ << " from " << from << " to " << to << dendl;
-  assert(from != to);
+  ceph_assert(from != to);
 
   for (version_t v = from; v < to; ++v) {
     dout(20) << __func__ << " " << v << dendl;
@@ -423,7 +421,7 @@ void PaxosService::trim(MonitorDBStore::TransactionRef t,
       t->erase(get_service_name(), full_key);
     }
   }
-  if (g_conf->mon_compact_on_trim) {
+  if (g_conf()->mon_compact_on_trim) {
     dout(20) << " compacting prefix " << get_service_name() << dendl;
     t->compact_range(get_service_name(), stringify(from - 1), stringify(to));
     t->compact_range(get_service_name(),
@@ -437,7 +435,7 @@ void PaxosService::load_health()
   bufferlist bl;
   mon->store->get("health", service_name, bl);
   if (bl.length()) {
-    auto p = bl.begin();
-    ::decode(health_checks, p);
+    auto p = bl.cbegin();
+    decode(health_checks, p);
   }
 }