From 0a878d4394b97348121d120fd6ac7f0365c5f265 Mon Sep 17 00:00:00 2001 From: Yaming Kuang <1477567+yamingk@users.noreply.github.com> Date: Fri, 29 Sep 2023 15:39:58 -0700 Subject: [PATCH] feed num_chunks to create_vdev (#195) * feed num_chunks to create_vdev * inc con ver --- src/include/homestore/blkdata_service.hpp | 2 +- src/include/homestore/index_service.hpp | 2 +- src/include/homestore/logstore_service.hpp | 2 +- src/include/homestore/meta_service.hpp | 2 +- src/lib/blkdata_svc/blkdata_service.cpp | 4 ++-- src/lib/homestore.cpp | 12 ++++++------ src/lib/index/index_service.cpp | 4 ++-- src/lib/logstore/log_store_service.cpp | 5 +++-- src/lib/meta/meta_blk_service.cpp | 4 ++-- 9 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/include/homestore/blkdata_service.hpp b/src/include/homestore/blkdata_service.hpp index faac2e426..00e569e1f 100644 --- a/src/include/homestore/blkdata_service.hpp +++ b/src/include/homestore/blkdata_service.hpp @@ -47,7 +47,7 @@ class BlkDataService { * @param size : size of this vdev */ void create_vdev(uint64_t size, uint32_t blk_size, blk_allocator_type_t alloc_type, - chunk_selector_type_t chunk_sel_type); + chunk_selector_type_t chunk_sel_type, uint32_t num_chunks); /** * @brief : called during recovery to open existing vdev for data service diff --git a/src/include/homestore/index_service.hpp b/src/include/homestore/index_service.hpp index b4f551a8e..466c52cdb 100644 --- a/src/include/homestore/index_service.hpp +++ b/src/include/homestore/index_service.hpp @@ -51,7 +51,7 @@ class IndexService { IndexService(std::unique_ptr< IndexServiceCallbacks > cbs); // Creates the vdev that is needed to initialize the device - void create_vdev(uint64_t size); + void create_vdev(uint64_t size, uint32_t num_chunks); // Open the existing vdev which is represnted by the vdev_info_block shared< VirtualDev > open_vdev(const vdev_info& vb, bool load_existing); diff --git a/src/include/homestore/logstore_service.hpp b/src/include/homestore/logstore_service.hpp index 3f1d62958..506eff5ba 100644 --- a/src/include/homestore/logstore_service.hpp +++ b/src/include/homestore/logstore_service.hpp @@ -135,7 +135,7 @@ class LogStoreService { void device_truncate(const device_truncate_cb_t& cb = nullptr, const bool wait_till_done = false, const bool dry_run = false); - folly::Future< std::error_code > create_vdev(uint64_t size, logstore_family_id_t family); + folly::Future< std::error_code > create_vdev(uint64_t size, logstore_family_id_t family, uint32_t num_chunks); shared< VirtualDev > open_vdev(const vdev_info& vinfo, logstore_family_id_t family, bool load_existing); shared< JournalVirtualDev > get_vdev(logstore_family_id_t family) const { return (family == DATA_LOG_FAMILY_IDX) ? m_data_logdev_vdev : m_ctrl_logdev_vdev; diff --git a/src/include/homestore/meta_service.hpp b/src/include/homestore/meta_service.hpp index b6b5c9b4c..cb2c65e25 100644 --- a/src/include/homestore/meta_service.hpp +++ b/src/include/homestore/meta_service.hpp @@ -98,7 +98,7 @@ class MetaBlkService { ~MetaBlkService() = default; // Creates the vdev that is needed to initialize the device - void create_vdev(uint64_t size); + void create_vdev(uint64_t size, uint32_t num_chunks); // Open the existing vdev which is represented by the vdev_info shared< VirtualDev > open_vdev(const vdev_info& vinfo, bool load_existing); diff --git a/src/lib/blkdata_svc/blkdata_service.cpp b/src/lib/blkdata_svc/blkdata_service.cpp index 6a596eb54..8a260ecdb 100644 --- a/src/lib/blkdata_svc/blkdata_service.cpp +++ b/src/lib/blkdata_svc/blkdata_service.cpp @@ -38,7 +38,7 @@ BlkDataService::~BlkDataService() = default; // first-time boot path void BlkDataService::create_vdev(uint64_t size, uint32_t blk_size, blk_allocator_type_t alloc_type, - chunk_selector_type_t chunk_sel_type) { + chunk_selector_type_t chunk_sel_type, uint32_t num_chunks) { hs_vdev_context vdev_ctx; vdev_ctx.type = hs_vdev_type_t::DATA_VDEV; @@ -46,7 +46,7 @@ void BlkDataService::create_vdev(uint64_t size, uint32_t blk_size, blk_allocator m_vdev = hs()->device_mgr()->create_vdev(vdev_parameters{.vdev_name = "blkdata", .vdev_size = size, - .num_chunks = 1, + .num_chunks = num_chunks, .blk_size = blk_size, .dev_type = HSDevType::Data, .alloc_type = alloc_type, diff --git a/src/lib/homestore.cpp b/src/lib/homestore.cpp index 92efbe652..699b61927 100644 --- a/src/lib/homestore.cpp +++ b/src/lib/homestore.cpp @@ -153,21 +153,21 @@ void HomeStore::format_and_start(std::map< uint32_t, hs_format_params >&& format if (fparams.size_pct == 0) { continue; } if ((svc_type & HS_SERVICE::META) && has_meta_service()) { - m_meta_service->create_vdev(pct_to_size(fparams.size_pct, HSDevType::Fast)); + m_meta_service->create_vdev(pct_to_size(fparams.size_pct, HSDevType::Fast), fparams.num_chunks); } else if ((svc_type & HS_SERVICE::LOG_REPLICATED) && has_log_service()) { futs.emplace_back(m_log_service->create_vdev(pct_to_size(fparams.size_pct, HSDevType::Fast), - LogStoreService::DATA_LOG_FAMILY_IDX)); + LogStoreService::DATA_LOG_FAMILY_IDX, fparams.num_chunks)); } else if ((svc_type & HS_SERVICE::LOG_LOCAL) && has_log_service()) { futs.emplace_back(m_log_service->create_vdev(pct_to_size(fparams.size_pct, HSDevType::Fast), - LogStoreService::CTRL_LOG_FAMILY_IDX)); + LogStoreService::CTRL_LOG_FAMILY_IDX, fparams.num_chunks)); } else if ((svc_type & HS_SERVICE::DATA) && has_data_service()) { m_data_service->create_vdev(pct_to_size(fparams.size_pct, HSDevType::Data), fparams.block_size, - fparams.alloc_type, fparams.chunk_sel_type); + fparams.alloc_type, fparams.chunk_sel_type, fparams.num_chunks); } else if ((svc_type & HS_SERVICE::INDEX) && has_index_service()) { - m_index_service->create_vdev(pct_to_size(fparams.size_pct, HSDevType::Fast)); + m_index_service->create_vdev(pct_to_size(fparams.size_pct, HSDevType::Fast), fparams.num_chunks); } else if ((svc_type & HS_SERVICE::REPLICATION) && has_repl_data_service()) { m_data_service->create_vdev(pct_to_size(fparams.size_pct, HSDevType::Data), fparams.block_size, - fparams.alloc_type, fparams.chunk_sel_type); + fparams.alloc_type, fparams.chunk_sel_type, fparams.num_chunks); } } diff --git a/src/lib/index/index_service.cpp b/src/lib/index/index_service.cpp index 4769a6d67..602026114 100644 --- a/src/lib/index/index_service.cpp +++ b/src/lib/index/index_service.cpp @@ -35,14 +35,14 @@ IndexService::IndexService(std::unique_ptr< IndexServiceCallbacks > cbs) : m_svc nullptr); } -void IndexService::create_vdev(uint64_t size) { +void IndexService::create_vdev(uint64_t size, uint32_t num_chunks) { auto const atomic_page_size = hs()->device_mgr()->atomic_page_size(HSDevType::Fast); hs_vdev_context vdev_ctx; vdev_ctx.type = hs_vdev_type_t::INDEX_VDEV; hs()->device_mgr()->create_vdev(vdev_parameters{.vdev_name = "index", .vdev_size = size, - .num_chunks = 1, + .num_chunks = num_chunks, .blk_size = atomic_page_size, .dev_type = HSDevType::Fast, .alloc_type = blk_allocator_type_t::fixed, diff --git a/src/lib/logstore/log_store_service.cpp b/src/lib/logstore/log_store_service.cpp index 02f223131..931e11b44 100644 --- a/src/lib/logstore/log_store_service.cpp +++ b/src/lib/logstore/log_store_service.cpp @@ -42,7 +42,8 @@ LogStoreService::LogStoreService() : m_logstore_families{std::make_unique< LogStoreFamily >(DATA_LOG_FAMILY_IDX), std::make_unique< LogStoreFamily >(CTRL_LOG_FAMILY_IDX)} {} -folly::Future< std::error_code > LogStoreService::create_vdev(uint64_t size, logstore_family_id_t family) { +folly::Future< std::error_code > LogStoreService::create_vdev(uint64_t size, logstore_family_id_t family, + uint32_t num_chunks) { const auto atomic_page_size = hs()->device_mgr()->atomic_page_size(HSDevType::Fast); hs_vdev_context hs_ctx; @@ -62,7 +63,7 @@ folly::Future< std::error_code > LogStoreService::create_vdev(uint64_t size, log auto vdev = hs()->device_mgr()->create_vdev(vdev_parameters{.vdev_name = name, .vdev_size = size, - .num_chunks = 1, + .num_chunks = num_chunks, .blk_size = atomic_page_size, .dev_type = HSDevType::Fast, .alloc_type = blk_allocator_type_t::none, diff --git a/src/lib/meta/meta_blk_service.cpp b/src/lib/meta/meta_blk_service.cpp index 85b39fef9..510033dfa 100644 --- a/src/lib/meta/meta_blk_service.cpp +++ b/src/lib/meta/meta_blk_service.cpp @@ -47,7 +47,7 @@ MetaBlkService& meta_service() { return hs()->meta_service(); } MetaBlkService::MetaBlkService(const char* name) : m_metrics{name} { m_last_mblk_id = std::make_unique< BlkId >(); } -void MetaBlkService::create_vdev(uint64_t size) { +void MetaBlkService::create_vdev(uint64_t size, uint32_t num_chunks) { const auto phys_page_size = hs()->device_mgr()->optimal_page_size(HSDevType::Fast); meta_vdev_context meta_ctx; @@ -55,7 +55,7 @@ void MetaBlkService::create_vdev(uint64_t size) { hs()->device_mgr()->create_vdev(vdev_parameters{.vdev_name = "meta", .vdev_size = size, - .num_chunks = 1, + .num_chunks = num_chunks, .blk_size = phys_page_size, .dev_type = HSDevType::Fast, .alloc_type = blk_allocator_type_t::varsize,