From: Sage Weil Date: Tue, 18 Oct 2016 16:06:27 +0000 (-0400) Subject: mempool: simplify debug settings X-Git-Tag: v11.1.0~442^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b15a377a7b077f2cb3c1bde9687e36f6ed209321;p=ceph.git mempool: simplify debug settings There's no need for a per-pool debug flag; just use the global debug_mode bool! Signed-off-by: Sage Weil --- diff --git a/src/global/mempool.cc b/src/global/mempool.cc index 413353d4a0fc..b034a79af7a7 100644 --- a/src/global/mempool.cc +++ b/src/global/mempool.cc @@ -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 shard_lock(lock); for (auto &p : type_map) { std::string n = ceph_demangle(p.second.type_name); diff --git a/src/include/mempool.h b/src/include/mempool.h index 9988b5b3f4ab..565f0abe2c93 100644 --- a/src/include/mempool.h +++ b/src/include/mempool.h @@ -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 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(new char[total]);