From 828b4022ed186493d887e33aa60d38c5092ccf41 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Sun, 16 Feb 2025 02:18:03 +0300 Subject: [PATCH] os/bluestore: don't use bdev.size() when dealing with bdev labels in fsck. This might cause assertions after incomplete volume expansion (expand-device cmd hasn't been called) as allocmap bitmaps are initialized with bdev label.size not bdev.size() and hence they are accessed out-of-bound. Signed-off-by: Igor Fedotov (cherry picked from commit 173bbe7dba7f0b835246fab9ecdba1f13c544460) --- src/os/bluestore/BlueStore.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 8178bd8378c..ac8f38e897d 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -10716,7 +10716,7 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair) if (bdev->supported_bdev_label() && bdev_label_multi) { for (size_t i = 0; i < bdev_label_positions.size(); i++) { uint64_t location = bdev_label_positions[i]; - if (location + BDEV_LABEL_BLOCK_SIZE > bdev->get_size()) { + if (location + BDEV_LABEL_BLOCK_SIZE > bdev_label.size) { continue; } if (std::find( @@ -10739,7 +10739,6 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair) if (bluefs) { interval_set bluefs_extents; - bluefs->foreach_block_extents( bluefs_layout.shared_bdev, [&](uint64_t start, uint32_t len) { @@ -10783,7 +10782,7 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair) for (size_t i = 0; i < bdev_label_positions.size(); i++) { uint64_t position = bdev_label_positions[i]; uint64_t length = std::max(BDEV_LABEL_BLOCK_SIZE, alloc_size); - if (position + length <= bdev->get_size()) { + if (position + length <= bdev_label.size) { apply_for_bitset_range(position, length, alloc_size, used_blocks, [&](uint64_t pos, mempool_dynamic_bitset& bs) { bs.set(pos); -- 2.39.5