static const unsigned max_attr_name_len = 100;
static const unsigned max_attr_value_len = 1024 * 4;
coll_t cid;
+ unsigned write_alignment;
unsigned max_object_len, max_write_len;
unsigned in_flight;
map<ghobject_t, Object, ghobject_t::BitwiseComparator> contents;
ObjectStore::Sequencer *osr,
coll_t cid,
unsigned max_size,
- unsigned max_write)
- : cid(cid), max_object_len(max_size), max_write_len(max_write),
- in_flight(0), object_gen(gen), rng(rng), store(store), osr(osr),
- lock("State lock") {}
+ unsigned max_write,
+ unsigned alignment)
+ : cid(cid), write_alignment(alignment), max_object_len(max_size),
+ max_write_len(max_write), in_flight(0), object_gen(gen),
+ rng(rng), store(store), osr(osr), lock("State lock") {}
int init() {
ObjectStore::Transaction t;
t.remove_collection(cid);
apply_transaction(store, osr, std::move(t));
}
+ void statfs(store_statfs_t& stat) {
+ store->statfs(&stat);
+ }
ghobject_t get_uniform_random_object() {
while (in_flight >= max_in_flight || available_objects.empty())
uint64_t offset = u1(*rng);
uint64_t len = u2(*rng);
bufferlist bl;
+ if (write_alignment) {
+ offset = ROUND_UP_TO(offset, write_alignment);
+ len = ROUND_UP_TO(len, write_alignment);
+ }
filled_byte_array(bl, len);
boost::uniform_int<> choose(0, max_object_len);
size_t len = choose(*rng);
+ if (write_alignment) {
+ len = ROUND_UP_TO(len, write_alignment);
+ }
+
bufferlist bl;
t->truncate(cid, obj, len);
boost::uniform_int<> u2(0, max_write_len);
uint64_t offset = u1(*rng);
uint64_t len = u2(*rng);
+ if (write_alignment) {
+ offset = ROUND_UP_TO(offset, write_alignment);
+ len = ROUND_UP_TO(len, write_alignment);
+ }
if (contents[new_obj].data.length() < offset + len) {
contents[new_obj].data.append_zero(offset+len-contents[new_obj].data.length());
gen_type rng(time(NULL));
coll_t cid(spg_t(pg_t(0,555), shard_id_t::NO_SHARD));
- SyntheticWorkloadState test_obj(store.get(), &gen, &rng, &osr, cid, 400*1024, 40*1024);
+ SyntheticWorkloadState test_obj(store.get(), &gen, &rng, &osr, cid, 400*1024, 40*1024, 0);
test_obj.init();
for (int i = 0; i < 1000; ++i) {
if (!(i % 500)) cerr << "seeding object " << i << std::endl;
gen_type rng(time(NULL));
coll_t cid(spg_t(pg_t(0,447),shard_id_t::NO_SHARD));
- SyntheticWorkloadState test_obj(store.get(), &gen, &rng, &osr, cid, 40*1024, 4*1024);
+ SyntheticWorkloadState test_obj(store.get(), &gen, &rng, &osr, cid, 40*1024, 4*1024, 0);
test_obj.init();
for (int i = 0; i < 500; ++i) {
if (!(i % 10)) cerr << "seeding object " << i << std::endl;
return r;
}
-void doMany4KWritesTest(boost::scoped_ptr<ObjectStore>& store)
+void doMany4KWritesTest(boost::scoped_ptr<ObjectStore>& store,
+ unsigned max_objects,
+ unsigned max_ops,
+ unsigned max_object_size,
+ unsigned max_write_size,
+ unsigned write_alignment,
+ store_statfs_t* res_stat)
{
ObjectStore::Sequencer osr("test");
MixedGenerator gen(555);
gen_type rng(time(NULL));
coll_t cid(spg_t(pg_t(0,555), shard_id_t::NO_SHARD));
- SyntheticWorkloadState test_obj(store.get(), &gen, &rng, &osr, cid, 4*1024*1024, 4096);
+ SyntheticWorkloadState test_obj(store.get(),
+ &gen,
+ &rng,
+ &osr,
+ cid,
+ max_object_size,
+ max_write_size,
+ write_alignment);
test_obj.init();
- const int max_objects = 1;
- for (int i = 0; i < max_objects; ++i) {
+ for (unsigned i = 0; i < max_objects; ++i) {
if (!(i % 500)) cerr << "seeding object " << i << std::endl;
test_obj.touch();
}
- for (int i = 0; i < 1000; ++i) {
- if (!(i % 1000)) {
+ for (unsigned i = 0; i < max_ops; ++i) {
+ if (!(i % 200)) {
cerr << "Op " << i << std::endl;
test_obj.print_internal_state();
}
test_obj.write();
}
test_obj.wait_for_done();
+ if (res_stat) {
+ test_obj.statfs(*res_stat);
+ }
test_obj.shutdown();
}
TEST_P(StoreTest, Many4KWritesTest) {
- g_ceph_context->_conf->apply_changes(NULL);
- doMany4KWritesTest(store);
+ if (string(GetParam()) != "bluestore")
+ return;
+ store_statfs_t res_stat;
+ unsigned max_object = 4*1024*1024;
+
+ doMany4KWritesTest(store, 1, 1000, 4*1024*1024, 4*1024, 0, &res_stat);
+
+ ASSERT_LE(res_stat.stored, max_object);
+ ASSERT_EQ(res_stat.allocated, max_object);
}
TEST_P(StoreTest, Many4KWritesNoCSumTest) {
+ if (string(GetParam()) != "bluestore")
+ return;
g_conf->set_val("bluestore_csum", "false");
g_conf->set_val("bluestore_csum_type", "none");
g_ceph_context->_conf->apply_changes(NULL);
- doMany4KWritesTest(store);
+ store_statfs_t res_stat;
+ unsigned max_object = 4*1024*1024;
+ doMany4KWritesTest(store, 1, 1000, max_object, 4*1024, 0, &res_stat );
+
+ ASSERT_LE(res_stat.stored, max_object);
+ ASSERT_EQ(res_stat.allocated, max_object);
g_conf->set_val("bluestore_csum", "true");
g_conf->set_val("bluestore_csum_type", "crc32c");
}
+TEST_P(StoreTest, TooManyBlobsTest) {
+ if (string(GetParam()) != "bluestore")
+ return;
+ store_statfs_t res_stat;
+ unsigned max_object = 4*1024*1024;
+ doMany4KWritesTest(store, 1, 1000, max_object, 4*1024, 0, &res_stat);
+ ASSERT_LE(res_stat.stored, max_object);
+ ASSERT_EQ(res_stat.allocated, max_object);
+}
+
/*
* Local Variables:
* compile-command: "cd ../.. ; make ceph_test_objectstore &&