Skip to content

Commit

Permalink
feed num_chunks to create_vdev (#195)
Browse files Browse the repository at this point in the history
* feed num_chunks to create_vdev

* inc con ver
  • Loading branch information
yamingk authored Sep 29, 2023
1 parent f2a82df commit 0a878d4
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/include/homestore/blkdata_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/include/homestore/index_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/include/homestore/logstore_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/include/homestore/meta_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/blkdata_svc/blkdata_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ 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;

if (blk_size == 0) { blk_size = hs()->device_mgr()->optimal_page_size(HSDevType::Data); }
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,
Expand Down
12 changes: 6 additions & 6 deletions src/lib/homestore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/index/index_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions src/lib/logstore/log_store_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/meta/meta_blk_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ 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;
meta_ctx.type = hs_vdev_type_t::META_VDEV;

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,
Expand Down

0 comments on commit 0a878d4

Please sign in to comment.