From 1dc6393daf3e04b56fa7c4e21e3b79a0bc8219c9 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 28 May 2017 21:19:44 -0400 Subject: [PATCH] mempool: allow pool counts to be adjusted explicitly Signed-off-by: Sage Weil --- src/common/mempool.cc | 7 +++++++ src/include/mempool.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/common/mempool.cc b/src/common/mempool.cc index 15643567b9b2e..ccb74dd1ea0a9 100644 --- a/src/common/mempool.cc +++ b/src/common/mempool.cc @@ -77,6 +77,13 @@ size_t mempool::pool_t::allocated_items() const return (size_t) result; } +void mempool::pool_t::adjust_count(ssize_t items, ssize_t bytes) +{ + shard_t *shard = pick_a_shard(); + shard->items += items; + shard->bytes += bytes; +} + void mempool::pool_t::get_stats( stats_t *total, std::map *by_type) const diff --git a/src/include/mempool.h b/src/include/mempool.h index 016b76b9c66ef..4914313a3009b 100644 --- a/src/include/mempool.h +++ b/src/include/mempool.h @@ -218,6 +218,8 @@ public: size_t allocated_bytes() const; size_t allocated_items() const; + void adjust_count(ssize_t items, ssize_t bytes); + shard_t* pick_a_shard() { // Dirt cheap, see: // http://fossies.org/dox/glibc-2.24/pthread__self_8c_source.html -- 2.39.5