Skip to content

Commit

Permalink
Merge pull request #9935 from xiexingguo/xxg-wip-make-zone-configurable
Browse files Browse the repository at this point in the history
os/bluestore: fix memory leak during bit_alloc testing

Reviewed-by: Ramesh Chander <Ramesh.Chander@sandisk.com>
  • Loading branch information
liewegas committed Jun 30, 2016
2 parents f2c2c29 + f35b05b commit 0ab6480
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/os/bluestore/BitMapAllocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ BitMapAllocator::BitMapAllocator(int64_t device_size, int64_t block_size)
zone_size_blks, CONCURRENT, true);
assert(m_bit_alloc);
if (!m_bit_alloc) {
dout(10) << __func__ << "Unable to intialize Bit Allocator" << dendl;
derr << __func__ << " Unable to intialize Bit Allocator" << dendl;
}
dout(10) << __func__ << " instance " << (uint64_t) this
<< " size 0x" << std::hex << device_size << std::dec
Expand Down
15 changes: 11 additions & 4 deletions src/test/objectstore/BitAllocator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ TEST(BitAllocator, test_bmap_iter)
bmap_test_assert(count == num_items + 1);

delete arr;
//delete list;

num_items = 4;
off = num_items - 1;
Expand All @@ -93,7 +92,6 @@ TEST(BitAllocator, test_bmap_iter)
for (i = 0; i < num_items; i++) {
(*arr)[i].init(i);
}
// list = new BitMapList<BmapEntityTmp>(arr, num_items, 0);
iter = BitMapEntityIter<BmapEntityTmp>(arr, off, true);
i = off;
last_idx = off;
Expand All @@ -109,6 +107,8 @@ TEST(BitAllocator, test_bmap_iter)
bmap_test_assert(i == (off + 1)%num_items);
bmap_test_assert(count == num_items + 1);

delete arr;

/*
* BitMapArea Iter tests.
*/
Expand Down Expand Up @@ -136,7 +136,6 @@ TEST(BitAllocator, test_bmap_iter)
bmap_test_assert(i == off);
bmap_test_assert(count == num_items);

// offset 0
off = 0;
area_iter = BmapEntityListIter(area_list, off, true);
i = off;
Expand All @@ -152,6 +151,12 @@ TEST(BitAllocator, test_bmap_iter)
}
bmap_test_assert(i == (off + 1)%num_items);
bmap_test_assert(count == num_items + 1);

for (i = 0; i < num_items; i++)
delete children[i];

delete children;
delete area_list;
}

TEST(BitAllocator, test_bmap_entry)
Expand Down Expand Up @@ -232,6 +237,7 @@ TEST(BitAllocator, test_bmap_entry)
bmap_test_assert(!bmap->is_allocated(0, 4));
bmap->set_bits(0, 4);
bmap_test_assert(bmap->is_allocated(0, BmapEntry::size()));
delete bmap;
}

TEST(BitAllocator, test_zone_alloc)
Expand Down Expand Up @@ -384,7 +390,6 @@ TEST(BitAllocator, test_bmap_alloc)
delete alloc;
alloc = new BitAllocator(total_blocks, zone_size, CONCURRENT);

int64_t blocks[2048] = {0};
for (int64_t i = 0; i < alloc->size(); i++) {
allocated = alloc->alloc_blocks(1, &start_block);
bmap_test_assert(allocated == 1);
Expand All @@ -393,6 +398,8 @@ TEST(BitAllocator, test_bmap_alloc)
alloc->free_blocks(i, 1);
}

int64_t blocks[alloc->size() / 2];
memset(blocks, 0, sizeof(blocks));
allocated = alloc->alloc_blocks_dis(alloc->size()/2, blocks);
bmap_test_assert(allocated == alloc->size() / 2);

Expand Down

0 comments on commit 0ab6480

Please sign in to comment.