From 119e67ef2973d1e0264c4c38feb905e1837cbec5 Mon Sep 17 00:00:00 2001 From: Sanal Date: Wed, 4 Oct 2023 17:12:59 -0700 Subject: [PATCH] Adjust num chunks requested in device manager. (#197) Fix timer related asan issue. Disable index btree remove api's as its conflict with cp flush. --- conanfile.py | 2 +- src/lib/checkpoint/cp_mgr.cpp | 7 ++++--- src/lib/device/device_manager.cpp | 13 +++++++++++++ src/lib/device/physical_dev.cpp | 2 +- src/lib/logstore/log_dev.cpp | 5 +++-- src/tests/test_device_manager.cpp | 2 +- src/tests/test_index_btree.cpp | 2 ++ 7 files changed, 25 insertions(+), 8 deletions(-) diff --git a/conanfile.py b/conanfile.py index c0bf4d834..2ca2c687a 100644 --- a/conanfile.py +++ b/conanfile.py @@ -5,7 +5,7 @@ class HomestoreConan(ConanFile): name = "homestore" - version = "4.5.1" + version = "4.5.2" homepage = "https://github.com/eBay/Homestore" description = "HomeStore Storage Engine" diff --git a/src/lib/checkpoint/cp_mgr.cpp b/src/lib/checkpoint/cp_mgr.cpp index 55e43000e..944c90222 100644 --- a/src/lib/checkpoint/cp_mgr.cpp +++ b/src/lib/checkpoint/cp_mgr.cpp @@ -71,6 +71,10 @@ void CPManager::create_first_cp() { } void CPManager::shutdown() { + LOGINFO("Stopping cp timer"); + iomanager.cancel_timer(m_cp_timer_hdl, true); + m_cp_timer_hdl = iomgr::null_timer_handle; + auto cp = get_cur_cp(); delete (cp); rcu_xchg_pointer(&m_cur_cp, nullptr); @@ -79,9 +83,6 @@ void CPManager::shutdown() { m_wd_cp->stop(); m_wd_cp.reset(); } - - iomanager.cancel_timer(m_cp_timer_hdl, true); - m_cp_timer_hdl = iomgr::null_timer_handle; } void CPManager::register_consumer(cp_consumer_t consumer_id, std::unique_ptr< CPCallbacks > callbacks) { diff --git a/src/lib/device/device_manager.cpp b/src/lib/device/device_manager.cpp index 1b06d2fd9..7e0dd40ec 100644 --- a/src/lib/device/device_manager.cpp +++ b/src/lib/device/device_manager.cpp @@ -211,6 +211,19 @@ shared< VirtualDev > DeviceManager::create_vdev(vdev_parameters&& vparam) { LOGINFO("{} Virtual device is attempted to be created with size={}, it needs to be rounded to new_size={}", vparam.vdev_name, in_bytes(input_vdev_size), in_bytes(vparam.vdev_size)); } + + // Adjust the maximum number chunks requested. + uint32_t max_num_chunks = 0; + for (const auto& d : m_dev_infos) { + max_num_chunks += hs_super_blk::max_chunks_in_pdev(d); + } + auto input_num_chunks = vparam.num_chunks; + vparam.num_chunks = std::min(vparam.num_chunks, max_num_chunks); + if (input_num_chunks != vparam.num_chunks) { + LOGINFO("{} Virtual device is attempted to be created with num_chunks={}, it needs to be adjust to " + "new_num_chunks={}", + vparam.vdev_name, in_bytes(input_num_chunks), in_bytes(vparam.num_chunks)); + } uint32_t chunk_size = vparam.vdev_size / vparam.num_chunks; LOGINFO( diff --git a/src/lib/device/physical_dev.cpp b/src/lib/device/physical_dev.cpp index 122f735d8..33f243824 100644 --- a/src/lib/device/physical_dev.cpp +++ b/src/lib/device/physical_dev.cpp @@ -427,7 +427,7 @@ void PhysicalDev::free_chunk_info(chunk_info* cinfo) { } ChunkInterval PhysicalDev::find_next_chunk_area(uint64_t size) const { - auto ins_ival = ChunkInterval::right_open(data_start_offset(), size); + auto ins_ival = ChunkInterval::right_open(data_start_offset(), data_start_offset() + size); for (auto& exist_ival : m_chunk_data_area) { if (ins_ival.upper() <= exist_ival.lower()) { break; } ins_ival = ChunkInterval::right_open(exist_ival.upper(), exist_ival.upper() + size); diff --git a/src/lib/logstore/log_dev.cpp b/src/lib/logstore/log_dev.cpp index 3dae46bbd..b8ea1e2ef 100644 --- a/src/lib/logstore/log_dev.cpp +++ b/src/lib/logstore/log_dev.cpp @@ -121,6 +121,9 @@ void LogDev::stop() { m_block_flush_q_cv.wait(lk, [&] { return m_stopped; }); } + // cancel the timer + iomanager.cancel_timer(m_flush_timer_hdl, true); + m_log_records = nullptr; m_logdev_meta.reset(); m_log_idx.store(0); @@ -137,8 +140,6 @@ void LogDev::stop() { } THIS_LOGDEV_LOG(INFO, "LogDev stopped successfully"); - // cancel the timer - iomanager.cancel_timer(m_flush_timer_hdl, true); m_hs.reset(); } diff --git a/src/tests/test_device_manager.cpp b/src/tests/test_device_manager.cpp index d54e31a65..8b1363688 100644 --- a/src/tests/test_device_manager.cpp +++ b/src/tests/test_device_manager.cpp @@ -140,7 +140,7 @@ TEST_F(DeviceMgrTest, StripedVDevCreation) { avail_size += pdev->data_size(); } - uint32_t size_pct = 4; + uint32_t size_pct = 2; uint64_t remain_size = avail_size; LOGINFO("Step 1: Creating {} vdevs with combined size as {}", in_bytes(avail_size)); diff --git a/src/tests/test_index_btree.cpp b/src/tests/test_index_btree.cpp index 4463ebbd4..5de8b3126 100644 --- a/src/tests/test_index_btree.cpp +++ b/src/tests/test_index_btree.cpp @@ -412,6 +412,7 @@ TYPED_TEST(BtreeTest, RandomInsert) { this->get_all_validate(); } +#if 0 TYPED_TEST(BtreeTest, SequentialRemove) { LOGINFO("SequentialRemove test start"); // Forward sequential insert @@ -466,6 +467,7 @@ TYPED_TEST(BtreeTest, RandomRemove) { } this->get_all_validate(); } +#endif TYPED_TEST(BtreeTest, RangeUpdate) { LOGINFO("RangeUpdate test start");