From acdd0e363c76073e2fc60de5e9b55d3441c74a66 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Fri, 7 Mar 2025 14:29:34 +0300 Subject: [PATCH] os/bluestore: get rid off BlueFS::get_block_device_size Signed-off-by: Igor Fedotov --- src/os/bluestore/BlueFS.cc | 21 +++++++-------------- src/os/bluestore/BlueFS.h | 1 - src/os/bluestore/BlueStore.cc | 12 ++++++------ 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index f301badfbe0..06b5af7adf0 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -552,13 +552,6 @@ bool BlueFS::bdev_support_label(unsigned id) return bdev[id]->supported_bdev_label(); } -uint64_t BlueFS::get_block_device_size(unsigned id) const -{ - if (id < bdev.size() && bdev[id]) - return bdev[id]->get_size(); - return 0; -} - BlockDevice* BlueFS::get_block_device(unsigned id) const { if (id < bdev.size() && bdev[id]) @@ -609,7 +602,7 @@ uint64_t BlueFS::get_used(unsigned id) uint64_t BlueFS::_get_total(unsigned id) const { ceph_assert(id < bdev.size()); - return get_block_device_size(id); + return bdev[id] ? bdev[id]->get_size() : 0; } uint64_t BlueFS::get_total(unsigned id) @@ -702,9 +695,9 @@ int BlueFS::mkfs(uuid_d osd_uuid, const bluefs_layout_t& layout) if (vselector == nullptr) { vselector.reset( new OriginalVolumeSelector( - get_block_device_size(BlueFS::BDEV_WAL) * 95 / 100, - get_block_device_size(BlueFS::BDEV_DB) * 95 / 100, - get_block_device_size(BlueFS::BDEV_SLOW) * 95 / 100)); + _get_total(BlueFS::BDEV_WAL) * 95 / 100, + _get_total(BlueFS::BDEV_DB) * 95 / 100, + _get_total(BlueFS::BDEV_SLOW) * 95 / 100)); } _init_logger(); @@ -1057,9 +1050,9 @@ int BlueFS::mount() if (vselector == nullptr) { vselector.reset( new OriginalVolumeSelector( - get_block_device_size(BlueFS::BDEV_WAL) * 95 / 100, - get_block_device_size(BlueFS::BDEV_DB) * 95 / 100, - get_block_device_size(BlueFS::BDEV_SLOW) * 95 / 100)); + _get_total(BlueFS::BDEV_WAL) * 95 / 100, + _get_total(BlueFS::BDEV_DB) * 95 / 100, + _get_total(BlueFS::BDEV_SLOW) * 95 / 100)); } _init_alloc(); diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index e0676d7967f..abca0a36623 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -773,7 +773,6 @@ public: int add_block_device(unsigned bdev, const std::string& path, bool trim, bluefs_shared_alloc_context_t* _shared_alloc = nullptr); bool bdev_support_label(unsigned id); - uint64_t get_block_device_size(unsigned bdev) const; BlockDevice* get_block_device(unsigned bdev) const; // handler for discard event diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index c54bc3bb28a..d72eb46808e 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -7698,16 +7698,16 @@ int BlueStore::_open_bluefs(bool create, bool read_only) } if (cct->_conf->bluestore_volume_selection_policy == "fit_to_fast") { vselector = new FitToFastVolumeSelector( - bluefs->get_block_device_size(BlueFS::BDEV_WAL) * 95 / 100, - bluefs->get_block_device_size(BlueFS::BDEV_DB) * 95 / 100, - bluefs->get_block_device_size(BlueFS::BDEV_SLOW) * 95 / 100); + bluefs->get_total(BlueFS::BDEV_WAL) * 95 / 100, + bluefs->get_total(BlueFS::BDEV_DB) * 95 / 100, + bluefs->get_total(BlueFS::BDEV_SLOW) * 95 / 100); } else { double reserved_factor = cct->_conf->bluestore_volume_selection_reserved_factor; vselector = new RocksDBBlueFSVolumeSelector( - bluefs->get_block_device_size(BlueFS::BDEV_WAL) * 95 / 100, - bluefs->get_block_device_size(BlueFS::BDEV_DB) * 95 / 100, - bluefs->get_block_device_size(BlueFS::BDEV_SLOW) * 95 / 100, + bluefs->get_total(BlueFS::BDEV_WAL) * 95 / 100, + bluefs->get_total(BlueFS::BDEV_DB) * 95 / 100, + bluefs->get_total(BlueFS::BDEV_SLOW) * 95 / 100, rocks_opts.write_buffer_size * rocks_opts.max_write_buffer_number, rocks_opts.max_bytes_for_level_base, rocks_opts.max_bytes_for_level_multiplier, -- 2.39.5