Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class HomeBlocksConan(ConanFile):
name = "homeblocks"
version = "0.0.15"
version = "1.0.15"
homepage = "https://github.com/eBay/HomeBlocks"
description = "Block Store built on HomeStore"
topics = ("ebay")
Expand Down
2 changes: 1 addition & 1 deletion src/include/homeblks/home_blks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class HomeBlocksApplication {
virtual uint64_t app_mem_size() const = 0;

// Callback made after determining if a SvcId exists or not during initialization, will consume response
virtual peer_id_t discover_svcid(std::optional< peer_id_t > const& found) const = 0;
virtual std::optional< peer_id_t > discover_svc_id(std::optional< peer_id_t > const& found) const = 0;
};

struct HomeBlocksStats {
Expand Down
24 changes: 20 additions & 4 deletions src/lib/homeblks_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
*
*********************************************************************************/
#include <algorithm>

#include <boost/uuid/uuid.hpp>
#include <boost/uuid/nil_generator.hpp>
#include <iomgr/io_environment.hpp>
#include <homestore/homestore.hpp>
#include <homestore/replication_service.hpp>
Expand Down Expand Up @@ -119,8 +120,8 @@ class HBReplApp : public homestore::ReplApplication {

homestore::replica_id_t get_my_repl_id() const override { return hb_->our_uuid(); }

void destroy_repl_dev_listener(homestore::group_id_t) override {
LOGERROR("destroy_repl_dev_listener Unimplimented");
void destroy_repl_dev_listener(homestore::group_id_t gid) override {
LOGI("Destroying repl dev listener for group_id {}", boost::uuids::to_string(gid));
}

private:
Expand Down Expand Up @@ -182,7 +183,11 @@ void HomeBlocksImpl::init_homestore() {
.start(hs_input_params{.devices = device_info, .app_mem_size = app_mem_size},
[this]() { register_metablk_cb(); });
if (need_format) {
LOGI("We are starting for the first time. Formatting HomeStore. ");
auto ret = app->discover_svc_id(std::nullopt);
DEBUG_ASSERT(ret.has_value(), "UUID should be generated by application.");
our_uuid_ = ret.value();
LOGINFO("We are starting for the first time on svc_id: [{}]. Formatting HomeStore. ",
boost::uuids::to_string(our_uuid()));
if (has_data_dev && has_fast_dev) {
// NOTE: chunk_size, num_chunks only has to specify one, can be deduced from each other.
homestore::hs()->format_and_start({
Expand Down Expand Up @@ -216,6 +221,12 @@ void HomeBlocksImpl::init_homestore() {
}
// repl_app->on_repl_devs_init_completed();
superblk_init();
} else {
// we are starting on an existing system;
DEBUG_ASSERT(our_uuid() != boost::uuids::nil_uuid(), "UUID should be recovered from HB superblock!");
// now callback to application to nofity the uuid so that we are treated as an existing system;
app->discover_svc_id(our_uuid());
LOGINFO("We are starting on [{}].", boost::uuids::to_string(our_uuid_));
}

recovery_done_ = true;
Expand All @@ -228,6 +239,7 @@ void HomeBlocksImpl::superblk_init() {
sb_->version = HB_SB_VER;
sb_->boot_cnt = 0;
sb_->init_flag(0);
sb_->svc_id = our_uuid_;
sb_.write();
}

Expand All @@ -247,6 +259,10 @@ void HomeBlocksImpl::on_hb_meta_blk_found(sisl::byte_view const& buf, void* cook

++sb_->boot_cnt;

our_uuid_ = sb_->svc_id;

LOGI("HomeBlks superblock loaded, boot_cnt: {}, svc_id: {}", sb_->boot_cnt, boost::uuids::to_string(our_uuid_));

// avoid doing sb meta blk write in callback which will cause deadlock;
// the 1st CP should flush all dirty SB before taking traffic;
}
Expand Down
7 changes: 3 additions & 4 deletions src/lib/homeblks_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class HomeBlocksImpl : public HomeBlocks, public VolumeManager, public std::enab
uint32_t version;
uint32_t flag;
uint64_t boot_cnt;
peer_id_t svc_id;

void init_flag(uint32_t f) { flag = f; }
void set_flag(uint32_t bit) { flag |= bit; }
Expand Down Expand Up @@ -67,6 +68,7 @@ class HomeBlocksImpl : public HomeBlocks, public VolumeManager, public std::enab

bool recovery_done_{false};
superblk< homeblks_sb_t > sb_;
peer_id_t our_uuid_;

public:
explicit HomeBlocksImpl(std::weak_ptr< HomeBlocksApplication >&& application);
Expand All @@ -84,10 +86,7 @@ class HomeBlocksImpl : public HomeBlocks, public VolumeManager, public std::enab
HomeBlocksStats get_stats() const final;
iomgr::drive_type data_drive_type() const final;

peer_id_t our_uuid() const final {
// not expected to be called;
return peer_id_t{};
}
peer_id_t our_uuid() const final { return our_uuid_; }

/// VolumeManager
NullAsyncResult create_volume(VolumeInfo&& vol_info) final;
Expand Down
7 changes: 5 additions & 2 deletions src/lib/volume/tests/test_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <sisl/settings/settings.hpp>
#include <boost/uuid/string_generator.hpp>
#include <boost/uuid/nil_generator.hpp>
#include <boost/uuid/random_generator.hpp>
#include <chrono>
#include <iostream>
#include <thread>
Expand Down Expand Up @@ -82,7 +83,9 @@ class HBTestHelper {
return devs;
}

peer_id_t discover_svcid(std::optional< peer_id_t > const&) const override { return helper_.svc_id(); }
std::optional< peer_id_t > discover_svc_id(std::optional< peer_id_t > const&) const override {
return helper_.svc_id();
}

uint64_t app_mem_size() const override {
// return SISL_OPTIONS["app_mem_size"].as< uint64_t >();
Expand All @@ -99,7 +102,7 @@ class HBTestHelper {
sisl::logging::SetLogPattern("[%D %T%z] [%^%L%$] [%n] [%t] %v");

// init svc_id_
svc_id_ = boost::uuids::nil_uuid();
svc_id_ = boost::uuids::random_generator()();

// init device list
init_dev_list(true /*init_device*/);
Expand Down
Loading