Skip to content

Commit db2ae04

Browse files
authored
Issue 85: Expose data service drive type info to BM (#87)
* Issue 85: expose storage info * Issue 85: expose storage info * Issue 85: HomeBlks to expose data service drive info * con ver
1 parent 6660487 commit db2ae04

File tree

6 files changed

+65
-49
lines changed

6 files changed

+65
-49
lines changed

conanfile.py

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

1010
class HomeBlocksConan(ConanFile):
1111
name = "homeblocks"
12-
version = "0.0.14"
12+
version = "0.0.15"
1313
homepage = "https://github.com/eBay/HomeBlocks"
1414
description = "Block Store built on HomeStore"
1515
topics = ("ebay")

src/include/homeblks/home_blks.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#pragma once
1616

1717
#include <list>
18-
18+
#include <iomgr/iomgr_types.hpp>
1919
#include <sisl/utility/enum.hpp>
2020

2121
#include "common.hpp"
@@ -77,6 +77,7 @@ class HomeBlocks {
7777
virtual peer_id_t our_uuid() const = 0;
7878
virtual std::shared_ptr< VolumeManager > volume_manager() = 0;
7979
virtual HomeBlocksStats get_stats() const = 0;
80+
virtual iomgr::drive_type data_drive_type() const = 0;
8081
};
8182

8283
extern std::shared_ptr< HomeBlocks > init_homeblocks(std::weak_ptr< HomeBlocksApplication >&& application);

src/lib/homeblks_impl.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ extern std::shared_ptr< HomeBlocks > init_homeblocks(std::weak_ptr< HomeBlocksAp
3838
return inst;
3939
}
4040

41+
iomgr::drive_type HomeBlocksImpl::data_drive_type() const {
42+
auto const dtype = homestore::hs()->data_service().get_dev_type();
43+
if (dtype == homestore::HSDevType::Data) {
44+
return iomgr::drive_type::block_hdd;
45+
} else if (dtype == homestore::HSDevType::Fast) {
46+
return iomgr::drive_type::block_nvme;
47+
} else {
48+
return iomgr::drive_type::unknown;
49+
}
50+
}
51+
4152
HomeBlocksStats HomeBlocksImpl::get_stats() const {
4253
auto const stats = homestore::hs()->repl_service().get_cap_stats();
4354
return {stats.total_capacity, stats.used_capacity};

src/lib/homeblks_impl.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class HomeBlocksImpl : public HomeBlocks, public VolumeManager, public std::enab
8282
/// HomeBlocks
8383
/// Returns the UUID of this HomeBlocks.
8484
HomeBlocksStats get_stats() const final;
85+
iomgr::drive_type data_drive_type() const final;
86+
8587
peer_id_t our_uuid() const final {
8688
// not expected to be called;
8789
return peer_id_t{};
@@ -94,17 +96,14 @@ class HomeBlocksImpl : public HomeBlocks, public VolumeManager, public std::enab
9496

9597
VolumePtr lookup_volume(const volume_id_t& id) final;
9698

97-
NullAsyncResult write(const VolumePtr& vol, const vol_interface_req_ptr& req,
98-
bool part_of_batch = false) final;
99+
NullAsyncResult write(const VolumePtr& vol, const vol_interface_req_ptr& req, bool part_of_batch = false) final;
99100

100-
NullAsyncResult read(const VolumePtr& vol, const vol_interface_req_ptr& req,
101-
bool part_of_batch = false) final;
101+
NullAsyncResult read(const VolumePtr& vol, const vol_interface_req_ptr& req, bool part_of_batch = false) final;
102102

103103
NullAsyncResult unmap(const VolumePtr& vol, const vol_interface_req_ptr& req) final;
104104

105105
void submit_io_batch() final;
106106

107-
108107
// see api comments in base class;
109108
bool get_stats(volume_id_t id, VolumeStats& stats) const final;
110109
void get_volume_ids(std::vector< volume_id_t >& vol_ids) const final;

src/lib/volume/tests/test_volume.cpp

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class VolumeTest : public ::testing::Test {
6565
#endif
6666
};
6767

68-
TEST_F(VolumeTest, CreateVolumeThenRecover) {
68+
TEST_F(VolumeTest, CreateDestroyVolume) {
6969
std::vector< volume_id_t > vol_ids;
7070
{
7171
auto hb = g_helper->inst();
@@ -86,29 +86,25 @@ TEST_F(VolumeTest, CreateVolumeThenRecover) {
8686
}
8787

8888
auto const s = hb->get_stats();
89-
LOGINFO("Stats: {}", s.to_string());
90-
}
91-
92-
g_helper->restart(5);
89+
auto const dtype = hb->data_drive_type();
90+
LOGINFO("Stats: {}, drive_type: {}", s.to_string(), dtype);
9391

94-
// verify the volumes are still there
95-
{
96-
auto hb = g_helper->inst();
97-
auto vol_mgr = hb->volume_manager();
98-
99-
for (const auto& id : vol_ids) {
92+
for (uint32_t i = 0; i < num_vols; ++i) {
93+
auto id = vol_ids[i];
94+
auto ret = vol_mgr->remove_volume(id).get();
95+
ASSERT_TRUE(ret);
96+
// sleep for a while
97+
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
10098
auto vinfo_ptr = vol_mgr->lookup_volume(id);
101-
// verify the volume is there
102-
ASSERT_TRUE(vinfo_ptr != nullptr);
99+
// verify the volume is not there
100+
ASSERT_TRUE(vinfo_ptr == nullptr);
103101
}
104102
}
105-
}
106103

107-
TEST_F(VolumeTest, DestroyVolumeCrashRecovery) {
104+
g_helper->restart(5);
105+
}
108106

109-
#ifdef _PRERELEASE
110-
set_flip_point("vol_destroy_crash_simulation");
111-
#endif
107+
TEST_F(VolumeTest, CreateVolumeThenRecover) {
112108
std::vector< volume_id_t > vol_ids;
113109
{
114110
auto hb = g_helper->inst();
@@ -127,18 +123,28 @@ TEST_F(VolumeTest, DestroyVolumeCrashRecovery) {
127123
// verify the volume is there
128124
ASSERT_TRUE(vinfo_ptr != nullptr);
129125
}
130-
131-
for (uint32_t i = 0; i < num_vols; ++i) {
132-
auto id = vol_ids[i];
133-
auto ret = vol_mgr->remove_volume(id).get();
134-
ASSERT_TRUE(ret);
135-
}
136126
}
137127

138128
g_helper->restart(5);
129+
130+
// verify the volumes are still there
131+
{
132+
auto hb = g_helper->inst();
133+
auto vol_mgr = hb->volume_manager();
134+
135+
for (const auto& id : vol_ids) {
136+
auto vinfo_ptr = vol_mgr->lookup_volume(id);
137+
// verify the volume is there
138+
ASSERT_TRUE(vinfo_ptr != nullptr);
139+
}
140+
}
139141
}
140142

141-
TEST_F(VolumeTest, CreateDestroyVolume) {
143+
TEST_F(VolumeTest, DestroyVolumeCrashRecovery) {
144+
145+
#ifdef _PRERELEASE
146+
set_flip_point("vol_destroy_crash_simulation");
147+
#endif
142148
std::vector< volume_id_t > vol_ids;
143149
{
144150
auto hb = g_helper->inst();
@@ -162,13 +168,10 @@ TEST_F(VolumeTest, CreateDestroyVolume) {
162168
auto id = vol_ids[i];
163169
auto ret = vol_mgr->remove_volume(id).get();
164170
ASSERT_TRUE(ret);
165-
// sleep for a while
166-
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
167-
auto vinfo_ptr = vol_mgr->lookup_volume(id);
168-
// verify the volume is not there
169-
ASSERT_TRUE(vinfo_ptr == nullptr);
170171
}
171172
}
173+
174+
g_helper->restart(5);
172175
}
173176

174177
int main(int argc, char* argv[]) {

src/lib/volume/volume.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,14 @@ bool Volume::init(bool is_recovery) {
8080
auto ret = homestore::hs()->repl_service().get_repl_dev(id());
8181

8282
if (ret.hasError()) {
83-
LOGE("Failed to get repl dev for volume name: {}, uuid: {}, error: {}", vol_info_->name,
84-
boost::uuids::to_string(vol_info_->id), ret.error());
85-
DEBUG_ASSERT(false, "Failed to get repl dev for volume");
86-
return false;
83+
LOGI("Volume in destroying state? Failed to get repl dev for volume name: {}, uuid: {}, error: {}",
84+
vol_info_->name, boost::uuids::to_string(vol_info_->id), ret.error());
85+
rd_ = nullptr;
86+
// DEBUG_ASSERT(false, "Failed to get repl dev for volume");
87+
// return false;
88+
} else {
89+
rd_ = ret.value();
8790
}
88-
rd_ = ret.value();
8991

9092
// index table will be recovered via in subsequent callback with init_index_table API;
9193
}
@@ -96,6 +98,13 @@ void Volume::destroy() {
9698
// 0. Set destroying state in superblock;
9799
state_change(vol_state::DESTROYING);
98100

101+
// 1. destroy the repl dev;
102+
if (rd_) {
103+
LOGI("Destroying repl dev for volume: {}, uuid: {}", vol_info_->name, boost::uuids::to_string(id()));
104+
homestore::hs()->repl_service().remove_repl_dev(id()).get();
105+
rd_ = nullptr;
106+
}
107+
99108
#ifdef _PRERELEASE
100109
if (iomgr_flip::instance()->test_flip("vol_destroy_crash_simulation")) {
101110
// this is to simulate crash during volume destroy;
@@ -105,13 +114,6 @@ void Volume::destroy() {
105114
}
106115
#endif
107116

108-
// 1. destroy the repl dev;
109-
if (rd_) {
110-
LOGI("Destroying repl dev for volume: {}, uuid: {}", vol_info_->name, boost::uuids::to_string(id()));
111-
homestore::hs()->repl_service().remove_repl_dev(id()).get();
112-
rd_ = nullptr;
113-
}
114-
115117
// 2. destroy the index table;
116118
if (indx_tbl_) {
117119
LOGI("Destroying index table for volume: {}, uuid: {}", vol_info_->name, boost::uuids::to_string(id()));

0 commit comments

Comments
 (0)