#define dout_prefix *_dout << "stupidalloc 0x" << this << " "
StupidAllocator::StupidAllocator(CephContext* cct,
- const std::string& name,
- int64_t _size,
- int64_t _block_size)
- : Allocator(name, _size, _block_size), cct(cct), num_free(0),
+ int64_t capacity,
+ int64_t _block_size,
+ std::string_view name)
+ : Allocator(name, capacity, _block_size),
+ cct(cct), num_free(0),
free(10)
{
ceph_assert(cct != nullptr);
- bdev_block_size = cct->_conf->bdev_block_size;
+ ceph_assert(block_size > 0);
}
StupidAllocator::~StupidAllocator()
unsigned StupidAllocator::_choose_bin(uint64_t orig_len)
{
- ceph_assert(bdev_block_size > 0);
- uint64_t len = orig_len / bdev_block_size;
+ uint64_t len = orig_len / block_size;
int bin = std::min((int)cbits(len), (int)free.size() - 1);
ldout(cct, 30) << __func__ << " len 0x" << std::hex << orig_len
<< std::dec << " -> " << bin << dendl;