]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Remove assert from NCB recovery
authorAdam Kupczyk <akupczyk@ibm.com>
Fri, 6 Mar 2026 12:26:52 +0000 (12:26 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Fri, 6 Mar 2026 17:58:15 +0000 (17:58 +0000)
Now instead of assert print error message.

Fixes: https://tracker.ceph.com/issues/74645
Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
src/os/bluestore/BlueStore.cc
src/test/objectstore/store_test.cc

index 7d44a9590d008d530a4a980ddc86db18c46131d3..5e64dd5282ce73c728e57f16e4f044a657713949 100644 (file)
@@ -20509,7 +20509,12 @@ int BlueStore::read_allocation_from_onodes(SimpleBitmap *sbmap, read_alloc_stats
              << dendl;
         return -EIO;
       }
-      ceph_assert(oid == edecoder.get_oid());
+      if (oid != edecoder.get_oid()) {
+        derr << __func__ << " shard " << pretty_binary_string(okey)
+             << " oid: " << oid
+             << " not from current oid: " << edecoder.get_oid() << dendl;
+        continue;
+      }
       edecoder.decode_some(it->value(), nullptr);
       ++stats.shard_count;
     }
index b9996b914b4819453a24c01cf392fd5ddb933f97..176eecbad3edc49a7ba0037bd0f393911ddefe08 100644 (file)
@@ -307,6 +307,63 @@ public:
     int r = queue_transaction(store, ch, std::move(t));
     return r;
   }
+
+  coll_t cid;
+  ObjectStore::CollectionHandle ch;
+
+  void prepare_store()
+  {
+    static constexpr uint64_t _1G = uint64_t(1024)*1024*1024;
+    static constexpr uint64_t _1M = uint64_t(1) * 1024 * 1024;
+    SetVal(g_conf(), "bluestore_block_size", stringify(101 * _1G).c_str());
+    g_conf().apply_changes(nullptr);
+    DeferredSetup();
+
+    cid = coll_t(spg_t(pg_t(1, 222), shard_id_t::NO_SHARD));
+
+    ghobject_t hoid1(hobject_t(sobject_t("aaaa_Object 1", CEPH_NOSNAP), "", 1, 222, ""));
+    ghobject_t hoid_special(hobject_t(sobject_t("my_special_object", CEPH_NOSNAP), "", 1, 222, ""));
+    ghobject_t hoid2(hobject_t(sobject_t("zzzz_Object 2", CEPH_NOSNAP), "", 1, 222, ""));
+    //set hashes to have special object in the middle
+    hoid1.hobj.       set_hash(0x00000000); //0
+    hoid_special.hobj.set_hash(0x80000000); //1
+    hoid2.hobj.       set_hash(0x40000000); //2
+
+    ch = store->create_new_collection(cid);
+    {
+      ObjectStore::Transaction t;
+      t.create_collection(cid, 0);
+      int r = queue_transaction(store, ch, std::move(t));
+      ASSERT_EQ(r, 0);
+    }
+
+    write_object(cid, ch, hoid1, 4 * _1M);
+    write_object(cid, ch, hoid_special, 4 * _1M);
+    write_object(cid, ch, hoid2, 4 * _1M);
+
+    ch.reset();
+    umount();
+  }
+
+  void cleanup_store()
+  {
+    ghobject_t hoid1(hobject_t(sobject_t("aaaa_Object 1", CEPH_NOSNAP),"", 1, 222,""));
+    ghobject_t hoid_special(hobject_t(sobject_t("my_special_object", CEPH_NOSNAP),"", 1, 222,""));
+    ghobject_t hoid2(hobject_t(sobject_t("zzzz_Object 2", CEPH_NOSNAP),"", 1, 222,""));
+    mount();
+    ch = store->open_collection(cid);
+    {
+      ObjectStore::Transaction t;
+      t.remove(cid, hoid1);
+      t.remove(cid, hoid_special);
+      t.remove(cid, hoid2);
+      t.remove_collection(cid);
+      int r = queue_transaction(store, ch, std::move(t));
+      ASSERT_EQ(r, 0);
+    }
+    ch.reset();
+    umount();
+  }
 };
 #endif // WITH_BLUESTORE
 
@@ -11408,39 +11465,10 @@ TEST_P(MultiLabelTest, UpgradeToMultiLabelCollisionWithObjects) {
   ASSERT_EQ(label.meta["multi"], "yes");
 }
 
-TEST_P(CorruptedOnodesTest, Recover_TolerateMissingHeadShard) {
-  static constexpr uint64_t _1G = uint64_t(1024)*1024*1024;
-  static constexpr uint64_t _1M = uint64_t(1)*1024*1024;
+TEST_P(CorruptedOnodesTest, Recover_TolerateMissingHeadShard)
+{
   SetVal(g_conf(), "bluestore_debug_inject_allocation_from_file_failure", "0");
-  SetVal(g_conf(), "bluestore_block_size", stringify(101 * _1G).c_str());
-  g_conf().apply_changes(nullptr);
-  DeferredSetup();
-
-  coll_t cid(spg_t(pg_t(1,222), shard_id_t::NO_SHARD));
-  ObjectStore::CollectionHandle ch;
-
-  ghobject_t hoid1(hobject_t(sobject_t("aaaa_Object 1", CEPH_NOSNAP),"", 1, 222,""));
-  ghobject_t hoid_special(hobject_t(sobject_t("my_special_object", CEPH_NOSNAP),"", 1, 222,""));
-  ghobject_t hoid2(hobject_t(sobject_t("zzzz_Object 2", CEPH_NOSNAP),"", 1, 222,""));
-  //set hashes to have special object in the middle
-  hoid1.hobj.       set_hash(0x00000000); //0
-  hoid_special.hobj.set_hash(0x80000000); //1
-  hoid2.hobj.       set_hash(0x40000000); //2
-  int r;
-  ch = store->create_new_collection(cid);
-  {
-    ObjectStore::Transaction t;
-    t.create_collection(cid, 0);
-    r = queue_transaction(store, ch, std::move(t));
-    ASSERT_EQ(r, 0);
-  }
-
-  write_object(cid, ch, hoid1, 4 * _1M);
-  write_object(cid, ch, hoid_special, 4 * _1M);
-  write_object(cid, ch, hoid2, 4 * _1M);
-
-  ch.reset();
-  umount();
+  prepare_store();
 
   mount();
   BlueStore* bs = dynamic_cast<BlueStore*>(store.get());
@@ -11464,19 +11492,7 @@ TEST_P(CorruptedOnodesTest, Recover_TolerateMissingHeadShard) {
 
   SetVal(g_conf(), "bluestore_debug_inject_allocation_from_file_failure", "1");
   g_conf().apply_changes(nullptr);
-  mount();
-  ch = store->open_collection(cid);
-  {
-    ObjectStore::Transaction t;
-    t.remove(cid, hoid1);
-    t.remove(cid, hoid_special);
-    t.remove(cid, hoid2);
-    t.remove_collection(cid);
-    r = queue_transaction(store, ch, std::move(t));
-    ASSERT_EQ(r, 0);
-  }
-  ch.reset();
-  umount();
+  cleanup_store();
 }
 
 #endif // WITH_BLUESTORE