]> git.apps.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)
committerPere Diaz Bou <pere-altea@hotmail.com>
Fri, 23 Aug 2024 09:49:25 +0000 (11:49 +0200)
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>
(cherry picked from commit 721482adc0de1371cf92cd4e73255ba170a2a5ac)

src/os/bluestore/BlueStore.cc
src/test/objectstore/store_test.cc

index 93de73fb4838cdcd7996db39d5782bd9c702d8e9..74f0f5845ec6d82181a293c688983733b4bfb074 100644 (file)
@@ -10477,10 +10477,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.
@@ -11064,7 +11062,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,
@@ -11163,6 +11164,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 f1bd146eaeae6911ec1f1afd145838bc37bbbadc..486aa6be529c37f89ba66d9ee2fc4f4219d026e5 100644 (file)
@@ -10693,6 +10693,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;