]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: fix fsck fixing multiple bdev label (superblock)
authorAdam Kupczyk <akupczyk@ibm.com>
Mon, 1 Jul 2024 13:44:41 +0000 (13:44 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Mon, 22 Jul 2024 12:36:29 +0000 (12:36 +0000)
The problem was that after fixing label location,
location was not marked as "good label".
In result the region was not excluded when saving allocator state.
After reading allocator state, label was treated as corrupted.

Fixed fixing bdev label when freelist is bitmap (HDD).

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

index d583efbc2281927b2e5a119f34900f058c6062df..84fb08889a8906de579b522a10c2b3c535961307 100644 (file)
@@ -10681,10 +10681,8 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair)
         dout(1) << "fsck bdev label at 0x" << std::hex << position << std::dec
                 <<  "taken by bluefs, cannot be fixed" << dendl;
       } else {
-        if (repair) {
-          // Mark blocks so we could move offending objects away.
-          bdev_labels_in_repair.push_back(position);
-        }
+        // Mark blocks so we could move offending objects away.
+        bdev_labels_in_repair.push_back(position);
       }
     }
     // Mark locations of those bdev labels that are not taken by bluefs.
@@ -11295,7 +11293,10 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair)
         ceph_assert(bdev_label_valid_locations.empty());
       }
       //unmark extra bdev copies, will collide with the check
-      for (uint64_t location : bdev_label_valid_locations) {
+
+      std::vector<uint64_t> sum = bdev_label_valid_locations;
+      sum.insert(sum.end(), bdev_labels_in_repair.begin(), bdev_labels_in_repair.end());
+      for (uint64_t location : sum) {
         uint64_t length = std::max<uint64_t>(BDEV_LABEL_BLOCK_SIZE, alloc_size);
         if (location != BDEV_FIRST_LABEL_POSITION) {
           apply_for_bitset_range(location, length, alloc_size, used_blocks,
@@ -11394,6 +11395,11 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair)
     // Now fix bdev_labels that were detected to be broken & repairable.
     string p = path + "/block";
     _write_bdev_label(cct, bdev, p, bdev_label, bdev_labels_in_repair);
+    for (uint64_t pos : bdev_labels_in_repair) {
+      if (pos != BDEV_FIRST_LABEL_POSITION) {
+        bdev_label_valid_locations.push_back(pos);
+      }
+    }
     repaired += bdev_labels_in_repair.size();
   }
 
index 5e01020062537fbb15d63397c8c847e39770a9c8..dc277c3c5a6cdb7d158752216c049ee754bffbc5 100644 (file)
@@ -11215,6 +11215,10 @@ TEST_P(MultiLabelTest, UpgradeToMultiLabelCollisionWithObjects) {
     }
   }
   umount();
+  // Need to do 2 passes of repair:
+  // - the first one moves offending objects away
+  // - the second can then fix bdev labels
+  store->repair(false);
   ASSERT_EQ(store->repair(false), 0);
   ASSERT_EQ(store->fsck(false), 0);
   bluestore_bdev_label_t label;