template <typename T>
int apply_transaction(
T &store,
- ObjectStore::Sequencer *osr,
+ ObjectStore::CollectionHandle ch,
ObjectStore::Transaction &&t) {
if (rand() % 2) {
ObjectStore::Transaction t2;
t2.append(t);
- return store->apply_transaction(osr, std::move(t2));
+ return store->apply_transaction(ch, std::move(t2));
} else {
- return store->apply_transaction(osr, std::move(t));
+ return store->apply_transaction(ch, std::move(t));
}
}
}
TEST_P(StoreTest, SimpleRemount) {
- ObjectStore::Sequencer osr("test");
coll_t cid;
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
ghobject_t hoid2(hobject_t(sobject_t("Object 2", CEPH_NOSNAP)));
bufferlist bl;
bl.append("1234512345");
int r;
+ auto ch = store->create_new_collection(cid);
{
cerr << "create collection + write" << std::endl;
ObjectStore::Transaction t;
t.create_collection(cid, 0);
t.write(cid, hoid, 0, bl.length(), bl);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
+ ch.reset();
r = store->umount();
ASSERT_EQ(0, r);
r = store->mount();
ASSERT_EQ(0, r);
+ ch = store->open_collection(cid);
{
ObjectStore::Transaction t;
t.write(cid, hoid2, 0, bl.length(), bl);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, hoid2);
t.remove_collection(cid);
cerr << "remove collection" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
+ ch.reset();
r = store->umount();
ASSERT_EQ(0, r);
r = store->mount();
ASSERT_EQ(0, r);
+ ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
bool exists = store->exists(cid, hoid);
ASSERT_TRUE(!exists);
ObjectStore::Transaction t;
t.remove_collection(cid);
cerr << "remove collection" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, IORemount) {
- ObjectStore::Sequencer osr("test");
coll_t cid;
bufferlist bl;
bl.append("1234512345");
int r;
+ auto ch = store->create_new_collection(cid);
{
cerr << "create collection + objects" << std::endl;
ObjectStore::Transaction t;
ghobject_t hoid(hobject_t(sobject_t("Object " + stringify(n), CEPH_NOSNAP)));
t.write(cid, hoid, 0, bl.length(), bl);
}
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
// overwrites
ObjectStore::Transaction t;
ghobject_t hoid(hobject_t(sobject_t("Object " + stringify(n), CEPH_NOSNAP)));
t.write(cid, hoid, 1, bl.length(), bl);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
+ ch.reset();
r = store->umount();
ASSERT_EQ(0, r);
r = store->mount();
t.remove(cid, hoid);
}
t.remove_collection(cid);
- r = apply_transaction(store, &osr, std::move(t));
+ auto ch = store->open_collection(cid);
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, UnprintableCharsName) {
- ObjectStore::Sequencer osr("test");
coll_t cid;
string name = "funnychars_";
for (unsigned i = 0; i < 256; ++i) {
}
ghobject_t oid(hobject_t(sobject_t(name, CEPH_NOSNAP)));
int r;
+ auto ch = store->create_new_collection(cid);
{
cerr << "create collection + object" << std::endl;
ObjectStore::Transaction t;
t.create_collection(cid, 0);
t.touch(cid, oid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
+ ch.reset();
r = store->umount();
ASSERT_EQ(0, r);
r = store->mount();
ObjectStore::Transaction t;
t.remove(cid, oid);
t.remove_collection(cid);
- r = apply_transaction(store, &osr, std::move(t));
+ auto ch = store->open_collection(cid);
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, FiemapEmpty) {
- ObjectStore::Sequencer osr("test");
coll_t cid;
int r = 0;
ghobject_t oid(hobject_t(sobject_t("fiemap_object", CEPH_NOSNAP)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
t.touch(cid, oid);
t.truncate(cid, oid, 100000);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, oid);
t.remove_collection(cid);
cerr << "remove collection" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, FiemapHoles) {
- ObjectStore::Sequencer osr("test");
const uint64_t MAX_EXTENTS = 4000;
const uint64_t SKIP_STEP = 65536;
coll_t cid;
ghobject_t oid(hobject_t(sobject_t("fiemap_object", CEPH_NOSNAP)));
bufferlist bl;
bl.append("foo");
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
t.touch(cid, oid);
for (uint64_t i = 0; i < MAX_EXTENTS; i++)
t.write(cid, oid, SKIP_STEP * i, 3, bl);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, oid);
t.remove_collection(cid);
cerr << "remove collection" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, SimpleMetaColTest) {
- ObjectStore::Sequencer osr("test");
coll_t cid;
int r = 0;
{
+ auto ch = store->create_new_collection(cid);
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "create collection" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.remove_collection(cid);
cerr << "remove collection" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ auto ch = store->open_collection(cid);
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
+ auto ch = store->create_new_collection(cid);
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "add collection" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.remove_collection(cid);
cerr << "remove collection" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ auto ch = store->open_collection(cid);
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, SimplePGColTest) {
- ObjectStore::Sequencer osr("test");
coll_t cid(spg_t(pg_t(1,2), shard_id_t::NO_SHARD));
int r = 0;
{
ObjectStore::Transaction t;
+ auto ch = store->create_new_collection(cid);
t.create_collection(cid, 4);
cerr << "create collection" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.remove_collection(cid);
cerr << "remove collection" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ auto ch = store->open_collection(cid);
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.create_collection(cid, 4);
cerr << "add collection" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ auto ch = store->create_new_collection(cid);
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.remove_collection(cid);
cerr << "remove collection" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ auto ch = store->open_collection(cid);
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, SimpleColPreHashTest) {
- ObjectStore::Sequencer osr("test");
// Firstly we will need to revert the value making sure
// collection hint actually works
int merge_threshold = g_ceph_context->_conf->filestore_merge_threshold;
coll_t cid(spg_t(pg_t(pg_id, 15), shard_id_t::NO_SHARD));
int r;
+ auto ch = store->create_new_collection(cid);
{
// Create a collection along with a hint
ObjectStore::Transaction t;
encode(expected_num_objs, hint);
t.collection_hint(cid, ObjectStore::Transaction::COLL_HINT_EXPECTED_NUM_OBJECTS, hint);
cerr << "collection hint" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.remove_collection(cid);
cerr << "remove collection" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
// Revert the config change so that it does not affect the split/merge tests
}
TEST_P(StoreTest, SmallBlockWrites) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
+ auto ch = store->create_new_collection(cid);
ghobject_t hoid(hobject_t(sobject_t("foo", CEPH_NOSNAP)));
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
bufferlist a;
{
ObjectStore::Transaction t;
t.write(cid, hoid, 0, 0x1000, a);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
bufferlist in, exp;
{
ObjectStore::Transaction t;
t.write(cid, hoid, 0x1000, 0x1000, b);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
bufferlist in, exp;
{
ObjectStore::Transaction t;
t.write(cid, hoid, 0x3000, 0x1000, c);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
bufferlist in, exp;
{
ObjectStore::Transaction t;
t.write(cid, hoid, 0x2000, 0x1000, a);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
bufferlist in, exp;
{
ObjectStore::Transaction t;
t.write(cid, hoid, 0, 0x1000, c);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, hoid);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, BufferCacheReadTest) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
r = store->read(cid, hoid, 0, 5, in);
ASSERT_EQ(-ENOENT, r);
}
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.touch(cid, hoid);
cerr << "Creating object " << hoid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
exists = store->exists(cid, hoid);
t.write(cid, hoid, 0, 5, bl);
t.write(cid, hoid, 10, 5, bl);
cerr << "TwinWrite" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
r = store->read(cid, hoid, 0, 15, newdata);
t.write(cid, hoid, 0, 5, bl);
t.write(cid, hoid, 10, 5, bl);
cerr << "TwinWrite" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
r = store->read(cid, hoid, 0, 15, newdata);
t.write(cid, hoid, 20, bl2.length(), bl2);
cerr << "Append" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
r = store->read(cid, hoid, 0, 30, newdata);
t.write(cid, hoid, 1, bl.length(), bl);
t.write(cid, hoid, 13, bl3.length(), bl3);
cerr << "TripleWrite" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
r = store->read(cid, hoid, 0, 40, newdata);
void doCompressionTest( boost::scoped_ptr<ObjectStore>& store)
{
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
r = store->read(cid, hoid, 0, 5, in);
ASSERT_EQ(-ENOENT, r);
}
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.touch(cid, hoid);
cerr << "Creating object " << hoid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
exists = store->exists(cid, hoid);
bl.append(data);
t.write(cid, hoid, 0, bl.length(), bl);
cerr << "CompressibleData (4xAU) Write" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
r = store->read(cid, hoid, 0, data.size() , newdata);
bl.append(data2);
t.write(cid, hoid, 0x8000, bl.length(), bl);
cerr << "CompressibleData partial overwrite" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
r = store->read(cid, hoid, 0, 0x10000, newdata);
bl.append(data2);
t.write(cid, hoid, 0, bl.length(), bl);
cerr << "CompressibleData partial overwrite, two extents overlapped, single one to be removed" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
r = store->read(cid, hoid, 0, 0x3e000 - 1, newdata);
bl.append(data);
t.write(cid, hoid, 0x3f000-1, bl.length(), bl);
cerr << "Small chunk partial overwrite, two extents overlapped, single one to be removed" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
r = store->read(cid, hoid, 0x3e000, 0x2000, newdata);
ObjectStore::Transaction t;
t.remove(cid, hoid);
cerr << "Cleaning object" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
//force fsck
+ ch.reset();
EXPECT_EQ(store->umount(), 0);
EXPECT_EQ(store->mount(), 0);
+ ch = store->open_collection(cid);
auto orig_min_blob_size = g_conf->bluestore_compression_min_blob_size;
{
g_conf->set_val("bluestore_compression_min_blob_size", "262144");
bl.append(data);
t.write(cid, hoid, 0, bl.length(), bl);
cerr << "CompressibleData large blob" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
//force fsck
+ ch.reset();
EXPECT_EQ(store->umount(), 0);
EXPECT_EQ(store->mount(), 0);
-
+ ch = store->open_collection(cid);
{
ObjectStore::Transaction t;
t.remove(cid, hoid);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
g_conf->set_val("bluestore_compression_min_blob_size", stringify(orig_min_blob_size));
}
TEST_P(StoreTest, SimpleObjectTest) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
r = store->read(cid, hoid, 0, 5, in);
ASSERT_EQ(-ENOENT, r);
}
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.touch(cid, hoid);
cerr << "Creating object " << hoid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
exists = store->exists(cid, hoid);
t.remove(cid, hoid);
t.touch(cid, hoid);
cerr << "Remove then create" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, hoid);
t.write(cid, hoid, 0, 5, bl);
cerr << "Remove then create" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
bufferlist in;
exp.append(bl);
t.write(cid, hoid, 5, 5, bl);
cerr << "Append" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
bufferlist in;
exp = bl;
t.write(cid, hoid, 0, 10, bl);
cerr << "Full overwrite" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
bufferlist in;
bl.append("abcde");
t.write(cid, hoid, 3, 5, bl);
cerr << "Partial overwrite" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
bufferlist in, exp;
t.truncate(cid, hoid, 0);
t.write(cid, hoid, 5, 5, bl);
cerr << "Truncate + hole" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
bl.append("abcde");
t.write(cid, hoid, 0, 5, bl);
cerr << "Reverse fill-in" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
bl.append("abcde01234012340123401234abcde01234012340123401234abcde01234012340123401234abcde01234012340123401234");
t.write(cid, hoid, 0, bl.length(), bl);
cerr << "larger overwrite" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
bufferlist in;
t.truncate(cid, hoid, 0);
t.write(cid, hoid, 0x1000-1, bl.length(), bl);
cerr << "Write unaligned csum, stage 1" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
bl.append(s3);
t.write(cid, hoid, 1, bl.length(), bl);
cerr << "Write unaligned csum, stage 2" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
in.clear();
t.remove(cid, hoid);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
g_conf->apply_changes(NULL);
int r;
- ObjectStore::Sequencer osr("test");
coll_t cid;
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
ghobject_t hoid2 = hoid;
r = store->read(cid, hoid, 0, 5, in);
ASSERT_EQ(-ENOENT, r);
}
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.touch(cid, hoid);
cerr << "Creating object " << hoid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
exists = store->exists(cid, hoid);
ASSERT_EQ(g_conf->bluestore_block_size, statfs.total);
ASSERT_TRUE(statfs.available > 0u && statfs.available < g_conf->bluestore_block_size);
//force fsck
+ ch.reset();
EXPECT_EQ(store->umount(), 0);
EXPECT_EQ(store->mount(), 0);
+ ch = store->open_collection(cid);
}
{
ObjectStore::Transaction t;
bl.append("abcde");
t.write(cid, hoid, 0, 5, bl);
cerr << "Append 5 bytes" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct store_statfs_t statfs;
ASSERT_EQ(0, statfs.compressed_original);
ASSERT_EQ(0, statfs.compressed_allocated);
//force fsck
+ ch.reset();
EXPECT_EQ(store->umount(), 0);
EXPECT_EQ(store->mount(), 0);
+ ch = store->open_collection(cid);
}
{
ObjectStore::Transaction t;
bl.append(s);
t.write(cid, hoid, 0x10000, bl.length(), bl);
cerr << "Append 0x30000 compressible bytes" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct store_statfs_t statfs;
ASSERT_EQ(0x20000, statfs.compressed_original);
ASSERT_EQ(statfs.compressed_allocated, 0x10000);
//force fsck
+ ch.reset();
EXPECT_EQ(store->umount(), 0);
EXPECT_EQ(store->mount(), 0);
+ ch = store->open_collection(cid);
}
{
ObjectStore::Transaction t;
t.zero(cid, hoid, 1, 3);
t.zero(cid, hoid, 0x20000, 9);
cerr << "Punch hole at 1~3, 0x20000~9" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct store_statfs_t statfs;
ASSERT_EQ(0x20000 - 9, statfs.compressed_original);
ASSERT_EQ(statfs.compressed_allocated, 0x10000);
//force fsck
+ ch.reset();
EXPECT_EQ(store->umount(), 0);
EXPECT_EQ(store->mount(), 0);
+ ch = store->open_collection(cid);
}
{
ObjectStore::Transaction t;
t.write(cid, hoid, 1, bl.length(), bl);
t.write(cid, hoid, 0x10001, bl.length(), bl);
cerr << "Overwrite first and second(compressible) extents" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct store_statfs_t statfs;
ASSERT_EQ(0x20000 - 9 - 0x1000, statfs.compressed_original);
ASSERT_EQ(statfs.compressed_allocated, 0x10000);
//force fsck
+ ch.reset();
EXPECT_EQ(store->umount(), 0);
EXPECT_EQ(store->mount(), 0);
+ ch = store->open_collection(cid);
}
{
ObjectStore::Transaction t;
t.write(cid, hoid, 0x20000, bl.length(), bl);
t.write(cid, hoid, 0x30000, bl.length(), bl);
cerr << "Overwrite compressed extent with 3 uncompressible ones" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct store_statfs_t statfs;
ASSERT_EQ(0, statfs.compressed_original);
ASSERT_EQ(0, statfs.compressed_allocated);
//force fsck
+ ch.reset();
EXPECT_EQ(store->umount(), 0);
EXPECT_EQ(store->mount(), 0);
+ ch = store->open_collection(cid);
}
{
ObjectStore::Transaction t;
t.zero(cid, hoid, 0, 0x40000);
cerr << "Zero object" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct store_statfs_t statfs;
int r = store->statfs(&statfs);
ASSERT_EQ(0u, statfs.compressed);
ASSERT_EQ(0u, statfs.compressed_allocated);
//force fsck
+ ch.reset();
EXPECT_EQ(store->umount(), 0);
EXPECT_EQ(store->mount(), 0);
+ ch = store->open_collection(cid);
}
{
ObjectStore::Transaction t;
bl.append(s.substr(0, 0x10000-2));
t.write(cid, hoid, 0, bl.length(), bl);
cerr << "Yet another compressible write" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct store_statfs_t statfs;
r = store->statfs(&statfs);
ASSERT_EQ(0x20000, statfs.compressed_original);
ASSERT_EQ(0x10000, statfs.compressed_allocated);
//force fsck
+ ch.reset();
EXPECT_EQ(store->umount(), 0);
EXPECT_EQ(store->mount(), 0);
+ ch = store->open_collection(cid);
}
{
struct store_statfs_t statfs;
ObjectStore::Transaction t;
t.clone(cid, hoid, hoid2);
cerr << "Clone compressed objecte" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct store_statfs_t statfs2;
r = store->statfs(&statfs2);
t.remove(cid, hoid2);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct store_statfs_t statfs;
return;
StartDeferred(0x10000);
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.touch(cid, hoid);
cerr << "Creating object " << hoid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
exists = store->exists(cid, hoid);
t.write(cid, hoid, 0, bl.length(), bl);
t.zero(cid, hoid, 0x10000, 0x10000);
cerr << "Append 3*0x10000 bytes and punch a hole 0x10000~10000" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct store_statfs_t statfs;
newdata.clear();
}
//force fsck
+ ch.reset();
EXPECT_EQ(store->umount(), 0);
EXPECT_EQ(store->mount(), 0);
+ ch = store->open_collection(cid);
{
ObjectStore::Transaction t;
bl.append(data2);
t.write(cid, hoid, 0x20000, bl.length(), bl);
cerr << "Write 3 bytes after the hole" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct store_statfs_t statfs;
newdata.clear();
}
//force fsck
+ ch.reset();
EXPECT_EQ(store->umount(), 0);
EXPECT_EQ(store->mount(), 0);
+ ch = store->open_collection(cid);
{
ObjectStore::Transaction t;
bl.append(data2);
t.write(cid, hoid, 0x10000+1, bl.length(), bl);
cerr << "Write 3 bytes to the hole" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct store_statfs_t statfs;
t.zero(cid, hoid, 0, 0x10000);
t.zero(cid, hoid, 0x20000, 0x10000);
cerr << "Rewrite an object and create two holes at the begining and the end" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct store_statfs_t statfs;
}
//force fsck
+ ch.reset();
EXPECT_EQ(store->umount(), 0);
EXPECT_EQ(store->mount(), 0);
+ ch = store->open_collection(cid);
{
ObjectStore::Transaction t;
t.remove(cid, hoid);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct store_statfs_t statfs;
#endif
TEST_P(StoreTest, ManySmallWrite) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t a(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
ghobject_t b(hobject_t(sobject_t("Object 2", CEPH_NOSNAP)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
bufferlist bl;
for (int i=0; i<100; ++i) {
ObjectStore::Transaction t;
t.write(cid, a, i*4096, 4096, bl, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
for (int i=0; i<100; ++i) {
ObjectStore::Transaction t;
t.write(cid, b, (rand() % 1024)*4096, 4096, bl, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, b);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, MultiSmallWriteSameBlock) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t a(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
bufferlist bl;
u.write(cid, a, 10, 5, bl, 0);
u.write(cid, a, 7000, 5, bl, 0);
vector<ObjectStore::Transaction> v = {t, u};
- store->queue_transactions(&osr, v, nullptr, &c);
+ store->queue_transactions(ch, v, nullptr, &c);
}
{
ObjectStore::Transaction t, u;
u.write(cid, a, 610, 5, bl, 0);
u.write(cid, a, 11000, 5, bl, 0);
vector<ObjectStore::Transaction> v = {t, u};
- store->queue_transactions(&osr, v, nullptr, &d);
+ store->queue_transactions(ch, v, nullptr, &d);
}
c.wait();
d.wait();
t.remove(cid, a);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, SmallSkipFront) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t a(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.touch(cid, a);
t.truncate(cid, a, 3000);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
bl.append(bp);
ObjectStore::Transaction t;
t.write(cid, a, 4096, 4096, bl);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, a);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, AppendDeferredVsTailCache) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t a(hobject_t(sobject_t("fooo", CEPH_NOSNAP)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = store->apply_transaction(&osr, std::move(t));
+ r = store->apply_transaction(ch, std::move(t));
ASSERT_EQ(r, 0);
}
unsigned min_alloc = g_conf->bluestore_min_alloc_size;
{
ObjectStore::Transaction t;
t.write(cid, a, 0, bla.length(), bla, 0);
- r = store->apply_transaction(&osr, std::move(t));
+ r = store->apply_transaction(ch, std::move(t));
ASSERT_EQ(r, 0);
}
// force cached tail to clear ...
{
+ ch.reset();
int r = store->umount();
ASSERT_EQ(0, r);
r = store->mount();
ASSERT_EQ(0, r);
+ ch = store->open_collection(cid);
}
bufferptr bpb(size);
{
ObjectStore::Transaction t;
t.write(cid, a, bla.length(), blb.length(), blb, 0);
- r = store->apply_transaction(&osr, std::move(t));
+ r = store->apply_transaction(ch, std::move(t));
ASSERT_EQ(r, 0);
}
bufferptr bpc(size);
{
ObjectStore::Transaction t;
t.write(cid, a, bla.length() + blb.length(), blc.length(), blc, 0);
- r = store->apply_transaction(&osr, std::move(t));
+ r = store->apply_transaction(ch, std::move(t));
ASSERT_EQ(r, 0);
}
bufferlist final;
t.remove(cid, a);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = store->apply_transaction(&osr, std::move(t));
+ r = store->apply_transaction(ch, std::move(t));
ASSERT_EQ(r, 0);
}
g_conf->set_val("bluestore_inject_deferred_apply_delay", "0");
}
TEST_P(StoreTest, AppendZeroTrailingSharedBlock) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t a(hobject_t(sobject_t("fooo", CEPH_NOSNAP)));
ghobject_t b = a;
b.hobj.snap = 1;
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = store->apply_transaction(&osr, std::move(t));
+ r = store->apply_transaction(ch, std::move(t));
ASSERT_EQ(r, 0);
}
unsigned min_alloc = g_conf->bluestore_min_alloc_size;
bt.append("BADBADBADBAD");
ObjectStore::Transaction t;
t.write(cid, a, 0, bt.length(), bt, 0);
- r = store->apply_transaction(&osr, std::move(t));
+ r = store->apply_transaction(ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.truncate(cid, a, size);
- r = store->apply_transaction(&osr, std::move(t));
+ r = store->apply_transaction(ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.clone(cid, a, b);
- r = store->apply_transaction(&osr, std::move(t));
+ r = store->apply_transaction(ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.write(cid, a, min_alloc * 3, blb.length(), blb, 0);
- r = store->apply_transaction(&osr, std::move(t));
+ r = store->apply_transaction(ch, std::move(t));
ASSERT_EQ(r, 0);
}
bufferlist final;
t.remove(cid, b);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = store->apply_transaction(&osr, std::move(t));
+ r = store->apply_transaction(ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, SmallSequentialUnaligned) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t a(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
bufferlist bl;
for (int i=0; i<1000; ++i) {
ObjectStore::Transaction t;
t.write(cid, a, i*len, len, bl, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, a);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, ManyBigWrite) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t a(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
ghobject_t b(hobject_t(sobject_t("Object 2", CEPH_NOSNAP)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
bufferlist bl;
for (int i=0; i<10; ++i) {
ObjectStore::Transaction t;
t.write(cid, a, i*4*1048586, 4*1048576, bl, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
// aligned
for (int i=0; i<10; ++i) {
ObjectStore::Transaction t;
t.write(cid, b, (rand() % 256)*4*1048576, 4*1048576, bl, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
// unaligned
for (int i=0; i<10; ++i) {
ObjectStore::Transaction t;
t.write(cid, b, (rand() % (256*4096))*1024, 4*1048576, bl, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
// do some zeros
for (int i=0; i<10; ++i) {
ObjectStore::Transaction t;
t.zero(cid, b, (rand() % (256*4096))*1024, 16*1048576);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, b);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, BigWriteBigZero) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t a(hobject_t(sobject_t("foo", CEPH_NOSNAP)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
bufferlist bl;
{
ObjectStore::Transaction t;
t.write(cid, a, 0, bl.length(), bl);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.zero(cid, a, bl.length() / 4, bl.length() / 2);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.write(cid, a, bl.length() / 2, s.length(), s);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.remove(cid, a);
t.remove_collection(cid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, MiscFragmentTests) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t a(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
bufferlist bl;
{
ObjectStore::Transaction t;
t.write(cid, a, 0, 524288, bl, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.write(cid, a, 1048576, 524288, bl, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
{
ObjectStore::Transaction t;
t.write(cid, a, 1048576 - 4096, 524288, bl, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, a);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, ZeroVsObjectSize) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
struct stat stat;
ghobject_t hoid(hobject_t(sobject_t("foo", CEPH_NOSNAP)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
bufferlist a;
{
ObjectStore::Transaction t;
t.write(cid, hoid, 0, 5, a);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_EQ(0, store->stat(cid, hoid, &stat));
{
ObjectStore::Transaction t;
t.zero(cid, hoid, 1, 2);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_EQ(0, store->stat(cid, hoid, &stat));
{
ObjectStore::Transaction t;
t.zero(cid, hoid, 3, 200);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_EQ(0, store->stat(cid, hoid, &stat));
{
ObjectStore::Transaction t;
t.zero(cid, hoid, 100000, 200);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_EQ(0, store->stat(cid, hoid, &stat));
}
TEST_P(StoreTest, ZeroLengthWrite) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t hoid(hobject_t(sobject_t("foo", CEPH_NOSNAP)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
t.touch(cid, hoid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
bufferlist empty;
t.write(cid, hoid, 1048576, 0, empty);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
struct stat stat;
}
TEST_P(StoreTest, ZeroLengthZero) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t hoid(hobject_t(sobject_t("foo", CEPH_NOSNAP)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
t.touch(cid, hoid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(0, r);
}
{
ObjectStore::Transaction t;
t.zero(cid, hoid, 1048576, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(0, r);
}
struct stat stat;
}
TEST_P(StoreTest, SimpleAttrTest) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t hoid(hobject_t(sobject_t("attr object 1", CEPH_NOSNAP)));
r = store->getattrs(cid, hoid, aset);
ASSERT_EQ(-ENOENT, r);
}
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- osr.flush();
+ ch->flush();
{
bool empty;
int r = store->collection_empty(cid, &empty);
t.touch(cid, hoid);
t.setattr(cid, hoid, "foo", val);
t.setattr(cid, hoid, "bar", val2);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- osr.flush();
+ ch->flush();
{
bool empty;
int r = store->collection_empty(cid, &empty);
ObjectStore::Transaction t;
t.remove(cid, hoid);
t.remove_collection(cid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, SimpleListTest) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid(spg_t(pg_t(0, 1), shard_id_t(1)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
set<ghobject_t> all;
t.touch(cid, hoid);
cerr << "Creating object " << hoid << std::endl;
}
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- osr.flush();
+ ch->flush();
{
set<ghobject_t> saw;
vector<ghobject_t> objects;
t.remove(cid, *p);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, ListEndTest) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid(spg_t(pg_t(0, 1), shard_id_t(1)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
set<ghobject_t> all;
t.touch(cid, hoid);
cerr << "Creating object " << hoid << std::endl;
}
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- osr.flush();
+ ch->flush();
{
ghobject_t end(hobject_t(sobject_t("object_100", CEPH_NOSNAP)),
ghobject_t::NO_GEN, shard_id_t(1));
t.remove(cid, *p);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
}
TEST_P(StoreTest, MultipoolListTest) {
- ObjectStore::Sequencer osr("test");
int r;
int poolid = 4373;
coll_t cid = coll_t(spg_t(pg_t(0, poolid), shard_id_t::NO_SHARD));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
set<ghobject_t> all, saw;
t.touch(cid, hoid);
cerr << "Creating object " << hoid << std::endl;
}
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- osr.flush();
+ ch->flush();
{
vector<ghobject_t> objects;
ghobject_t next, current;
t.remove(cid, *p);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, SimpleCloneTest) {
- ObjectStore::Sequencer osr("test");
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 = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP),
t.write(cid, hoid, 0, small.length(), small);
t.write(cid, hoid, 10, small.length(), small);
cerr << "Creating object and set attr " << hoid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
t.setattr(cid, hoid, "attr1", large);
t.setattr(cid, hoid, "attr2", small);
cerr << "Clone object and rm attr" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
r = store->read(cid, hoid, 10, 5, newdata);
ObjectStore::Transaction t;
t.remove(cid, hoid);
t.remove(cid, hoid2);
- ASSERT_EQ(0, apply_transaction(store, &osr, std::move(t)));
+ ASSERT_EQ(0, apply_transaction(store, ch, std::move(t)));
}
{
bufferlist final;
al.append(a);
final.append(a);
t.write(cid, hoid, pl.length(), a.length(), al);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
bufferlist rl;
ASSERT_EQ((int)final.length(),
ObjectStore::Transaction t;
t.remove(cid, hoid);
t.remove(cid, hoid2);
- ASSERT_EQ(0, apply_transaction(store, &osr, std::move(t)));
+ ASSERT_EQ(0, apply_transaction(store, ch, std::move(t)));
}
{
bufferlist final;
al.append(a);
final.append(a);
t.write(cid, hoid, pl.length() + z.length(), a.length(), al);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
bufferlist rl;
ASSERT_EQ((int)final.length(),
ObjectStore::Transaction t;
t.remove(cid, hoid);
t.remove(cid, hoid2);
- ASSERT_EQ(0, apply_transaction(store, &osr, std::move(t)));
+ ASSERT_EQ(0, apply_transaction(store, ch, std::move(t)));
}
{
bufferlist final;
al.append(a);
final.append(a);
t.write(cid, hoid, 17000, a.length(), al);
- ASSERT_EQ(0, apply_transaction(store, &osr, std::move(t)));
+ ASSERT_EQ(0, apply_transaction(store, ch, std::move(t)));
bufferlist rl;
ASSERT_EQ((int)final.length(),
store->read(cid, hoid, 0, final.length(), rl));
ObjectStore::Transaction t;
t.remove(cid, hoid);
t.remove(cid, hoid2);
- ASSERT_EQ(0, apply_transaction(store, &osr, std::move(t)));
+ ASSERT_EQ(0, apply_transaction(store, ch, std::move(t)));
}
{
bufferptr p(1048576);
bufferlist al;
al.append(a);
t.write(cid, hoid, a.length(), a.length(), al);
- ASSERT_EQ(0, apply_transaction(store, &osr, std::move(t)));
+ ASSERT_EQ(0, apply_transaction(store, ch, std::move(t)));
bufferlist rl;
bufferlist final;
final.substr_of(pl, 0, al.length());
ObjectStore::Transaction t;
t.remove(cid, hoid);
t.remove(cid, hoid2);
- ASSERT_EQ(0, apply_transaction(store, &osr, std::move(t)));
+ ASSERT_EQ(0, apply_transaction(store, ch, std::move(t)));
}
{
bufferptr p(65536);
bufferlist al;
al.append(a);
t.write(cid, hoid, 32768, a.length(), al);
- ASSERT_EQ(0, apply_transaction(store, &osr, std::move(t)));
+ ASSERT_EQ(0, apply_transaction(store, ch, std::move(t)));
bufferlist rl;
bufferlist final;
final.substr_of(pl, 0, 32768);
ObjectStore::Transaction t;
t.remove(cid, hoid);
t.remove(cid, hoid2);
- ASSERT_EQ(0, apply_transaction(store, &osr, std::move(t)));
+ ASSERT_EQ(0, apply_transaction(store, ch, std::move(t)));
}
{
bufferptr p(65536);
bufferlist al;
al.append(a);
t.write(cid, hoid, 33768, a.length(), al);
- ASSERT_EQ(0, apply_transaction(store, &osr, std::move(t)));
+ ASSERT_EQ(0, apply_transaction(store, ch, std::move(t)));
bufferlist rl;
bufferlist final;
final.substr_of(pl, 0, 33768);
//
if (string(GetParam()) != "filestore") {
//verify if non-empty collection is properly handled after store reload
+ ch.reset();
r = store->umount();
ASSERT_EQ(r, 0);
r = store->mount();
ASSERT_EQ(r, 0);
+ ch = store->open_collection(cid);
ObjectStore::Transaction t;
t.remove_collection(cid);
cerr << "Invalid rm coll" << std::endl;
PrCtl unset_dumpable;
- EXPECT_DEATH(apply_transaction(store, &osr, std::move(t)), "");
+ EXPECT_DEATH(apply_transaction(store, ch, std::move(t)), "");
}
{
ObjectStore::Transaction t;
t.touch(cid, hoid3); //new record in db
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
//See comment above for "filestore" check explanation.
ObjectStore::Transaction t;
//verify if non-empty collection is properly handled when there are some pending removes and live records in db
cerr << "Invalid rm coll again" << std::endl;
+ ch.reset();
r = store->umount();
ASSERT_EQ(r, 0);
r = store->mount();
ASSERT_EQ(r, 0);
+ ch = store->open_collection(cid);
t.remove(cid, hoid);
t.remove(cid, hoid2);
t.remove_collection(cid);
PrCtl unset_dumpable;
- EXPECT_DEATH(apply_transaction(store, &osr, std::move(t)), "");
+ EXPECT_DEATH(apply_transaction(store, ch, std::move(t)), "");
}
{
ObjectStore::Transaction t;
t.remove(cid, hoid3);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, OmapSimple) {
- ObjectStore::Sequencer osr("test");
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 = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ghobject_t hoid(hobject_t(sobject_t("omap_obj", CEPH_NOSNAP),
t.omap_setkeys(cid, hoid, km);
t.omap_setheader(cid, hoid, header);
cerr << "Creating object and set omap " << hoid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
// get header, keys
t.remove(cid, hoid);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, OmapCloneTest) {
- ObjectStore::Sequencer osr("test");
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 = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP),
t.omap_setkeys(cid, hoid, km);
t.omap_setheader(cid, hoid, header);
cerr << "Creating object and set omap " << hoid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ghobject_t hoid2(hobject_t(sobject_t("Object 2", CEPH_NOSNAP),
ObjectStore::Transaction t;
t.clone(cid, hoid, hoid2);
cerr << "Clone object" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, hoid2);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, SimpleCloneRangeTest) {
- ObjectStore::Sequencer osr("test");
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 = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
ObjectStore::Transaction t;
t.write(cid, hoid, 10, 5, small);
cerr << "Creating object and write bl " << hoid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ghobject_t hoid2(hobject_t(sobject_t("Object 2", CEPH_NOSNAP)));
ObjectStore::Transaction t;
t.clone_range(cid, hoid, hoid2, 10, 5, 10);
cerr << "Clone range object" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
r = store->read(cid, hoid2, 10, 5, newdata);
ASSERT_EQ(r, 5);
t.truncate(cid, hoid, 1024*1024);
t.clone_range(cid, hoid, hoid2, 0, 1024*1024, 0);
cerr << "Clone range object" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
struct stat stat, stat2;
r = store->stat(cid, hoid, &stat);
t.remove(cid, hoid2);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, SimpleObjectLongnameTest) {
- ObjectStore::Sequencer osr("test");
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 = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ghobject_t hoid(hobject_t(sobject_t("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaObjectaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 1", CEPH_NOSNAP)));
ObjectStore::Transaction t;
t.touch(cid, hoid);
cerr << "Creating object " << hoid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, hoid);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
}
TEST_P(StoreTest, LongnameSplitTest) {
- ObjectStore::Sequencer osr("test");
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 = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(0, r);
}
for (unsigned i = 0; i < 320; ++i) {
ghobject_t hoid = generate_long_name(i);
t.touch(cid, hoid);
cerr << "Creating object " << hoid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(0, r);
}
t.collection_move_rename(
cid, test_obj,
cid, test_obj_2);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(0, r);
}
ghobject_t hoid = generate_long_name(i);
t.remove(cid, hoid);
cerr << "Removing object " << hoid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(0, r);
}
{
t.remove(cid, test_obj_2);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(0, r);
}
}
TEST_P(StoreTest, ManyObjectTest) {
- ObjectStore::Sequencer osr("test");
int NUM_OBJS = 2000;
int r = 0;
coll_t cid;
string base = "";
for (int i = 0; i < 100; ++i) base.append("aaaaa");
set<ghobject_t> created;
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
for (int i = 0; i < NUM_OBJS; ++i) {
ghobject_t hoid(hobject_t(sobject_t(string(buf) + base, CEPH_NOSNAP)));
t.touch(cid, hoid);
created.insert(hoid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_TRUE(!store->stat(cid, *i, &buf));
}
- osr.flush();
+ ch->flush();
set<ghobject_t> listed, listed2;
vector<ghobject_t> objects;
++i) {
ObjectStore::Transaction t;
t.remove(cid, *i);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
cerr << "cleaning up" << std::endl;
{
ObjectStore::Transaction t;
t.remove_collection(cid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
ObjectGenerator *object_gen;
gen_type *rng;
ObjectStore *store;
- ObjectStore::Sequencer *osr;
+ ObjectStore::CollectionHandle ch;
Mutex lock;
Cond cond;
SyntheticWorkloadState(ObjectStore *store,
ObjectGenerator *gen,
gen_type *rng,
- ObjectStore::Sequencer *osr,
coll_t cid,
unsigned max_size,
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") {}
+ rng(rng), store(store),
+ lock("State lock") {}
int init() {
ObjectStore::Transaction t;
+ ch = store->create_new_collection(cid);
t.create_collection(cid, 0);
- return apply_transaction(store, osr, std::move(t));
+ return apply_transaction(store, ch, std::move(t));
}
void shutdown() {
while (1) {
- osr->flush();
+ ch->flush();
vector<ghobject_t> objects;
int r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(),
10, &objects, 0);
p != objects.end(); ++p) {
t.remove(cid, *p);
}
- apply_transaction(store, osr, std::move(t));
+ apply_transaction(store, ch, std::move(t));
}
ObjectStore::Transaction t;
t.remove_collection(cid);
- apply_transaction(store, osr, std::move(t));
+ apply_transaction(store, ch, std::move(t));
}
void statfs(store_statfs_t& stat) {
store->statfs(&stat);
}
void wait_for_done() {
- osr->flush();
+ ch->flush();
Mutex::Locker locker(lock);
while (in_flight)
cond.Wait(lock);
in_flight_objects.insert(new_obj);
if (!contents.count(new_obj))
contents[new_obj] = Object();
- int status = store->queue_transaction(osr, std::move(t), new C_SyntheticOnReadable(this, new_obj));
+ int status = store->queue_transaction(ch, std::move(t), new C_SyntheticOnReadable(this, new_obj));
return status;
}
contents[new_obj].data = contents[old_obj].data;
contents.erase(old_obj);
int status = store->queue_transaction(
- osr, std::move(t),
+ ch, std::move(t),
new C_SyntheticOnStash(this, old_obj, new_obj));
return status;
}
contents[new_obj].data = contents[old_obj].data;
int status = store->queue_transaction(
- osr, std::move(t),
+ ch, std::move(t),
new C_SyntheticOnClone(this, old_obj, new_obj));
return status;
}
}
int status = store->queue_transaction(
- osr, std::move(t), new C_SyntheticOnClone(this, old_obj, new_obj));
+ ch, std::move(t), new C_SyntheticOnClone(this, old_obj, new_obj));
return status;
}
++in_flight;
in_flight_objects.insert(new_obj);
int status = store->queue_transaction(
- osr, std::move(t), new C_SyntheticOnReadable(this, new_obj));
+ ch, std::move(t), new C_SyntheticOnReadable(this, new_obj));
return status;
}
}
int status = store->queue_transaction(
- osr, std::move(t), new C_SyntheticOnReadable(this, obj));
+ ch, std::move(t), new C_SyntheticOnReadable(this, obj));
return status;
}
++in_flight;
in_flight_objects.insert(new_obj);
int status = store->queue_transaction(
- osr, std::move(t), new C_SyntheticOnReadable(this, new_obj));
+ ch, std::move(t), new C_SyntheticOnReadable(this, new_obj));
return status;
}
++in_flight;
in_flight_objects.insert(obj);
int status = store->queue_transaction(
- osr, std::move(t), new C_SyntheticOnReadable(this, obj));
+ ch, std::move(t), new C_SyntheticOnReadable(this, obj));
return status;
}
++in_flight;
in_flight_objects.insert(obj);
int status = store->queue_transaction(
- osr, std::move(t), new C_SyntheticOnReadable(this, obj));
+ ch, std::move(t), new C_SyntheticOnReadable(this, obj));
return status;
}
EnterExit ee("fsck");
while (in_flight)
cond.Wait(lock);
+ ch.reset();
store->umount();
int r = store->fsck(deep);
assert(r == 0 || r == -EOPNOTSUPP);
store->mount();
+ ch = store->open_collection(cid);
}
void scan() {
EnterExit ee("scan");
while (in_flight)
cond.Wait(lock);
- osr->flush();
+ ch->flush();
vector<ghobject_t> objects;
set<ghobject_t> objects_set, objects_set2;
ghobject_t next, current;
available_objects.erase(to_remove);
in_flight_objects.insert(to_remove);
contents.erase(to_remove);
- int status = store->queue_transaction(osr, std::move(t), new C_SyntheticOnReadable(this, to_remove));
+ int status = store->queue_transaction(ch, std::move(t), new C_SyntheticOnReadable(this, to_remove));
return status;
}
int num_ops,
uint64_t max_obj, uint64_t max_wr, uint64_t align)
{
- 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));
g_ceph_context->_conf->set_val("bluestore_fsck_on_umount", "false");
g_ceph_context->_conf->apply_changes(NULL);
- SyntheticWorkloadState test_obj(store.get(), &gen, &rng, &osr, cid,
+ SyntheticWorkloadState test_obj(store.get(), &gen, &rng, cid,
max_obj, max_wr, align);
test_obj.init();
for (int i = 0; i < num_ops/10; ++i) {
StartDeferred(4096);
int r;
- ObjectStore::Sequencer osr("test");
coll_t cid;
ghobject_t a(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
bufferlist bl;
for (int i=0; i<1000; ++i) {
ObjectStore::Transaction t;
t.write(cid, a, i*2*len, len, bl, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
for (int i=0; i<1000; ++i) {
ObjectStore::Transaction t;
t.write(cid, a, i*2*len + 1, len, bl, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, a);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
}
TEST_P(StoreTest, AttrSynthetic) {
- ObjectStore::Sequencer osr("test");
MixedGenerator gen(447);
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, 0);
+ SyntheticWorkloadState test_obj(store.get(), &gen, &rng, 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;
}
TEST_P(StoreTest, HashCollisionTest) {
- ObjectStore::Sequencer osr("test");
int64_t poolid = 11;
coll_t cid(spg_t(pg_t(0,poolid),shard_id_t::NO_SHARD));
int r;
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
string base = "";
{
ObjectStore::Transaction t;
t.touch(cid, hoid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
created.insert(hoid);
}
}
vector<ghobject_t> objects;
- osr.flush();
+ ch->flush();
r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(), INT_MAX, &objects, 0);
ASSERT_EQ(r, 0);
set<ghobject_t> listed(objects.begin(), objects.end());
++i) {
ObjectStore::Transaction t;
t.remove(cid, *i);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ObjectStore::Transaction t;
t.remove_collection(cid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
TEST_P(StoreTest, ScrubTest) {
- ObjectStore::Sequencer osr("test");
int64_t poolid = 111;
coll_t cid(spg_t(pg_t(0, poolid),shard_id_t(1)));
int r;
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
string base = "aaaaa";
{
ObjectStore::Transaction t;
t.touch(cid, hoid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
created.insert(hoid);
t.touch(cid, hoid1);
t.touch(cid, hoid2);
t.touch(cid, hoid3);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
created.insert(hoid1);
created.insert(hoid2);
created.insert(hoid3);
ASSERT_EQ(r, 0);
}
- osr.flush();
+ ch->flush();
vector<ghobject_t> objects;
r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
++i) {
ObjectStore::Transaction t;
t.remove(cid, *i);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ObjectStore::Transaction t;
t.remove_collection(cid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
TEST_P(StoreTest, OMapTest) {
- ObjectStore::Sequencer osr("test");
coll_t cid;
ghobject_t hoid(hobject_t("tesomap", "", CEPH_NOSNAP, 0, 0, ""));
+ auto ch = store->create_new_collection(cid);
int r;
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
t.omap_clear(cid, hoid);
map<string, bufferlist> start_set;
t.omap_setkeys(cid, hoid, start_set);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
to_add.insert(pair<string, bufferlist>("key-" + string(buf), bl));
attrs.insert(pair<string, bufferlist>("key-" + string(buf), bl));
t.omap_setkeys(cid, hoid, to_add);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
set<string> keys_to_remove;
keys_to_remove.insert(to_remove);
t.omap_rmkeys(cid, hoid, keys_to_remove);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
attrs.erase(to_remove);
bl1.append("omap_header");
ObjectStore::Transaction t;
t.omap_setheader(cid, hoid, bl1);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
t = ObjectStore::Transaction();
map<string, bufferlist> to_add;
to_add.insert(pair<string, bufferlist>("key", bl2));
t.omap_setkeys(cid, hoid, to_add);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
bufferlist bl3;
t.touch(cid, hoid);
t.omap_setheader(cid, hoid, h);
t.omap_setkeys(cid, hoid, to_set);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.omap_rmkeyrange(cid, hoid, "3", "7");
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
{
ObjectStore::Transaction t;
t.omap_clear(cid, hoid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.remove(cid, hoid);
t.remove_collection(cid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
TEST_P(StoreTest, OMapIterator) {
- ObjectStore::Sequencer osr("test");
coll_t cid;
ghobject_t hoid(hobject_t("tesomap", "", CEPH_NOSNAP, 0, 0, ""));
int count = 0;
+ auto ch = store->create_new_collection(cid);
int r;
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
t.omap_clear(cid, hoid);
map<string, bufferlist> start_set;
t.omap_setkeys(cid, hoid, start_set);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ObjectMap::ObjectMapIterator iter;
attrs.insert(pair<string, bufferlist>("key-" + string(buf), bl));
ObjectStore::Transaction t;
t.omap_setkeys(cid, hoid, to_add);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ObjectStore::Transaction t;
t.remove(cid, hoid);
t.remove_collection(cid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, XattrTest) {
- ObjectStore::Sequencer osr("test");
coll_t cid;
ghobject_t hoid(hobject_t("tesomap", "", CEPH_NOSNAP, 0, 0, ""));
bufferlist big;
small.append('\0');
}
int r;
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
t.touch(cid, hoid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
attrs["attr4"] = big;
t.setattr(cid, hoid, "attr3", big);
attrs["attr3"] = big;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ObjectStore::Transaction t;
t.rmattr(cid, hoid, "attr2");
attrs.erase("attr2");
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ObjectStore::Transaction t;
t.remove(cid, hoid);
t.remove_collection(cid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
unsigned common_suffix_size,
bool clones
) {
- ObjectStore::Sequencer osr("test");
coll_t cid(spg_t(pg_t(0,52),shard_id_t::NO_SHARD));
coll_t tid(spg_t(pg_t(1<<common_suffix_size,52),shard_id_t::NO_SHARD));
+ auto ch = store->create_new_collection(cid);
+ auto tch = store->create_new_collection(tid);
int r = 0;
{
ObjectStore::Transaction t;
t.create_collection(cid, common_suffix_size);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
bufferlist small;
t.clone(cid, a, b);
}
if (i % 100) {
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
t = ObjectStore::Transaction();
}
}
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.create_collection(tid, common_suffix_size + 1);
t.split_collection(cid, common_suffix_size+1, 1<<common_suffix_size, tid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, tch, std::move(t));
ASSERT_EQ(r, 0);
}
- osr.flush();
+ ch->flush();
ObjectStore::Transaction t;
vector<ghobject_t> objects;
r = store->collection_list(cid, ghobject_t(), ghobject_t::get_max(),
t.remove(cid, *i);
if (++size > 100) {
size = 0;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
t = ObjectStore::Transaction();
}
}
- osr.flush();
+ ch->flush();
objects.clear();
r = store->collection_list(tid, ghobject_t(), ghobject_t::get_max(),
INT_MAX, &objects, 0);
t.remove(tid, *i);
if (++size > 100) {
size = 0;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, tch, std::move(t));
ASSERT_EQ(r, 0);
t = ObjectStore::Transaction();
}
t.remove_collection(cid);
t.remove_collection(tid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, tch, std::move(t));
ASSERT_EQ(r, 0);
}
* stops at the common prefix subdir. See bug
* #5273 */
TEST_P(StoreTest, TwoHash) {
- ObjectStore::Sequencer osr("test");
coll_t cid;
int r;
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
std::cout << "Making objects" << std::endl;
}
o.hobj.set_hash((i << 16) | 0xB1);
t.touch(cid, o);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
std::cout << "Removing half" << std::endl;
o.hobj.pool = -1;
o.hobj.set_hash((i << 16) | 0xA1);
t.remove(cid, o);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
std::cout << "Checking" << std::endl;
t.remove(cid, o);
o.hobj.set_hash((i << 16) | 0xB1);
t.remove(cid, o);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ObjectStore::Transaction t;
t.remove_collection(cid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
TEST_P(StoreTest, Rename) {
- ObjectStore::Sequencer osr("test");
coll_t cid(spg_t(pg_t(0, 2122),shard_id_t::NO_SHARD));
ghobject_t srcoid(hobject_t("src_oid", "", CEPH_NOSNAP, 0, 0, ""));
ghobject_t dstoid(hobject_t("dest_oid", "", CEPH_NOSNAP, 0, 0, ""));
bufferlist a, b;
a.append("foo");
b.append("bar");
+ auto ch = store->create_new_collection(cid);
int r;
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
t.write(cid, srcoid, 0, a.length(), a);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_TRUE(store->exists(cid, srcoid));
t.collection_move_rename(cid, srcoid, cid, dstoid);
t.write(cid, srcoid, 0, b.length(), b);
t.setattr(cid, srcoid, "attr", b);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_TRUE(store->exists(cid, srcoid));
ObjectStore::Transaction t;
t.remove(cid, dstoid);
t.collection_move_rename(cid, srcoid, cid, dstoid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_TRUE(store->exists(cid, dstoid));
ObjectStore::Transaction t;
t.remove(cid, dstoid);
t.remove_collection(cid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, MoveRename) {
- ObjectStore::Sequencer osr("test");
coll_t cid(spg_t(pg_t(0, 212),shard_id_t::NO_SHARD));
ghobject_t temp_oid(hobject_t("tmp_oid", "", CEPH_NOSNAP, 0, 0, ""));
ghobject_t oid(hobject_t("dest_oid", "", CEPH_NOSNAP, 0, 0, ""));
+ auto ch = store->create_new_collection(cid);
int r;
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
t.touch(cid, oid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_TRUE(store->exists(cid, oid));
t.write(cid, temp_oid, 0, data.length(), data);
t.setattr(cid, temp_oid, "attr", attr);
t.omap_setkeys(cid, temp_oid, omap);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_TRUE(store->exists(cid, temp_oid));
ObjectStore::Transaction t;
t.remove(cid, oid);
t.collection_move_rename(cid, temp_oid, cid, oid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ASSERT_TRUE(store->exists(cid, oid));
ObjectStore::Transaction t;
t.remove(cid, oid);
t.remove_collection(cid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, BigRGWObjectName) {
- ObjectStore::Sequencer osr("test");
coll_t cid(spg_t(pg_t(0,12),shard_id_t::NO_SHARD));
ghobject_t oid(
hobject_t(
ghobject_t oidhead(oid);
oidhead.generation = ghobject_t::NO_GEN;
+ auto ch = store->create_new_collection(cid);
+
int r;
{
ObjectStore::Transaction t;
t.collection_move_rename(cid, oidhead, cid, oid);
t.touch(cid, oidhead);
t.collection_move_rename(cid, oidhead, cid, oid2);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.remove(cid, oid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
- osr.flush();
+ ch->flush();
{
vector<ghobject_t> objects;
ObjectStore::Transaction t;
t.remove(cid, oid2);
t.remove_collection(cid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, SetAllocHint) {
- ObjectStore::Sequencer osr("test");
coll_t cid;
ghobject_t hoid(hobject_t("test_hint", "", CEPH_NOSNAP, 0, 0, ""));
+ auto ch = store->create_new_collection(cid);
int r;
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
t.touch(cid, hoid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.set_alloc_hint(cid, hoid, 4*1024*1024, 1024*4, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.remove(cid, hoid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.set_alloc_hint(cid, hoid, 4*1024*1024, 1024*4, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.remove_collection(cid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
TEST_P(StoreTest, TryMoveRename) {
- ObjectStore::Sequencer osr("test");
coll_t cid;
ghobject_t hoid(hobject_t("test_hint", "", CEPH_NOSNAP, 0, -1, ""));
ghobject_t hoid2(hobject_t("test_hint2", "", CEPH_NOSNAP, 0, -1, ""));
+ auto ch = store->create_new_collection(cid);
int r;
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.try_rename(cid, hoid, hoid2);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.touch(cid, hoid);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
ObjectStore::Transaction t;
t.try_rename(cid, hoid, hoid2);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
struct stat st;
g_conf->set_val("bluestore_csum_type", "crc32c");
g_conf->apply_changes(NULL);
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
r = store->read(cid, hoid, 0, 5, in);
ASSERT_EQ(-ENOENT, r);
}
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.set_alloc_hint(cid, hoid, 4*1024*1024, 1024*8, 0);
t.write(cid, hoid, 0, bl.length(), bl);
cerr << "Remove then create" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
g_conf->set_val("bluestore_csum_type", "none");
t.set_alloc_hint(cid, hoid, 4*1024*1024, 1024*8, 0);
t.write(cid, hoid, 0, bl.length(), bl);
cerr << "Remove then create" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
g_conf->set_val("bluestore_csum_type", "crc32c");
t.remove(cid, hoid);
t.write(cid, hoid, 0, bl.length(), bl);
cerr << "Remove then create" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
g_conf->set_val("bluestore_csum_type", "none");
ObjectStore::Transaction t2;
t2.write(cid, hoid, block_size*2, bl.length(), bl);
cerr << "Append 'unprotected'" << std::endl;
- r = apply_transaction(store, &osr, std::move(t2));
+ r = apply_transaction(store, ch, std::move(t2));
ASSERT_EQ(r, 0);
bufferlist in;
t.set_alloc_hint(cid, hoid, 4*1024*1024, 1024*8, 0);
t.write(cid, hoid, 0, bl.length(), bl);
cerr << "Remove then create" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
g_conf->set_val("bluestore_csum_type", "none");
t2.write(cid, hoid, 0, bl.length(), bl);
t2.write(cid, hoid, block_size0, bl.length(), bl);
cerr << "Overwrite with unprotected data" << std::endl;
- r = apply_transaction(store, &osr, std::move(t2));
+ r = apply_transaction(store, ch, std::move(t2));
ASSERT_EQ(r, 0);
orig = bl;
bl.append(std::string(block_size2, 'c'));
t3.write(cid, hoid, block_size0, bl.length(), bl);
cerr << "Overwrite with protected data" << std::endl;
- r = apply_transaction(store, &osr, std::move(t3));
+ r = apply_transaction(store, ch, std::move(t3));
ASSERT_EQ(r, 0);
in.clear();
t.remove(cid, hoid);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
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,
max_object_size,
max_write_size,
g_conf->set_val("bluestore_cache_size_ssd", "400000000");
g_conf->apply_changes(NULL);
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t hoid(hobject_t("test_hint", "", CEPH_NOSNAP, 0, -1, ""));
get_mempool_stats(&total_bytes, &total_onodes);
ASSERT_EQ(total_onodes, 0u);
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
bl.append(std::string(obj_size, 'a'));
t.write(cid, hoid, 0, bl.length(), bl);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
get_mempool_stats(&total_bytes, &total_onodes);
{
ObjectStore::Transaction t;
t.truncate(cid, hoid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
for( size_t j = 0; j < obj_size; j+= bl.length()) {
ObjectStore::Transaction t;
t.write(cid, hoid, j, bl.length(), bl);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
get_mempool_stats(&total_bytes2, &total_onodes);
t.remove(cid, hoid);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
g_ceph_context->_conf->set_val("bluestore_cache_size_hdd", "4000000");
g_conf->set_val("bluestore_max_blob_size", "65536");
g_conf->apply_changes(NULL);
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t hoid(hobject_t("test_hint", "", CEPH_NOSNAP, 0, -1, ""));
const PerfCounters* logger = store->get_perf_counters();
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
bl.append(std::string(block_size * 2, 'a'));
t.write(cid, hoid, 0, bl.length(), bl, CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
bl.append(std::string(block_size, 'b'));
t.write(cid, hoid, 0, bl.length(), bl, CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
bl.append(std::string(block_size * 2, 'c'));
t.write(cid, hoid, block_size * 2, bl.length(), bl, CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
bl.append(std::string(block_size * 2, 'd'));
t.write(cid, hoid, block_size * 5, bl.length(), bl, CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
// Currently we are unable to reuse blob when overwriting in a single step
t.write(cid, hoid, block_size * 6, bl.length(), bl, CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
bl.append(std::string(block_size, 'f'));
t.write(cid, hoid, block_size * 4, bl.length(), bl, CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, hoid);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
g_conf->set_val("bluestore_max_blob_size", "0");
g_conf->apply_changes(NULL);
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t hoid(hobject_t("test_hint", "", CEPH_NOSNAP, 0, -1, ""));
+ auto ch = store->create_new_collection(cid);
+
const PerfCounters* logger = store->get_perf_counters();
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
bl.append(std::string(block_size * 2, 'a'));
t.write(cid, hoid, block_size * 10, bl.length(), bl,
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
bl.append(std::string(block_size, 'b'));
t.write(cid, hoid, block_size * 9, bl.length(), bl,
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
bl.append(std::string(block_size, 'c'));
t.write(cid, hoid, block_size * 7, bl.length(), bl,
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
bl.append(std::string(block_size, 'd'));
t.write(cid, hoid, block_size * 13, bl.length(), bl,
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
t.write(cid, hoid, block_size * 19, bl.length(), bl,
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
t.write(cid, hoid, block_size * 18, bl.length(), bl,
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, hoid);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
g_conf->set_val("bluestore_max_blob_size", "0");
g_conf->set_val("bluestore_max_blob_size", "65536");
g_conf->apply_changes(NULL);
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
ghobject_t hoid(hobject_t("test_hint", "", CEPH_NOSNAP, 0, -1, ""));
const PerfCounters* logger = store->get_perf_counters();
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.write(cid, hoid, 0, bl.length(), bl, CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
t.write(cid, hoid, block_size * 2, bl.length(), bl,
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
bl.append(std::string(3, 'b'));
t.write(cid, hoid, block_size + 1, bl.length(), bl,
CEPH_OSD_OP_FLAG_FADVISE_WILLNEED);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
t.remove(cid, hoid);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
g_conf->set_val("bluestore_max_blob_size", "0");
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)));
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
{
bl.append(std::string(0x80000, 'a'));
t.write(cid, hoid1, 0, bl.length(), bl, 0);
t.zero(cid, hoid1, 0x719e0, 0x75b0 );
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
bl2.append(std::string(0x70000, 'b'));
t.write(cid, hoid1, 0, bl2.length(), bl2, 0);
t.zero(cid, hoid1, 0, 0x50000);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
+ ch.reset();
store->umount();
store->mount();
+ ch = store->open_collection(cid);
{
// do a write to zero space in between some extents sharing the same blob
bl.append(std::string(0x6520, 'c'));
t.write(cid, hoid1, 0x71c00, bl.length(), bl, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
t.remove(cid, hoid1);
t.remove_collection(cid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
g_conf->set_val("bluestore_max_target_blob", "524288");
if (string(GetParam()) != "bluestore")
return;
- ObjectStore::Sequencer osr("test");
int NUM_OBJS = 200;
int r = 0;
coll_t cid;
bufferptr ap(0x1000);
memset(ap.c_str(), 'a', 0x1000);
a.append(ap);
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
for (int i = 0; i < NUM_OBJS; ++i) {
snprintf(buf, sizeof(buf), "%d", i);
ghobject_t hoid(hobject_t(sobject_t(base + string(buf), CEPH_NOSNAP)));
t.write(cid, hoid, 0, 0x1000, a);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
r = store->mount(); //to force rocksdb stats
ASSERT_EQ(r, 0);
- ObjectStore::Sequencer osr("test");
int NUM_OBJS = 200;
coll_t cid;
string base("testobj.");
bufferptr ap(0x1000);
memset(ap.c_str(), 'a', 0x1000);
a.append(ap);
+ auto ch = store->create_new_collection(cid);
{
ObjectStore::Transaction t;
t.create_collection(cid, 0);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
for (int i = 0; i < NUM_OBJS; ++i) {
snprintf(buf, sizeof(buf), "%d", i);
ghobject_t hoid(hobject_t(sobject_t(base + string(buf), CEPH_NOSNAP)));
t.write(cid, hoid, 0, 0x1000, a);
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
#if defined(WITH_BLUESTORE)
TEST_P(StoreTestSpecificAUSize, garbageCollection) {
- ObjectStore::Sequencer osr("test");
int r;
coll_t cid;
int buf_len = 256 * 1024;
} else {\
t.write(cid, hoid, offset, bl.length(), bl);\
}\
- r = apply_transaction(store, &osr, std::move(t));\
+ r = apply_transaction(store, ch, std::move(t));\
ASSERT_EQ(r, 0);\
}
g_conf->set_val("bluestore_compression_mode", "force");
g_conf->apply_changes(NULL);
+ auto ch = store->create_new_collection(cid);
+
ghobject_t hoid(hobject_t(sobject_t("Object 1", CEPH_NOSNAP)));
{
bufferlist in;
ObjectStore::Transaction t;
t.create_collection(cid, 0);
cerr << "Creating collection " << cid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
ObjectStore::Transaction t;
t.touch(cid, hoid);
cerr << "Creating object " << hoid << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
exists = store->exists(cid, hoid);
ObjectStore::Transaction t;
t.remove(cid, hoid);
cerr << "Cleaning" << std::endl;
- r = apply_transaction(store, &osr, std::move(t));
+ r = apply_transaction(store, ch, std::move(t));
ASSERT_EQ(r, 0);
}
}
g_ceph_context->_conf->set_val("filestore_op_thread_timeout", "1000");
g_ceph_context->_conf->set_val("filestore_op_thread_suicide_timeout", "10000");
//g_ceph_context->_conf->set_val("filestore_fiemap", "true");
- g_ceph_context->_conf->set_val("bluestore_fsck_on_mount", "true");
- g_ceph_context->_conf->set_val("bluestore_fsck_on_umount", "true");
+ g_ceph_context->_conf->set_val("bluestore_fsck_on_mkfs", "false");
+ g_ceph_context->_conf->set_val("bluestore_fsck_on_mount", "false");
+ g_ceph_context->_conf->set_val("bluestore_fsck_on_umount", "false");
g_ceph_context->_conf->set_val("bluestore_debug_misc", "true");
g_ceph_context->_conf->set_val("bluestore_debug_small_allocations", "4");
g_ceph_context->_conf->set_val("bluestore_debug_freelist", "true");