#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)
class Allocator {
public:
- virtual ~Allocator() {}
+ explicit Allocator(const std::string& name);
+ virtual ~Allocator();
/*
* Allocate required number of blocks in n number of extents.
}
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
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 << "/"
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
{
}
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<uint64_t>& p = block_all[id];
for (interval_set<uint64_t>::iterator q = p.begin(); q != p.end(); ++q) {
alloc[id]->init_add_free(q.get_start(), q.get_len());
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
#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)
{
uint64_t alloc_unit);
public:
- StupidAllocator(CephContext* cct);
+ StupidAllocator(CephContext* cct, const std::string& name = "");
~StupidAllocator() override;
int64_t allocate(