]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Fix fsck() for multi label
authorAdam Kupczyk <akupczyk@ibm.com>
Tue, 30 Jan 2024 13:07:38 +0000 (13:07 +0000)
committerPere Diaz Bou <pere-altea@hotmail.com>
Fri, 23 Aug 2024 09:49:24 +0000 (11:49 +0200)
Do not operate if bdev label is outside device size.

Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
(cherry picked from commit 86f3aad2db49721af6ca7782e789e5861918406a)

src/os/bluestore/BlueStore.cc

index 7abec77f6a5ad5dc38cc650e20e390769a2b4ae1..fac2304842f4f770353dccba0408a76a8126b14e 100644 (file)
@@ -10358,7 +10358,7 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair)
   if (bdev_label_multi) {
     for (size_t i = 0; i < bdev_label_positions.size(); i++) {
       uint64_t location = bdev_label_positions[i];
-      if (location > bdev->get_size()) {
+      if (location + BDEV_LABEL_BLOCK_SIZE > bdev->get_size()) {
         continue;
       }
       if (std::find(
@@ -10427,11 +10427,13 @@ 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);
-      apply_for_bitset_range(position, length, alloc_size, used_blocks,
-        [&](uint64_t pos, mempool_dynamic_bitset& bs) {
-          bs.set(pos);
-        }
-      );
+      if (position + length <= bdev->get_size()) {
+        apply_for_bitset_range(position, length, alloc_size, used_blocks,
+          [&](uint64_t pos, mempool_dynamic_bitset& bs) {
+            bs.set(pos);
+          }
+        );
+      }
     }
   }