]> git-server-git.apps.pok.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)
committerAdam Kupczyk <akupczyk@ibm.com>
Mon, 22 Jul 2024 12:28:50 +0000 (12:28 +0000)
Do not operate if bdev label is outside device size.

Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
src/os/bluestore/BlueStore.cc

index ea776696c1fad0288c454a007407febb4a322697..4a2c24312cceae034280364125566f9ab4df3805 100644 (file)
@@ -10562,7 +10562,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(
@@ -10631,11 +10631,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);
+          }
+        );
+      }
     }
   }