From d287f8fe0d73f980f381f49e468cc229ba505e84 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Sat, 1 Aug 2020 11:43:44 +0300 Subject: [PATCH] os/bluestore: proper BlueFS shared allocator setup Signed-off-by: Igor Fedotov --- src/os/bluestore/BlueFS.cc | 13 ++++++------- src/os/bluestore/BlueFS.h | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 9a3175b3241bf..cf28b50b25832 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -350,6 +350,7 @@ int BlueFS::add_block_device(unsigned id, const string& path, bool trim, if (_shared_bdev_alloc) { ceph_assert(shared_bdev_alloc == nullptr); alloc[id] = shared_bdev_alloc = _shared_bdev_alloc; + need_shared_alloc_init = true; } return 0; } @@ -583,8 +584,7 @@ int BlueFS::mkfs(uuid_d osd_uuid, const bluefs_layout_t& layout) vselector.reset(nullptr); _stop_alloc(); _shutdown_logger(); - - after_mkfs = true; + need_shared_alloc_init = false; dout(10) << __func__ << " success" << dendl; return 0; @@ -698,15 +698,16 @@ int BlueFS::mount() dout(30) << __func__ << " noting alloc for " << p.second->fnode << dendl; for (auto& q : p.second->fnode.extents) { if (alloc[q.bdev] == shared_bdev_alloc) { - if (!after_mkfs) { + if (need_shared_alloc_init) { alloc[q.bdev]->init_rm_free(q.offset, q.length); + shared_bdev_used += q.length; } - shared_bdev_used += q.length; } else { alloc[q.bdev]->init_rm_free(q.offset, q.length); } } } + need_shared_alloc_init = false; dout(1) << __func__ << " shared_bdev_used = " << shared_bdev_used << dendl; // set up the log for future writes @@ -717,8 +718,6 @@ int BlueFS::mount() << std::hex << log_writer->pos << std::dec << dendl; - after_mkfs = false; - return 0; out: @@ -1291,7 +1290,7 @@ int BlueFS::_replay(bool noop, bool to_stdout) if (!noop) { block_all[id].erase(offset, length); _adjust_granularity(id, &offset, &length, false); - if (length) { + if (length && alloc[id] != shared_bdev_alloc) { alloc[id]->init_rm_free(offset, length); } if (cct->_conf->bluefs_log_replay_check_allocations) { diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index edbdd94e8891a..1a4997663455b 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -309,14 +309,14 @@ private: BlockDevice::aio_callback_t discard_cb[3]; //discard callbacks for each dev std::unique_ptr vselector; + bool need_shared_alloc_init = false; Allocator* shared_bdev_alloc = nullptr; std::atomic shared_bdev_used = 0; + class SocketHook; SocketHook* asok_hook = nullptr; - bool after_mkfs = false; - void _init_logger(); void _shutdown_logger(); void _update_logger_stats(); -- 2.39.5