Skip to content

Commit

Permalink
test/store_test: refactor DeferredOnBitOverwrite* tests
Browse files Browse the repository at this point in the history
Fixes: https://tracker.ceph.com/issues/63106

Signed-off-by: Igor Fedotov <[email protected]>
  • Loading branch information
ifed01 committed Dec 8, 2023
1 parent 8f5d61d commit 73f7c94
Showing 1 changed file with 85 additions and 20 deletions.
105 changes: 85 additions & 20 deletions src/test/objectstore/store_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7844,7 +7844,7 @@ TEST_P(StoreTestSpecificAUSize, ZeroBlockDetectionBigOverwrite) {
}
}

TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite) {
TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite1) {

if (string(GetParam()) != "bluestore")
return;
Expand Down Expand Up @@ -7961,7 +7961,7 @@ TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite) {
bufferlist bl;

bl.append(std::string(block_size, 'e'));
t.write(cid, hoid2, block_size , bl.length(), bl, CEPH_OSD_OP_FLAG_FADVISE_NOCACHE);
t.write(cid, hoid2, block_size, bl.length(), bl, CEPH_OSD_OP_FLAG_FADVISE_NOCACHE);
r = queue_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
Expand Down Expand Up @@ -8018,17 +8018,50 @@ TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite) {
ASSERT_EQ(statfs.data_stored, (unsigned)block_size * 5);
ASSERT_LE(statfs.allocated, (unsigned)block_size * 5);
}
store->refresh_perf_counters();
ASSERT_EQ(logger->get(l_bluestore_blobs), 2u);
ASSERT_EQ(logger->get(l_bluestore_extents), 2u);

{
ObjectStore::Transaction t;
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(StoreTestSpecificAUSize, DeferredOnBigOverwrite2) {

if (string(GetParam()) != "bluestore")
return;
if (smr) {
cout << "SKIP: no deferred" << std::endl;
return;
}

size_t block_size = 4096;
StartDeferred(block_size);
SetVal(g_conf(), "bluestore_max_blob_size", "131072");
SetVal(g_conf(), "bluestore_prefer_deferred_size", "65536");

g_conf().apply_changes(nullptr);

int r;
coll_t cid;
ghobject_t hoid(hobject_t("test", "", CEPH_NOSNAP, 0, -1, ""));
ghobject_t hoid2(hobject_t("test2", "", CEPH_NOSNAP, 0, -1, ""));

PerfCounters* logger = const_cast<PerfCounters*>(store->get_perf_counters());

auto 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);
}
{
ObjectStore::Transaction t;
bufferlist bl;
Expand All @@ -8038,8 +8071,8 @@ TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite) {
r = queue_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_EQ(logger->get(l_bluestore_write_big), 6u);
ASSERT_EQ(logger->get(l_bluestore_write_big_deferred), 3u);
ASSERT_EQ(logger->get(l_bluestore_write_big), 1u);
ASSERT_EQ(logger->get(l_bluestore_write_big_deferred), 0u);

{
ObjectStore::Transaction t;
Expand All @@ -8061,14 +8094,14 @@ TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite) {
expected.append(string(block_size * 2 - 100, 'f'));
ASSERT_TRUE(bl_eq(expected, bl));
}
sleep(2);
{
struct store_statfs_t statfs;
int r = store->statfs(&statfs);
ASSERT_EQ(r, 0);
ASSERT_EQ(statfs.data_stored, (unsigned)block_size * 2 - 100);
ASSERT_LE(statfs.allocated, (unsigned)block_size * 2);
}
store->refresh_perf_counters();
ASSERT_EQ(logger->get(l_bluestore_blobs), 1u);
ASSERT_EQ(logger->get(l_bluestore_extents), 1u);

Expand All @@ -8081,8 +8114,8 @@ TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite) {
r = queue_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_EQ(logger->get(l_bluestore_write_big), 7u);
ASSERT_EQ(logger->get(l_bluestore_write_big_deferred), 4u);
ASSERT_EQ(logger->get(l_bluestore_write_big), 2u);
ASSERT_EQ(logger->get(l_bluestore_write_big_deferred), 1u);
{
bufferlist bl, expected;
r = store->read(ch, hoid, 0, block_size, bl);
Expand All @@ -8105,6 +8138,7 @@ TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite) {
ASSERT_EQ(statfs.data_stored, (unsigned)block_size * 2);
ASSERT_LE(statfs.allocated, (unsigned)block_size * 2);
}
store->refresh_perf_counters();
ASSERT_EQ(logger->get(l_bluestore_blobs), 1u);
ASSERT_EQ(logger->get(l_bluestore_extents), 1u);

Expand All @@ -8118,8 +8152,8 @@ TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite) {
r = queue_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_EQ(logger->get(l_bluestore_write_big), 8u);
ASSERT_EQ(logger->get(l_bluestore_write_big_deferred), 4u);
ASSERT_EQ(logger->get(l_bluestore_write_big), 3u);
ASSERT_EQ(logger->get(l_bluestore_write_big_deferred), 1u);

{
bufferlist bl, expected;
Expand All @@ -8141,10 +8175,43 @@ TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite) {
ObjectStore::Transaction t;
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(StoreTestSpecificAUSize, DeferredOnBigOverwrite3) {

if (string(GetParam()) != "bluestore")
return;
if (smr) {
cout << "SKIP: no deferred" << std::endl;
return;
}

size_t block_size = 4096;
StartDeferred(block_size);
SetVal(g_conf(), "bluestore_max_blob_size", "131072");
SetVal(g_conf(), "bluestore_prefer_deferred_size", "65536");

g_conf().apply_changes(nullptr);

int r;
coll_t cid;
ghobject_t hoid(hobject_t("test", "", CEPH_NOSNAP, 0, -1, ""));
ghobject_t hoid2(hobject_t("test2", "", CEPH_NOSNAP, 0, -1, ""));

PerfCounters* logger = const_cast<PerfCounters*>(store->get_perf_counters());

auto 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);
}
{
ObjectStore::Transaction t;
bufferlist bl;
Expand All @@ -8156,8 +8223,8 @@ TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite) {
r = queue_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_EQ(logger->get(l_bluestore_write_big), 10u);
ASSERT_EQ(logger->get(l_bluestore_write_big_deferred), 4u);
ASSERT_EQ(logger->get(l_bluestore_write_big), 2u);
ASSERT_EQ(logger->get(l_bluestore_write_big_deferred), 0u);

// check whether overwrite (less than prefer_deferred_size) partially overlapping two adjacent blobs goes
// deferred
Expand All @@ -8170,8 +8237,8 @@ TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite) {
r = queue_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_EQ(logger->get(l_bluestore_write_big), 11u);
ASSERT_EQ(logger->get(l_bluestore_write_big_deferred), 6u);
ASSERT_EQ(logger->get(l_bluestore_write_big), 3u);
ASSERT_EQ(logger->get(l_bluestore_write_big_deferred), 2u);

{
bufferlist bl, expected;
Expand Down Expand Up @@ -8213,9 +8280,8 @@ TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite) {
r = queue_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
sleep(2);
ASSERT_EQ(logger->get(l_bluestore_write_big), 12u);
ASSERT_EQ(logger->get(l_bluestore_write_big_deferred), 8u);
ASSERT_EQ(logger->get(l_bluestore_write_big), 4u);
ASSERT_EQ(logger->get(l_bluestore_write_big_deferred), 4u);

{
bufferlist bl, expected;
Expand Down Expand Up @@ -8258,7 +8324,6 @@ TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite) {
r = queue_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
sleep(2);
ASSERT_EQ(logger->get(l_bluestore_write_big), 1u);
ASSERT_EQ(logger->get(l_bluestore_write_big_deferred), 1u);
ASSERT_EQ(logger->get(l_bluestore_issued_deferred_writes), 1u);
Expand All @@ -8283,7 +8348,7 @@ TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite) {
}
}

TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite2) {
TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite4) {

if (string(GetParam()) != "bluestore")
return;
Expand Down Expand Up @@ -8359,7 +8424,7 @@ TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite2) {
}
}

TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite3) {
TEST_P(StoreTestSpecificAUSize, DeferredOnBigOverwrite5) {

if (string(GetParam()) != "bluestore")
return;
Expand Down

0 comments on commit 73f7c94

Please sign in to comment.