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: v15.1.0~1945^2~7 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0d64893c3ebc8a56ceac61596efc6f75ed06fbaf;p=ceph-ci.git BlueStore/allocator: Give allocator names, so they can be distinguished. Signed-off-by: Adam Kupczyk --- 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 00fdf0394b9..6877a3bbce7 100644 --- a/src/os/bluestore/Allocator.h +++ b/src/os/bluestore/Allocator.h @@ -19,7 +19,8 @@ class Allocator { public: - virtual ~Allocator() {} + explicit Allocator(const std::string& name); + virtual ~Allocator(); /* * Allocate required number of blocks in n number of extents. @@ -57,8 +58,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 367108c5880..c24a333aae3 100644 --- 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 100644 --- 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 b9c529641bd..e5d9174730c 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -441,9 +441,15 @@ void BlueFS::_init_alloc() continue; } 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 52ebc5004f6..305ea688187 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -4841,7 +4841,7 @@ int BlueStore::_open_alloc() 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 289e1736280..c80c855ad40 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 d603b47173e..23264757c3f 100644 --- a/src/os/bluestore/StupidAllocator.h +++ b/src/os/bluestore/StupidAllocator.h @@ -35,7 +35,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(