Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class HomeBlocksConan(ConanFile):
name = "homeblocks"
version = "4.0.1"
version = "4.0.2"

homepage = "https://github.com/eBay/HomeBlocks"
description = "Block Store built on HomeStore"
Expand Down
3 changes: 3 additions & 0 deletions src/lib/home_blks_config.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ table HomeBlksSettings{

// homestore dataservice chunk size;
hs_data_chunk_size_mb: uint32 = 2048;

// volume lazy alloc blks feature on/off
volume_lazy_alloc_blks_on: bool = false;
}

root_type HomeBlksSettings;
14 changes: 8 additions & 6 deletions src/lib/volume/tests/test_volume_chunk_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,12 @@ TEST_F(ChunkSelectorTest, AllocateReleaseChunksTest) {
auto init_num_free_chunks = chunk_sel->num_free_chunks();

// Allocate chunks for multiple volumes to simulate volume create.
auto vol1_chunks = chunk_sel->allocate_init_chunks(0 /* ordinal */, 180 * Ki, pdev_id);
auto vol1_chunks = chunk_sel->allocate_init_chunks(0 /* ordinal */, 160 * Ki, pdev_id);
RELEASE_ASSERT(!vol1_chunks.empty(), "no chunks");

// Since we lazily allocate chunks, we can allocate more than sum
// of all volume sizes. Make sure same chunks not allocated to multiple volumes.
for (uint32_t i = 1; i < 5; i++) {
auto vol_chunks = chunk_sel->allocate_init_chunks(i /* ordinal */, 180 * Ki, pdev_id);
// Make sure same chunks not allocated to multiple volumes.
for (uint32_t i = 1; i < 4; i++) {
auto vol_chunks = chunk_sel->allocate_init_chunks(i /* ordinal */, 160 * Ki, pdev_id);
RELEASE_ASSERT(!vol_chunks.empty(), "no chunks");
bool noDuplicates = std::none_of(vol1_chunks.begin(), vol1_chunks.end(), [&](int elem) {
return std::unordered_set< int >(vol_chunks.begin(), vol_chunks.end()).count(elem) > 0;
Expand All @@ -146,7 +145,7 @@ TEST_F(ChunkSelectorTest, AllocateReleaseChunksTest) {
}

// Release all chunks to simulate volume destroy.
for (uint32_t i = 0; i < 5; i++) {
for (uint32_t i = 0; i < 4; i++) {
chunk_sel->release_chunks(i /* ordinal */);
}

Expand Down Expand Up @@ -182,6 +181,8 @@ TEST_F(ChunkSelectorTest, SelectChunksTest) {
}

#ifdef _PRERELEASE
// This test case will fail as the lazy allocation of the chunks is disabled
#if 0
Copy link
Contributor

Choose a reason for hiding this comment

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

We should still test both scenario's. Since we dont depend on homestore config, you can add it as true here.

TEST_F(ChunkSelectorTest, ResizeNumChunksTest) {
auto latch = std::make_shared< std::latch >(1);
auto chunk_sel = std::make_shared< VolumeChunkSelector >(
Expand Down Expand Up @@ -213,6 +214,7 @@ TEST_F(ChunkSelectorTest, ResizeNumChunksTest) {
RELEASE_ASSERT_GT(resized_chunks.size(), initial_chunks.size(), "Resize op failed");
}
#endif
#endif

TEST_F(ChunkSelectorTest, RecoverChunksTest) {
auto chunk_sel =
Expand Down
3 changes: 2 additions & 1 deletion src/lib/volume/volume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*********************************************************************************/
#include "volume.hpp"
#include "lib/homeblks_impl.hpp"
#include "lib/home_blks_config.hpp"
#include <homestore/replication_service.hpp>
#include <iomgr/iomgr_flip.hpp>

Expand Down Expand Up @@ -85,7 +86,7 @@ bool Volume::init(bool is_recovery) {
// Allocate initial set of chunks for the volume with thin provisioning.
uint32_t pdev_id;
auto chunk_ids =
volume_chunk_selector_->allocate_init_chunks(vol_info_->ordinal, vol_info_->size_bytes, pdev_id);
volume_chunk_selector_->allocate_init_chunks(vol_info_->ordinal, vol_info_->size_bytes, pdev_id, HB_DYNAMIC_CONFIG(volume_lazy_alloc_blks_on));
if (chunk_ids.empty()) {
LOGE("Failed to allocate chunks for volume: {}, uuid: {}", vol_info_->name,
boost::uuids::to_string(vol_info_->id));
Expand Down
2 changes: 1 addition & 1 deletion src/lib/volume/volume_chunk_selector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class VolumeChunkSelector : public homestore::ChunkSelector {

// Allocate some initial set of chunks during volume or index create. The number is num_chunks_per_resize
std::vector< chunk_num_t > allocate_init_chunks(uint64_t volume_ordinal, uint64_t volume_size, uint32_t& pdev_id,
bool lazy_alloc = true);
bool lazy_alloc = false);

// Called during destroy of volume or index.
void release_chunks(uint64_t volume_ordinal);
Expand Down
Loading