From: Pere Diaz Bou Date: Thu, 14 Dec 2023 18:38:58 +0000 (+0100) Subject: os/bluestore: test unshare blob + clone errors X-Git-Tag: v19.3.0~3^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d5510b0f62677641b642b304b6a99ad2239a71f2;p=ceph.git os/bluestore: test unshare blob + clone errors This will ensure deleting and then cloning the same blob works. Signed-off-by: Pere Diaz Bou --- diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 61ac86a8fee..a923ede5c12 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -3769,6 +3769,73 @@ TEST_P(StoreTest, SimpleCloneRangeTest) { } #if defined(WITH_BLUESTORE) +TEST_P(StoreTest, BlueStoreUnshareBlobSimple) { + if (string(GetParam()) != "bluestore") + return; + int r; + coll_t cid; + auto ch = store->create_new_collection(cid); + { + ObjectStore::Transaction t; + t.create_collection(cid, 0); + cerr << "Creating collection " << cid << std::endl; + r = queue_transaction(store, ch, std::move(t)); + ASSERT_EQ(r, 0); + } + ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP))); + hoid.hobj.pool = -1; + ghobject_t hoid2(hobject_t(sobject_t("Object 1", CEPH_NOSNAP))); + hoid2.hobj.pool = -1; + hoid2.generation = 2; + { + // multiples of unit_size are necesary so that ref_map in sharedblob is equal to the one in maybe_shared_blob + bufferlist data; + data.append(string(4096, 'a')); + + ObjectStore::Transaction t; + t.write(cid, hoid, 0, data.length(), data); + cerr << "Creating object and write 4K " << hoid << std::endl; + r = queue_transaction(store, ch, std::move(t)); + ASSERT_EQ(r, 0); + + ObjectStore::Transaction t2; + t2.clone(cid, hoid, hoid2); + cerr << "Clone object" << std::endl; + r = queue_transaction(store, ch, std::move(t2)); + ASSERT_EQ(r, 0); + + + } + + { + // This should unshare previous Blob, only works with generations + ObjectStore::Transaction t; + t.remove(cid, hoid2); + cerr << "Removing gen 2" << std::endl; + r = queue_transaction(store, ch, std::move(t)); + ASSERT_EQ(r, 0); + } + + { + ObjectStore::Transaction t; + cerr << "Cloning again" << std::endl; + // expect share blob to work again + t.clone(cid, hoid, hoid2); + r = queue_transaction(store, ch, std::move(t)); + ASSERT_EQ(r, 0); + } + + { + ObjectStore::Transaction t; + // clean up + t.remove(cid, hoid); + t.remove(cid, hoid2); + t.remove_collection(cid); + cerr << "Cleaning" << std::endl; + r = queue_transaction(store, ch, std::move(t)); + ASSERT_EQ(r, 0); + } +} TEST_P(StoreTest, BlueStoreUnshareBlobTest) { if (string(GetParam()) != "bluestore") return;