Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxi Chen <[email protected]>
  • Loading branch information
xiaoxichen committed Aug 14, 2024
1 parent d6f1639 commit d1ac41d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/lib/device/hs_super_blk.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ class hs_super_blk {
static uint64_t chunk_super_block_size(const dev_info& dinfo);
static uint64_t chunk_info_bitmap_size(const dev_info& dinfo) {
// Chunk bitmap area has bitmap of max_chunks rounded off to 4k page
return sisl::round_up(bitset_serialized::nbytes(hs_super_blk::max_chunks_in_pdev(dinfo)), 4096));
// add 4KB headroom for bitmap serialized header
auto bytes = sisl::round_up(hs_super_blk::max_chunks_in_pdev(dinfo), 8) / 8 + 4096;
return sisl::round_up(bytes, 4096);
}

static uint64_t total_size(const dev_info& dinfo) { return total_used_size(dinfo) + future_padding_size(dinfo); }
Expand All @@ -197,13 +199,10 @@ class hs_super_blk {
return (dinfo.dev_type == HSDevType::Fast) ? EXTRA_SB_SIZE_FOR_FAST_DEVICE : EXTRA_SB_SIZE_FOR_DATA_DEVICE;
}
static uint32_t max_chunks_in_pdev(const dev_info& dinfo) {
uint64_t min_chunk_size =
(dinfo.dev_type == HSDevType::Fast) ? MIN_CHUNK_SIZE_FAST_DEVICE : MIN_CHUNK_SIZE_DATA_DEVICE;
#ifdef _PRERELEASE
auto chunk_size = iomgr_flip::instance()->get_test_flip< long >("set_minimum_chunk_size");
if (chunk_size) { min_chunk_size = chunk_size.get(); }
#endif
return (dinfo.dev_size - 1) / min_chunk_size + 1;
uint64_t min_c_size = min_chunk_size(dinfo.dev_type);
// Do not round up , for a device with 128MB and min_chunk_size = 16MB, we should get 8 chunks
// for a device with 100MB and min_chunk_size = 16MB, we should get 6 chunks, not 7.
return dinfo.dev_size / min_c_size;
}
static uint32_t min_chunk_size(HSDevType dtype) {
uint64_t min_chunk_size = (dtype == HSDevType::Fast) ? MIN_CHUNK_SIZE_FAST_DEVICE : MIN_CHUNK_SIZE_DATA_DEVICE;
Expand Down
4 changes: 3 additions & 1 deletion src/tests/test_pdev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ SISL_OPTION_GROUP(test_pdev,
::cxxopts::value< uint32_t >()->default_value("2"), "number"),
(data_dev_size_mb, "", "data_dev_size_mb", "size of each data device in MB",
::cxxopts::value< uint64_t >()->default_value("1024"), "number"),
// in OrderlyChunkOpsWithRestart UT, we need to create 10 chunks on fast drive
// ensure fast dev has > min_chunk_size_fast(32M) * 10 capacity.
(fast_dev_size_mb, "", "fast_dev_size_mb", "size of each fast device in MB",
::cxxopts::value< uint64_t >()->default_value("100"), "number"),
::cxxopts::value< uint64_t >()->default_value("400"), "number"),
(spdk, "", "spdk", "spdk", ::cxxopts::value< bool >()->default_value("false"), "true or false"));

std::vector< std::string > g_data_dev_names;
Expand Down

0 comments on commit d1ac41d

Please sign in to comment.