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
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());
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