|
//!!!! to be included into src/test/objectstore/store_test.cc!!!
|
|
|
|
TEST_P(StoreTestSpecificAUSize, BlobReuseBug) {
|
|
|
|
if (string(GetParam()) != "bluestore")
|
|
return;
|
|
|
|
size_t block_size = 0x10000;
|
|
StartDeferred(block_size);
|
|
g_conf->set_val("bluestore_max_blob_size", "131072");
|
|
g_conf->set_val("bluestore_compression_mode", "force");
|
|
g_conf->apply_changes(NULL);
|
|
|
|
ObjectStore::Sequencer osr("test");
|
|
int r;
|
|
coll_t cid;
|
|
ghobject_t hoid1(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
|
|
ghobject_t hoid2(hobject_t(sobject_t("Object 2", CEPH_NOSNAP)));
|
|
|
|
const PerfCounters* logger = store->get_perf_counters();
|
|
|
|
{
|
|
ObjectStore::Transaction t;
|
|
t.create_collection(cid, 0);
|
|
r = apply_transaction(store, &osr, std::move(t));
|
|
ASSERT_EQ(r, 0);
|
|
}
|
|
{
|
|
ObjectStore::Transaction t;
|
|
bufferlist bl, bl2;
|
|
|
|
t.touch(cid, hoid1);
|
|
t.touch(cid, hoid2);
|
|
t.set_alloc_hint(cid, hoid1,
|
|
0x20000,
|
|
0x4000,
|
|
0);
|
|
t.set_alloc_hint(cid, hoid2,
|
|
0x20000,
|
|
0x4000,
|
|
0);
|
|
|
|
bl.append(std::string(0x17000, 'a'));
|
|
t.write(cid, hoid1, 0, bl.length(), bl, 0);
|
|
bl2.append(std::string(0x1000, 'c'));
|
|
t.write(cid, hoid1, 0x17000, bl2.length(), bl2, 0);
|
|
t.zero(cid, hoid1, 0, 0x14a00);
|
|
|
|
t.touch(cid, hoid2);
|
|
r = apply_transaction(store, &osr, std::move(t));
|
|
ASSERT_EQ(r, 0);
|
|
}
|
|
|
|
{
|
|
ObjectStore::Transaction t;
|
|
bufferlist bl, expected;
|
|
|
|
t.clone_range(cid, hoid1, hoid2, 0x400, 0x17c00, 0x400);
|
|
r = apply_transaction(store, &osr, std::move(t));
|
|
ASSERT_EQ(r, 0);
|
|
|
|
r = store->read(cid, hoid1, 0x14a00, 0x3600, bl);
|
|
ASSERT_EQ(r, (int)0x3600);
|
|
expected.append(string(0x2600, 'a'));
|
|
expected.append(string(0x1000, 'c'));
|
|
ASSERT_TRUE(bl_eq(expected, bl));
|
|
bl.clear();
|
|
r = store->read(cid, hoid2, 0x14a00, 0x3600, bl);
|
|
ASSERT_EQ(r, (int)0x3600);
|
|
ASSERT_TRUE(bl_eq(expected, bl));
|
|
|
|
}
|
|
{
|
|
// partially zero source
|
|
ObjectStore::Transaction t;
|
|
bufferlist bl, expected;
|
|
|
|
t.zero(cid, hoid1, 0x14e00, 0x19600);
|
|
r = apply_transaction(store, &osr, std::move(t));
|
|
ASSERT_EQ(r, 0);
|
|
|
|
r = store->read(cid, hoid1, 0x14a00, 0x3600, bl);
|
|
ASSERT_EQ(r, (int)0x3600);
|
|
expected.append(string(0x400, 'a'));
|
|
expected.append(string(0x3200, 0));
|
|
ASSERT_TRUE(bl_eq(expected, bl));
|
|
bl.clear();
|
|
expected.clear();
|
|
expected.append(string(0x2600, 'a'));
|
|
expected.append(string(0x1000, 'c'));
|
|
r = store->read(cid, hoid2, 0x14a00, 0x3600, bl);
|
|
ASSERT_EQ(r, (int)bl.length());
|
|
ASSERT_TRUE(bl_eq(expected, bl));
|
|
}
|
|
|
|
{
|
|
ObjectStore::Transaction t;
|
|
t.remove(cid, hoid1);
|
|
t.remove(cid, hoid2);
|
|
t.remove_collection(cid);
|
|
cerr << "Cleaning" << std::endl;
|
|
r = apply_transaction(store, &osr, std::move(t));
|
|
ASSERT_EQ(r, 0);
|
|
}
|
|
g_conf->set_val("bluestore_compression_mode", "none");
|
|
g_conf->set_val("bluestore_max_blob_size", "524288");
|
|
|
|
}
|