From: Adam Kupczyk Date: Fri, 2 Aug 2019 11:53:37 +0000 (+0200) Subject: BlueStore/allocator: Give allocator names, so they can be distinguished. X-Git-Tag: v12.2.13~157^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=51bc73e4b231655c6f2e9eeb89ac8f0d4689553d;p=ceph.git BlueStore/allocator: Give allocator names, so they can be distinguished. Signed-off-by: Adam Kupczyk (cherry picked from commit 0d64893c3ebc8a56ceac61596efc6f75ed06fbaf) --- diff --git a/src/os/bluestore/Allocator.cc b/src/os/bluestore/Allocator.cc index 4c140cefd48..56854a056b8 100644 --- a/src/os/bluestore/Allocator.cc +++ b/src/os/bluestore/Allocator.cc @@ -8,17 +8,31 @@ #define dout_subsys ceph_subsys_bluestore +Allocator::Allocator(const std::string& name) +{ + asok_hook = new SocketHook(this, name); +} + + +Allocator::~Allocator() +{ +} + + Allocator *Allocator::create(CephContext* cct, string type, - int64_t size, int64_t block_size) + int64_t size, int64_t block_size, const std::string& name) { + Allocator* alloc = nullptr; if (type == "stupid") { - return new StupidAllocator(cct); + alloc = new StupidAllocator(cct, name); } else if (type == "bitmap") { - return new BitmapAllocator(cct, size, block_size); + alloc = new BitmapAllocator(cct, size, block_size, name); } - lderr(cct) << "Allocator::" << __func__ << " unknown alloc type " + if (alloc == nullptr) { + lderr(cct) << "Allocator::" << __func__ << " unknown alloc type " << type << dendl; - return nullptr; + } + return alloc; } void Allocator::release(const PExtentVector& release_vec) diff --git a/src/os/bluestore/Allocator.h b/src/os/bluestore/Allocator.h index 7425e33629d..1bb95e945df 100644 --- a/src/os/bluestore/Allocator.h +++ b/src/os/bluestore/Allocator.h @@ -21,7 +21,8 @@ class FreelistManager; class Allocator { public: - virtual ~Allocator() {} + explicit Allocator(const std::string& name); + virtual ~Allocator(); /* * Allocate required number of blocks in n number of extents. @@ -59,8 +60,9 @@ public: } virtual double get_fragmentation_score(); virtual void shutdown() = 0; + static Allocator *create(CephContext* cct, string type, int64_t size, - int64_t block_size); + int64_t block_size, const std::string& name = ""); }; #endif diff --git a/src/os/bluestore/BitmapAllocator.cc b/src/os/bluestore/BitmapAllocator.cc index 3e80d025843..80f21848915 100755 --- a/src/os/bluestore/BitmapAllocator.cc +++ b/src/os/bluestore/BitmapAllocator.cc @@ -10,7 +10,9 @@ BitmapAllocator::BitmapAllocator(CephContext* _cct, int64_t capacity, - int64_t alloc_unit) : + int64_t alloc_unit, + const std::string& name) : + Allocator(name), cct(_cct) { ldout(cct, 10) << __func__ << " 0x" << std::hex << capacity << "/" diff --git a/src/os/bluestore/BitmapAllocator.h b/src/os/bluestore/BitmapAllocator.h index df41c1a958c..ed7f122775f 100755 --- a/src/os/bluestore/BitmapAllocator.h +++ b/src/os/bluestore/BitmapAllocator.h @@ -17,7 +17,7 @@ class BitmapAllocator : public Allocator, CephContext* cct; public: - BitmapAllocator(CephContext* _cct, int64_t capacity, int64_t alloc_unit); + BitmapAllocator(CephContext* _cct, int64_t capacity, int64_t alloc_unit, const std::string& name); ~BitmapAllocator() override { } diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 9330e27d396..07dcb1b4519 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -391,9 +391,16 @@ void BlueFS::_init_alloc() continue; } assert(bdev[id]->get_size()); + ceph_assert(bdev[id]->get_size()); + std::string name = "bluefs-"; + const char* devnames[] = {"wal","db","slow"}; + if (id <= BDEV_SLOW) + name += devnames[id]; + else + name += to_string(uintptr_t(this)); alloc[id] = Allocator::create(cct, cct->_conf->bluefs_allocator, bdev[id]->get_size(), - cct->_conf->bluefs_alloc_size); + cct->_conf->bluefs_alloc_size, name); interval_set& p = block_all[id]; for (interval_set::iterator q = p.begin(); q != p.end(); ++q) { alloc[id]->init_add_free(q.get_start(), q.get_len()); diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index ee840c53c65..70f4e3c85a6 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -4613,7 +4613,7 @@ int BlueStore::_open_alloc() assert(bdev->get_size()); alloc = Allocator::create(cct, cct->_conf->bluestore_allocator, bdev->get_size(), - min_alloc_size); + min_alloc_size, "block"); if (!alloc) { lderr(cct) << __func__ << " Allocator::unknown alloc type " << cct->_conf->bluestore_allocator diff --git a/src/os/bluestore/StupidAllocator.cc b/src/os/bluestore/StupidAllocator.cc index 0f957e4c6d1..3e573f349bc 100644 --- a/src/os/bluestore/StupidAllocator.cc +++ b/src/os/bluestore/StupidAllocator.cc @@ -10,8 +10,8 @@ #undef dout_prefix #define dout_prefix *_dout << "stupidalloc 0x" << this << " " -StupidAllocator::StupidAllocator(CephContext* cct) - : cct(cct), num_free(0), +StupidAllocator::StupidAllocator(CephContext* cct, const std::string& name) + : Allocator(name), cct(cct), num_free(0), free(10), last_alloc(0) { diff --git a/src/os/bluestore/StupidAllocator.h b/src/os/bluestore/StupidAllocator.h index fb0e2761a0a..4cbb3ce75d7 100644 --- a/src/os/bluestore/StupidAllocator.h +++ b/src/os/bluestore/StupidAllocator.h @@ -34,7 +34,7 @@ class StupidAllocator : public Allocator { uint64_t alloc_unit); public: - StupidAllocator(CephContext* cct); + StupidAllocator(CephContext* cct, const std::string& name = ""); ~StupidAllocator() override; int64_t allocate(