From 48fdc4c84f6bf60413cb9e02f7f71e6cebf3e6ba 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 (cherry picked from commit acdd0e363c76073e2fc60de5e9b55d3441c74a66) --- 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 041ff732f7030..91e87e8339770 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -538,13 +538,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]) @@ -595,7 +588,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) @@ -688,9 +681,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(); @@ -1043,9 +1036,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 ee8f50149c545..67d8cee95228f 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -777,7 +777,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 7601966c3ff5c..54fb0ef4ad6b6 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -7627,16 +7627,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