]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mempool: simplify debug settings
authorSage Weil <sage@redhat.com>
Tue, 18 Oct 2016 16:06:27 +0000 (12:06 -0400)
committerSage Weil <sage@redhat.com>
Wed, 2 Nov 2016 17:48:49 +0000 (13:48 -0400)
There's no need for a per-pool debug flag; just use the global
debug_mode bool!

Signed-off-by: Sage Weil <sage@redhat.com>
src/global/mempool.cc
src/include/mempool.h

index 413353d4a0fc12170ece913aed12f15b1d5c2667..b034a79af7a76676732b3984f506b7017b9e9446 100644 (file)
@@ -17,7 +17,7 @@
 
 
 // default to debug_mode off
-static bool debug_mode = false;
+bool mempool::debug_mode = false;
 
 // --------------------------------------------------------------
 
@@ -35,7 +35,7 @@ mempool::pool_t& mempool::get_pool(mempool::pool_index_t ix)
 
   switch (ix) {
 #define P(x)                                                           \
-  case x: pools[ix] = new mempool::pool_t(#x,debug_mode); break;
+  case x: pools[ix] = new mempool::pool_t(#x); break;
     DEFINE_MEMORY_POOLS_HELPER(P);
 #undef P
   default: assert(0);
@@ -56,11 +56,6 @@ void mempool::dump(ceph::Formatter *f, size_t skip)
 void mempool::set_debug_mode(bool d)
 {
   debug_mode = d;
-  for (size_t i = 0; i < mempool::num_pools; ++i) {
-    if (pools[i]) {
-      pools[i]->debug = d;
-    }
-  }
 }
 
 // --------------------------------------------------------------
@@ -94,7 +89,7 @@ void mempool::pool_t::get_stats(
     total->items += shard[i].items;
     total->bytes += shard[i].bytes;
   }
-  if (debug) {
+  if (debug_mode) {
     std::unique_lock<std::mutex> shard_lock(lock);
     for (auto &p : type_map) {
       std::string n = ceph_demangle(p.second.type_name);
index 9988b5b3f4ab23287be308c5e8555350cc96eb83..565f0abe2c9352995d57153251cc7b9bb0237479 100644 (file)
@@ -151,6 +151,7 @@ enum pool_index_t {
 };
 #undef P
 
+extern bool debug_mode;
 extern void set_debug_mode(bool d);
 
 // --------------------------------------------------------------
@@ -202,10 +203,8 @@ class pool_t {
   std::unordered_map<const char *, type_t> type_map;
 
 public:
-  bool debug;
-
-  pool_t(const std::string& n, bool _debug)
-    : name(n), debug(_debug) {
+  pool_t(const std::string& n)
+    : name(n) {
   }
 
   //
@@ -274,7 +273,7 @@ public:
 
   void init(bool force_register) {
     pool = &get_pool(pool_ix);
-    if (pool->debug || force_register) {
+    if (debug_mode || force_register) {
       type = pool->get_type(typeid(T), sizeof(T));
     }
   }
@@ -292,7 +291,7 @@ public:
     shard_t *shard = pool->pick_a_shard();
     shard->bytes += total;
     shard->items += n;
-    if (pool->debug) {
+    if (debug_mode) {
       type->items += n;
     }
     T* r = reinterpret_cast<T*>(new char[total]);