]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: don't use bdev.size() when dealing with bdev labels in fsck.
authorIgor Fedotov <ifedotov@croit.io>
Sat, 15 Feb 2025 23:18:03 +0000 (02:18 +0300)
committerIgor Fedotov <igor.fedotov@croit.io>
Tue, 15 Apr 2025 09:04:23 +0000 (12:04 +0300)
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 <igor.fedotov@croit.io>
(cherry picked from commit 173bbe7dba7f0b835246fab9ecdba1f13c544460)

src/os/bluestore/BlueStore.cc

index 8178bd8378c55e9b3827621c7be96231ea18918c..ac8f38e897d7cf68deb31b4b11b595afe49cab4b 100644 (file)
@@ -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<uint64_t> 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<uint64_t>(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);