void AvlAllocator::init_add_free(uint64_t offset, uint64_t length)
{
+ if (!length)
+ return;
std::lock_guard l(lock);
ldout(cct, 10) << __func__ << std::hex
<< " offset 0x" << offset
void AvlAllocator::init_rm_free(uint64_t offset, uint64_t length)
{
+ if (!length)
+ return;
std::lock_guard l(lock);
ldout(cct, 10) << __func__ << std::hex
<< " offset 0x" << offset
void HybridAllocator::init_rm_free(uint64_t offset, uint64_t length)
{
+ if (!length)
+ return;
std::lock_guard l(lock);
ldout(cct, 10) << __func__ << std::hex
<< " offset 0x" << offset
void StupidAllocator::init_add_free(uint64_t offset, uint64_t length)
{
+ if (!length)
+ return;
std::lock_guard l(lock);
ldout(cct, 10) << __func__ << " 0x" << std::hex << offset << "~" << length
<< std::dec << dendl;
void StupidAllocator::init_rm_free(uint64_t offset, uint64_t length)
{
+ if (!length)
+ return;
std::lock_guard l(lock);
ldout(cct, 10) << __func__ << " 0x" << std::hex << offset << "~" << length
<< std::dec << dendl;
ASSERT_EQ(alloc->get_free(), (uint64_t) 0);
}
+TEST_P(AllocTest, test_init_add_free)
+{
+ int64_t block_size = 1024;
+ int64_t capacity = 4 * 1024 * block_size;
+
+ {
+ init_alloc(capacity, block_size);
+
+ auto free = alloc->get_free();
+ alloc->init_add_free(block_size, 0);
+ ASSERT_EQ(free, alloc->get_free());
+
+ alloc->init_rm_free(block_size, 0);
+ ASSERT_EQ(free, alloc->get_free());
+ }
+}
+
TEST_P(AllocTest, test_alloc_min_alloc)
{
int64_t block_size = 1024;