Skip to content

Commit 61b3a73

Browse files
Make chunk_size to uint64_t to avoid overflow and support chunk size greater equal than 4GB
1 parent 44ab175 commit 61b3a73

16 files changed

Lines changed: 79 additions & 87 deletions

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class HomestoreConan(ConanFile):
1111
name = "homestore"
12-
version = "7.3.3"
12+
version = "8.3.3"
1313

1414
homepage = "https://github.com/eBay/Homestore"
1515
description = "HomeStore Storage Engine"

src/include/homestore/blkdata_service.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class BlkDataService {
7272
* @param chunk_size The size of chunks to use for the virtual device, in bytes.
7373
*/
7474
void create_vdev(uint64_t size, HSDevType devType, uint32_t blk_size, blk_allocator_type_t alloc_type,
75-
chunk_selector_type_t chunk_sel_type, uint32_t num_chunks, uint32_t chunk_size);
75+
chunk_selector_type_t chunk_sel_type, uint32_t num_chunks, uint64_t chunk_size);
7676

7777
/**
7878
* @brief Opens a virtual device with the specified virtual device information.

src/include/homestore/index_service.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class IndexService {
6363
// Creates the vdev that is needed to initialize the device
6464
void create_vdev(uint64_t size, HSDevType devType, uint32_t num_chunks,
6565
chunk_selector_type_t chunk_sel_type = chunk_selector_type_t::ROUND_ROBIN,
66-
uint32_t chunk_size = 0);
66+
uint64_t chunk_size = 0);
6767
// Open the existing vdev which is represnted by the vdev_info_block
6868
shared< VirtualDev > open_vdev(const vdev_info& vb, bool load_existing);
6969
std::shared_ptr< ChunkSelector > get_chunk_selector() { return m_custom_chunk_selector; };

src/include/homestore/logstore_service.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class LogStoreService {
160160
*/
161161
void device_truncate();
162162

163-
folly::Future< std::error_code > create_vdev(uint64_t size, HSDevType devType, uint32_t chunk_size);
163+
folly::Future< std::error_code > create_vdev(uint64_t size, HSDevType devType, uint64_t chunk_size);
164164
std::shared_ptr< VirtualDev > open_vdev(const vdev_info& vinfo, bool load_existing);
165165
std::shared_ptr< JournalVirtualDev > get_vdev() const { return m_logdev_vdev; }
166166
std::vector< std::shared_ptr< LogDev > > get_all_logdevs();

src/lib/blkalloc/bitmap_blk_allocator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void BitmapBlkAllocator::cp_flush(CP*) {
5959

6060
if (m_is_disk_bm_dirty.load()) {
6161
sisl::byte_array bitmap_buf = acquire_underlying_buffer();
62+
BLKALLOC_LOG(INFO, "Flushing bitmap (name: {} id: {}) size = {}", get_name(), m_chunk_id, bitmap_buf->size());
6263
if (m_meta_blk_cookie) {
6364
meta_service().update_sub_sb(bitmap_buf->cbytes(), bitmap_buf->size(), m_meta_blk_cookie);
6465
} else {

src/lib/blkdata_svc/blkdata_service.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ BlkDataService::~BlkDataService() = default;
3939

4040
// first-time boot path
4141
void BlkDataService::create_vdev(uint64_t size, HSDevType devType, uint32_t blk_size, blk_allocator_type_t alloc_type,
42-
chunk_selector_type_t chunk_sel_type, uint32_t num_chunks, uint32_t chunk_size) {
42+
chunk_selector_type_t chunk_sel_type, uint32_t num_chunks, uint64_t chunk_size) {
4343
hs_vdev_context vdev_ctx;
4444
vdev_ctx.type = hs_vdev_type_t::DATA_VDEV;
4545

src/lib/device/device.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ struct vdev_info {
4343
uint32_t num_mirrors{0}; // 12: Total number of mirrors
4444
uint32_t blk_size{0}; // 16: IO block size for this vdev
4545
uint32_t num_primary_chunks{0}; // 20: number of primary chunks
46-
uint32_t chunk_size{0}; // 24: chunk size used in vdev.
47-
vdev_size_type_t size_type{}; // 28: Whether its a static or dynamic type.
48-
uint8_t slot_allocated{0}; // 29: Is this current slot allocated
49-
uint8_t failed{0}; // 30: set to true if disk is replaced
50-
uint8_t hs_dev_type{0}; // 31: PDev dev type (as in fast or data)
51-
uint8_t multi_pdev_choice{0}; // 32: Choice when multiple pdevs are present (vdev_multi_pdev_opts_t)
52-
char name[max_name_len]; // 33: Name of the vdev
53-
uint16_t checksum{0}; // 97: Checksum of this entire Block
54-
uint8_t alloc_type; // 98: Allocator type of this vdev
55-
uint8_t chunk_sel_type; // 99: Chunk Selector type of this vdev_id
56-
uint8_t use_slab_allocator{0}; // 100: Use slab allocator for this vdev
57-
uint8_t padding[154]{}; // 101: Padding to make it 256 bytes
46+
uint64_t chunk_size{0}; // 24: chunk size used in vdev.
47+
vdev_size_type_t size_type{}; // 32: Whether its a static or dynamic type.
48+
uint8_t slot_allocated{0}; // 33: Is this current slot allocated
49+
uint8_t failed{0}; // 34: set to true if disk is replaced
50+
uint8_t hs_dev_type{0}; // 35: PDev dev type (as in fast or data)
51+
uint8_t multi_pdev_choice{0}; // 36: Choice when multiple pdevs are present (vdev_multi_pdev_opts_t)
52+
char name[max_name_len]; // 37: Name of the vdev
53+
uint16_t checksum{0}; // 101: Checksum of this entire Block
54+
uint8_t alloc_type; // 102: Allocator type of this vdev
55+
uint8_t chunk_sel_type; // 103: Chunk Selector type of this vdev_id
56+
uint8_t use_slab_allocator{0}; // 104: Use slab allocator for this vdev
57+
uint8_t padding[150]{}; // 105: Padding to make it 256 bytes
5858
uint8_t user_private[user_private_size]{}; // 128: User sepcific information
5959

6060
uint32_t get_vdev_id() const { return vdev_id; }

src/lib/device/device_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ void DeviceManager::compose_vparam(uint64_t vdev_id, vdev_parameters& vparam, st
415415
}
416416

417417
// Based on the min chunk size, we calculate the max number of chunks that can be created in each target pdev
418-
uint32_t min_chunk_size = hs_super_blk::min_chunk_size(vparam.dev_type);
418+
uint64_t min_chunk_size = hs_super_blk::min_chunk_size(vparam.dev_type);
419419
// FIXME: it is possible that each vdev is less than max_num_chunks, but total is more than MAX_CHUNKS_IN_SYSTEM.
420420
// uint32 convert is safe as it only overflow when vdev size > 64PB with 16MB min_chunk_size.
421421
uint32_t max_num_chunks = std::min(uint32_t(vparam.vdev_size / min_chunk_size), hs_super_blk::MAX_CHUNKS_IN_SYSTEM);

src/lib/device/hs_super_blk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class hs_super_blk {
207207
// for a device with 100MB and min_chunk_size = 16MB, we should get 6 chunks, not 7.
208208
return dinfo.dev_size / min_c_size;
209209
}
210-
static uint32_t min_chunk_size(HSDevType dtype) {
210+
static uint64_t min_chunk_size(HSDevType dtype) {
211211
uint64_t min_chunk_size = (dtype == HSDevType::Fast) ? MIN_CHUNK_SIZE_FAST_DEVICE : MIN_CHUNK_SIZE_DATA_DEVICE;
212212
#ifdef _PRERELEASE
213213
auto chunk_size = iomgr_flip::instance()->get_test_flip< long >("set_minimum_chunk_size");

src/lib/index/index_service.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ IndexService::IndexService(std::unique_ptr< IndexServiceCallbacks > cbs, shared<
4545
}
4646

4747
void IndexService::create_vdev(uint64_t size, HSDevType devType, uint32_t num_chunks,
48-
chunk_selector_type_t chunk_sel_type, uint32_t chunk_size) {
48+
chunk_selector_type_t chunk_sel_type, uint64_t chunk_size) {
4949
auto const atomic_page_size = hs()->device_mgr()->atomic_page_size(devType);
5050
hs_vdev_context vdev_ctx;
5151
vdev_ctx.type = hs_vdev_type_t::INDEX_VDEV;

0 commit comments

Comments
 (0)