Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os/bluestore: fix memory leak during bit_alloc testing #9935

Merged
merged 3 commits into from
Jun 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

}
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok

}

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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good.

allocated = alloc->alloc_blocks_dis(alloc->size()/2, blocks);
bmap_test_assert(allocated == alloc->size() / 2);

Expand Down