diff --git a/src/include/mempool.h b/src/include/mempool.h index 7e6a8dfffa2..02991541705 100644 --- a/src/include/mempool.h +++ b/src/include/mempool.h @@ -168,7 +168,9 @@ namespace mempool { #define DEFINE_MEMORY_POOLS_HELPER(f) \ f(unittest_1) \ - f(unittest_2) + f(unittest_2) \ + f(bluestore_meta_onode) \ + f(bluestore_meta_other) // give them integer ids #define P(x) x, diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 2212774c118..df854399fe4 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -34,6 +34,38 @@ #define dout_subsys ceph_subsys_bluestore +// bluestore_meta_onode +MEMPOOL_DEFINE_OBJECT_FACTORY(BlueStore::Onode, bluestore_onode, + bluestore_meta_onode); + +// bluestore_meta_other +MEMPOOL_DEFINE_OBJECT_FACTORY(BlueStore::Buffer, bluestore_buffer, + bluestore_meta_other); +MEMPOOL_DEFINE_MAP_FACTORY(uint64_t, std::unique_ptr, + bluestore_uint64_Buffer, bluestore_meta_other); +MEMPOOL_DEFINE_OBJECT_FACTORY(BlueStore::Extent, bluestore_extent, + bluestore_meta_other); +MEMPOOL_DEFINE_OBJECT_FACTORY(BlueStore::Blob, bluestore_blob, + bluestore_meta_other); +MEMPOOL_DEFINE_MAP_FACTORY(int, BlueStore::BlobRef, + bluestore_int_BlobRef, bluestore_meta_other); +MEMPOOL_DEFINE_OBJECT_FACTORY(BlueStore::SharedBlob, bluestore_shared_blob, + bluestore_meta_other); +MEMPOOL_DEFINE_FACTORY(BlueStore::ExtentMap::Shard, bluestore_ExtentMap_Shard, + bluestore_meta_other); + +MEMPOOL_DEFINE_UNORDERED_MAP_BASE_FACTORY(bluestore_meta_other); +MEMPOOL_DEFINE_UNORDERED_MAP_FACTORY(ghobject_t, BlueStore::OnodeRef, true, + bluestore_ghobject_OnodeRef, + bluestore_meta_other); +MEMPOOL_DEFINE_UNORDERED_MAP_FACTORY(coll_t, BlueStore::CollectionRef, true, + bluestore_coll_CollectionRef, + bluestore_meta_other); +MEMPOOL_DEFINE_UNORDERED_MAP_FACTORY(uint64_t, BlueStore::SharedBlob*, false, + bluestore_u64_sharedblob, + bluestore_meta_other); + +// kv store prefixes const string PREFIX_SUPER = "S"; // field -> value const string PREFIX_STAT = "T"; // field -> value(int64 array) const string PREFIX_COLL = "C"; // collection name -> cnode_t diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index ea2ce8d685b..73d57e30e60 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -32,6 +32,7 @@ #include "include/assert.h" #include "include/unordered_map.h" #include "include/memory.h" +#include "include/mempool.h" #include "common/Finisher.h" #include "compressor/Compressor.h" #include "os/ObjectStore.h" @@ -120,6 +121,8 @@ public: /// cached buffer struct Buffer { + MEMPOOL_CLASS_HELPERS(); + enum { STATE_EMPTY, ///< empty buffer -- used for cache history STATE_CLEAN, ///< clean data that is up to date @@ -207,7 +210,7 @@ public: boost::intrusive::list_member_hook<>, &Buffer::state_item> > state_list_t; - map> buffer_map; + bluestore_meta_other::map> buffer_map; Cache *cache; // we use a bare intrusive list here instead of std::map because @@ -320,6 +323,8 @@ public: /// in-memory shared blob state (incl cached buffers) struct SharedBlob { + MEMPOOL_CLASS_HELPERS(); + std::atomic_int nref = {0}; ///< reference count // these are defined/set if the shared_blob is 'loaded' @@ -362,7 +367,7 @@ public: // we use a bare pointer because we don't want to affect the ref // count - std::unordered_map sb_map; + bluestore_meta_other::unordered_map sb_map; SharedBlobRef lookup(uint64_t sbid) { std::lock_guard l(lock); @@ -397,6 +402,8 @@ public: /// in-memory blob metadata and associated cached buffers (if any) struct Blob { + MEMPOOL_CLASS_HELPERS(); + std::atomic_int nref = {0}; ///< reference count int16_t id = -1; ///< id, for spanning blobs only, >= 0 int16_t last_encoded_id = -1; ///< (ephemeral) used during encoding only @@ -516,10 +523,12 @@ public: #endif }; typedef boost::intrusive_ptr BlobRef; - typedef std::map blob_map_t; + typedef bluestore_meta_other::map blob_map_t; /// a logical extent, pointing to (some portion of) a blob struct Extent : public boost::intrusive::set_base_hook> { + MEMPOOL_CLASS_HELPERS(); + uint32_t logical_offset = 0; ///< logical offset uint32_t blob_offset = 0; ///< blob offset uint32_t length = 0; ///< length @@ -594,7 +603,7 @@ public: bool loaded = false; ///< true if shard is loaded bool dirty = false; ///< true if shard is dirty and needs reencoding }; - vector shards; ///< shards + bluestore_meta_other::vector shards; ///< shards bufferlist inline_bl; ///< cached encoded map, if unsharded; empty=>dirty @@ -732,6 +741,8 @@ public: /// an in-memory object struct Onode { + MEMPOOL_CLASS_HELPERS(); + std::atomic_int nref; ///< reference count Collection *c; @@ -991,7 +1002,9 @@ public: struct OnodeSpace { Cache *cache; - ceph::unordered_map onode_map; ///< forward lookups + + /// forward lookups + bluestore_meta_other::unordered_map onode_map; OnodeSpace(Cache *c) : cache(c) {} ~OnodeSpace() { @@ -1429,7 +1442,7 @@ private: bool mounted; RWLock coll_lock; ///< rwlock to protect coll_map - ceph::unordered_map coll_map; + bluestore_meta_other::unordered_map coll_map; vector cache_shards; diff --git a/src/os/bluestore/bluestore_types.cc b/src/os/bluestore/bluestore_types.cc index f24a94fd6b1..93d307ee4da 100644 --- a/src/os/bluestore/bluestore_types.cc +++ b/src/os/bluestore/bluestore_types.cc @@ -112,6 +112,9 @@ void bluestore_cnode_t::generate_test_instances(list& o) // bluestore_extent_ref_map_t +MEMPOOL_DEFINE_MAP_FACTORY(uint64_t, bluestore_extent_ref_map_t::record_t, + uint64_extent_ref_map_record, bluestore_meta_other) + void bluestore_extent_ref_map_t::_check() const { uint64_t pos = 0; diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index 5917d333428..901954a4e1c 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -24,6 +24,7 @@ #include "common/hobject.h" #include "compressor/Compressor.h" #include "common/Checksummer.h" +#include "include/mempool.h" namespace ceph { class Formatter; @@ -187,10 +188,11 @@ struct bluestore_extent_ref_map_t { } }; - map ref_map; + typedef bluestore_meta_other::map map_t; + map_t ref_map; void _check() const; - void _maybe_merge_left(map::iterator& p); + void _maybe_merge_left(map_t::iterator& p); void clear() { ref_map.clear();