diff --git a/src/osd.cpp b/src/osd.cpp index 0fc0cb55..5e27b2f4 100644 --- a/src/osd.cpp +++ b/src/osd.cpp @@ -44,9 +44,10 @@ osd_t::osd_t(const json11::Json & config, ring_loop_t *ringloop) // FIXME: Use timerfd_interval based directly on io_uring this->tfd = epmgr->tfd; - auto bs_cfg = json_to_bs(this->config); - this->bs = new blockstore_t(bs_cfg, ringloop, tfd); + if (!json_is_true(this->config["disable_blockstore"])) { + auto bs_cfg = json_to_bs(this->config); + this->bs = new blockstore_t(bs_cfg, ringloop, tfd); // Autosync based on the number of unstable writes to prevent stalls due to insufficient journal space uint64_t max_autosync = bs->get_journal_size() / bs->get_block_size() / 2; if (autosync_writes > max_autosync) @@ -93,7 +94,8 @@ osd_t::~osd_t() { ringloop->unregister_consumer(&consumer); delete epmgr; - delete bs; + if (bs) + delete bs; close(listen_fd); free(zero_buffer); } @@ -475,7 +477,7 @@ void osd_t::print_slow() } } } - if (has_slow) + if (has_slow && bs) { bs->dump_diagnostics(); } diff --git a/src/osd.h b/src/osd.h index bb765754..b8830153 100644 --- a/src/osd.h +++ b/src/osd.h @@ -152,7 +152,7 @@ class osd_t bool stopping = false; int inflight_ops = 0; - blockstore_t *bs; + blockstore_t *bs = NULL; void *zero_buffer = NULL; uint64_t zero_buffer_size = 0; uint32_t bs_block_size, bs_bitmap_granularity, clean_entry_bitmap_size; diff --git a/src/osd_cluster.cpp b/src/osd_cluster.cpp index fcb12324..603c7dcf 100644 --- a/src/osd_cluster.cpp +++ b/src/osd_cluster.cpp @@ -182,10 +182,10 @@ json11::Json osd_t::get_statistics() char time_str[50] = { 0 }; sprintf(time_str, "%ld.%03ld", ts.tv_sec, ts.tv_nsec/1000000); st["time"] = time_str; - st["blockstore_ready"] = bs->is_started(); - st["data_block_size"] = (uint64_t)bs->get_block_size(); if (bs) { + st["blockstore_ready"] = bs->is_started(); + st["data_block_size"] = (uint64_t)bs->get_block_size(); st["size"] = bs->get_block_count() * bs->get_block_size(); st["free"] = bs->get_free_block_count() * bs->get_block_size(); } @@ -233,7 +233,8 @@ void osd_t::report_statistics() json11::Json::object inode_space; json11::Json::object last_stat; pool_id_t last_pool = 0; - auto & bs_inode_space = bs->get_inode_space_stats(); + std::map bs_empty_space; + auto & bs_inode_space = bs ? bs->get_inode_space_stats() : bs_empty_space; for (auto kv: bs_inode_space) { pool_id_t pool_id = INODE_POOL(kv.first);