Skip to content

Commit

Permalink
create_vdev take device type parameters.
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxi Chen <[email protected]>
  • Loading branch information
xiaoxichen committed Mar 19, 2024
1 parent 4c674bf commit fd75dc0
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 26 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 @@ -65,7 +65,7 @@ class BlkDataService {
* @param chunk_sel_type The type of chunk selector to use for the virtual device.
* @param num_chunks The number of chunks to use for the virtual device.
*/
void create_vdev(uint64_t size, uint32_t blk_size, blk_allocator_type_t alloc_type,
void create_vdev(uint64_t size, HSDevType devType, uint32_t blk_size, blk_allocator_type_t alloc_type,
chunk_selector_type_t chunk_sel_type, uint32_t num_chunks);

/**
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, uint32_t num_chunks);
void create_vdev(uint64_t size, HSDevType devType, 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 @@ -144,7 +144,7 @@ class LogStoreService {
*/
void device_truncate(const device_truncate_cb_t& cb = nullptr, bool wait_till_done = false, bool dry_run = false);

folly::Future< std::error_code > create_vdev(uint64_t size, uint32_t chunk_size);
folly::Future< std::error_code > create_vdev(uint64_t size, HSDevType devType, uint32_t chunk_size);
std::shared_ptr< VirtualDev > open_vdev(const vdev_info& vinfo, bool load_existing);
std::shared_ptr< JournalVirtualDev > get_vdev() const { return m_logdev_vdev; }
std::vector< std::shared_ptr< LogDev > > get_all_logdevs();
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 @@ -103,7 +103,7 @@ class MetaBlkService {
~MetaBlkService() = default;

// Creates the vdev that is needed to initialize the device
void create_vdev(uint64_t size, uint32_t num_chunks);
void create_vdev(uint64_t size, HSDevType devType, 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
6 changes: 3 additions & 3 deletions src/lib/blkdata_svc/blkdata_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ BlkDataService::BlkDataService(shared< ChunkSelector > chunk_selector) :
BlkDataService::~BlkDataService() = default;

// first-time boot path
void BlkDataService::create_vdev(uint64_t size, uint32_t blk_size, blk_allocator_type_t alloc_type,
void BlkDataService::create_vdev(uint64_t size, HSDevType devType, uint32_t blk_size, blk_allocator_type_t alloc_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); }
if (blk_size == 0) { blk_size = hs()->device_mgr()->optimal_page_size(devType); }
m_vdev =
hs()->device_mgr()->create_vdev(vdev_parameters{.vdev_name = "blkdata",
.vdev_size = size,
.num_chunks = num_chunks,
.blk_size = blk_size,
.dev_type = HSDevType::Data,
.dev_type = devType,
.alloc_type = alloc_type,
.chunk_sel_type = chunk_sel_type,
.multi_pdev_opts = vdev_multi_pdev_opts_t::ALL_PDEV_STRIPED,
Expand Down
24 changes: 14 additions & 10 deletions src/lib/homestore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void HomeStore::format_and_start(std::map< uint32_t, hs_format_params >&& format
// Sanity check, each type accumulated pct <=100%
auto all_pct = 0;
for (const auto& [DevType, total_pct] : total_pct_by_type) {
all_pct + = total_pct;
all_pct += total_pct;
if (total_pct > 100.0f) {
LOGERROR("Total percentage of services on Device type {} is greater than 100.0f, total_pct_sum={}", DevType,
total_pct);
Expand Down Expand Up @@ -212,19 +212,23 @@ 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), fparams.num_chunks);
m_meta_service->create_vdev(pct_to_size(fparams.size_pct, fparams.dev_type), fparams.dev_type,
fparams.num_chunks);

} else if ((svc_type & HS_SERVICE::LOG) && has_log_service()) {
futs.emplace_back(
m_log_service->create_vdev(pct_to_size(fparams.size_pct, HSDevType::Fast), fparams.chunk_size));
} 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.num_chunks);
futs.emplace_back(m_log_service->create_vdev(pct_to_size(fparams.size_pct, fparams.dev_type),
fparams.dev_type, fparams.chunk_size));
} else if ((svc_type & HS_SERVICE::INDEX) && has_index_service()) {
m_index_service->create_vdev(pct_to_size(fparams.size_pct, HSDevType::Fast), fparams.num_chunks);
m_index_service->create_vdev(pct_to_size(fparams.size_pct, fparams.dev_type), fparams.dev_type,
fparams.num_chunks);
} else if ((svc_type & HS_SERVICE::DATA) && has_data_service()) {
m_data_service->create_vdev(pct_to_size(fparams.size_pct, fparams.dev_type), fparams.dev_type,
fparams.block_size, fparams.alloc_type, fparams.chunk_sel_type,
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.num_chunks);
m_data_service->create_vdev(pct_to_size(fparams.size_pct, fparams.dev_type), fparams.dev_type,
fparams.block_size, fparams.alloc_type, fparams.chunk_sel_type,
fparams.num_chunks);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib/index/index_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ IndexService::IndexService(std::unique_ptr< IndexServiceCallbacks > cbs) : m_svc
nullptr);
}

void IndexService::create_vdev(uint64_t size, uint32_t num_chunks) {
auto const atomic_page_size = hs()->device_mgr()->atomic_page_size(HSDevType::Fast);
void IndexService::create_vdev(uint64_t size, HSDevType devType, uint32_t num_chunks) {
auto const atomic_page_size = hs()->device_mgr()->atomic_page_size(devType);
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 = num_chunks,
.blk_size = atomic_page_size,
.dev_type = HSDevType::Fast,
.dev_type = devType,
.alloc_type = blk_allocator_type_t::fixed,
.chunk_sel_type = chunk_selector_type_t::ROUND_ROBIN,
.multi_pdev_opts = vdev_multi_pdev_opts_t::ALL_PDEV_STRIPED,
Expand Down
6 changes: 3 additions & 3 deletions src/lib/logstore/log_store_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ LogStoreService::LogStoreService() {
nullptr);
}

folly::Future< std::error_code > LogStoreService::create_vdev(uint64_t size, uint32_t chunk_size) {
const auto atomic_page_size = hs()->device_mgr()->atomic_page_size(HSDevType::Fast);
folly::Future< std::error_code > LogStoreService::create_vdev(uint64_t size, HSDevType devType, uint32_t chunk_size) {
const auto atomic_page_size = hs()->device_mgr()->atomic_page_size(devType);

hs_vdev_context hs_ctx;
hs_ctx.type = hs_vdev_type_t::LOGDEV_VDEV;
Expand All @@ -78,7 +78,7 @@ folly::Future< std::error_code > LogStoreService::create_vdev(uint64_t size, uin
.num_chunks = 0,
.blk_size = atomic_page_size,
.chunk_size = chunk_size,
.dev_type = HSDevType::Fast,
.dev_type = devType,
.alloc_type = blk_allocator_type_t::none,
.chunk_sel_type = chunk_selector_type_t::ROUND_ROBIN,
.multi_pdev_opts = vdev_multi_pdev_opts_t::ALL_PDEV_STRIPED,
Expand Down
6 changes: 3 additions & 3 deletions src/lib/meta/meta_blk_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ 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, uint32_t num_chunks) {
const auto phys_page_size = hs()->device_mgr()->optimal_page_size(HSDevType::Fast);
void MetaBlkService::create_vdev(uint64_t size, HSDevType devType, uint32_t num_chunks) {
const auto phys_page_size = hs()->device_mgr()->optimal_page_size(devType);

meta_vdev_context meta_ctx;
meta_ctx.type = hs_vdev_type_t::META_VDEV;
Expand All @@ -56,7 +56,7 @@ void MetaBlkService::create_vdev(uint64_t size, uint32_t num_chunks) {
.vdev_size = size,
.num_chunks = num_chunks,
.blk_size = phys_page_size,
.dev_type = HSDevType::Fast,
.dev_type = devType,
.alloc_type = blk_allocator_type_t::varsize,
.chunk_sel_type = chunk_selector_type_t::ROUND_ROBIN,
.multi_pdev_opts = vdev_multi_pdev_opts_t::ALL_PDEV_STRIPED,
Expand Down

0 comments on commit fd75dc0

Please sign in to comment.