From: Igor Fedotov Date: Tue, 6 Feb 2018 16:50:40 +0000 (+0300) Subject: test/store_test: add test case to for excessive fragmentation X-Git-Tag: v12.2.5~17^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=db9a2bbf160033cf861da58b13a1ecd6363ac574;p=ceph.git test/store_test: add test case to for excessive fragmentation Signed-off-by: Igor Fedotov (cherry picked from commit eb0443a1034b42d006d2a1d2bd5cb91881f07df7) --- diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index d44373751c74..d2152d456208 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -44,6 +44,7 @@ typedef boost::mt11213b gen_type; +const uint64_t DEF_STORE_TEST_BLOCKDEV_SIZE = 10240000000; #define dout_context g_ceph_context #if GTEST_HAS_PARAM_TEST @@ -6463,6 +6464,108 @@ TEST_P(StoreTestSpecificAUSize, SmallWriteOnShardedExtents) { g_conf->set_val("bluestore_csum_type", "crc32c"); } +TEST_P(StoreTestSpecificAUSize, ExcessiveFragmentation) { + if (string(GetParam()) != "bluestore") + return; + + g_conf->set_val("bluestore_block_size", + stringify((uint64_t)2048 * 1024 * 1024)); + + ASSERT_EQ(g_conf->get_val("bluefs_alloc_size"), + 1024 * 1024); + + size_t block_size = 0x10000; + StartDeferred(block_size); + + 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))); + + { + ObjectStore::Transaction t; + t.create_collection(cid, 0); + r = apply_transaction(store, &osr, std::move(t)); + ASSERT_EQ(r, 0); + } + { + // create 2x400MB objects in a way that their pextents are interleaved + ObjectStore::Transaction t; + bufferlist bl; + + bl.append(std::string(block_size * 4, 'a')); // 256KB + uint64_t offs = 0; + while(offs < (uint64_t)400 * 1024 * 1024) { + t.write(cid, hoid1, offs, bl.length(), bl, 0); + t.write(cid, hoid2, offs, bl.length(), bl, 0); + r = apply_transaction(store, &osr, std::move(t)); + ASSERT_EQ(r, 0); + offs += bl.length(); + if( (offs % (100 * 1024 * 1024)) == 0) { + std::cout<<"written " << offs << std::endl; + } + } + } + std::cout<<"written 800MB"<get_val("bluestore_bluefs_balance_interval"); + std::cout<<"sleeping... " << std::endl; + sleep(to_sleep); + + { + // touch another object to triggerrebalance + ObjectStore::Transaction t; + t.touch(cid, hoid1); + r = apply_transaction(store, &osr, std::move(t)); + ASSERT_EQ(r, 0); + } + { + 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_block_size", + stringify(DEF_STORE_TEST_BLOCKDEV_SIZE)); +} + #endif //#if defined(HAVE_LIBAIO) TEST_P(StoreTest, KVDBHistogramTest) { @@ -6787,7 +6890,8 @@ int main(int argc, char **argv) { g_ceph_context->_conf->set_val("bdev_debug_aio", "true"); // specify device size - g_ceph_context->_conf->set_val("bluestore_block_size", "10240000000"); + g_ceph_context->_conf->set_val("bluestore_block_size", + stringify(DEF_STORE_TEST_BLOCKDEV_SIZE)); g_ceph_context->_conf->set_val( "enable_experimental_unrecoverable_data_corrupting_features", "*");