using namespace crimson;
using namespace crimson::os;
using namespace crimson::os::seastore;
+using SeaStoreShard = FuturizedStore::Shard;
using CTransaction = ceph::os::Transaction;
using namespace std;
}
return tm_setup(journal
).then([this] {
- return seastore->create_new_collection(coll_name);
+ return sharded_seastore->create_new_collection(coll_name);
}).then([this](auto coll_ref) {
coll = coll_ref;
CTransaction t;
t.create_collection(coll_name, 0);
- return seastore->do_transaction(
+ return sharded_seastore->do_transaction(
coll,
std::move(t));
});
}
void do_transaction(CTransaction &&t) {
- return seastore->do_transaction(
+ return sharded_seastore->do_transaction(
coll,
std::move(t)).get0();
}
}
void touch(
- SeaStore &seastore) {
+ SeaStoreShard &sharded_seastore) {
CTransaction t;
touch(t);
- seastore.do_transaction(
+ sharded_seastore.do_transaction(
coll,
std::move(t)).get0();
}
}
void truncate(
- SeaStore &seastore,
+ SeaStoreShard &sharded_seastore,
uint64_t off) {
CTransaction t;
truncate(t, off);
- seastore.do_transaction(
+ sharded_seastore.do_transaction(
coll,
std::move(t)).get0();
}
std::map<uint64_t, uint64_t> fiemap(
- SeaStore &seastore,
+ SeaStoreShard &sharded_seastore,
uint64_t off,
uint64_t len) {
- return seastore.fiemap(coll, oid, off, len).unsafe_get0();
+ return sharded_seastore.fiemap(coll, oid, off, len).unsafe_get0();
}
bufferlist readv(
- SeaStore &seastore,
+ SeaStoreShard &sharded_seastore,
interval_set<uint64_t>&m) {
- return seastore.readv(coll, oid, m).unsafe_get0();
+ return sharded_seastore.readv(coll, oid, m).unsafe_get0();
}
void remove(
}
void remove(
- SeaStore &seastore) {
+ SeaStoreShard &sharded_seastore) {
CTransaction t;
remove(t);
- seastore.do_transaction(
+ sharded_seastore.do_transaction(
coll,
std::move(t)).get0();
}
}
void set_omap(
- SeaStore &seastore,
+ SeaStoreShard &sharded_seastore,
const string &key,
const bufferlist &val) {
CTransaction t;
set_omap(t, key, val);
- seastore.do_transaction(
+ sharded_seastore.do_transaction(
coll,
std::move(t)).get0();
}
void write(
- SeaStore &seastore,
+ SeaStoreShard &sharded_seastore,
CTransaction &t,
uint64_t offset,
bufferlist bl) {
}
void write(
- SeaStore &seastore,
+ SeaStoreShard &sharded_seastore,
uint64_t offset,
bufferlist bl) {
CTransaction t;
- write(seastore, t, offset, bl);
- seastore.do_transaction(
+ write(sharded_seastore, t, offset, bl);
+ sharded_seastore.do_transaction(
coll,
std::move(t)).get0();
}
void write(
- SeaStore &seastore,
+ SeaStoreShard &sharded_seastore,
uint64_t offset,
size_t len,
char fill) {
::memset(buffer.c_str(), fill, len);
bufferlist bl;
bl.append(buffer);
- write(seastore, offset, bl);
+ write(sharded_seastore, offset, bl);
}
void zero(
- SeaStore &seastore,
+ SeaStoreShard &sharded_seastore,
CTransaction &t,
uint64_t offset,
size_t len) {
}
void zero(
- SeaStore &seastore,
+ SeaStoreShard &sharded_seastore,
uint64_t offset,
size_t len) {
CTransaction t;
- zero(seastore, t, offset, len);
- seastore.do_transaction(
+ zero(sharded_seastore, t, offset, len);
+ sharded_seastore.do_transaction(
coll,
std::move(t)).get0();
}
void read(
- SeaStore &seastore,
+ SeaStoreShard &sharded_seastore,
uint64_t offset,
uint64_t len) {
bufferlist to_check;
contents,
offset,
len);
- auto ret = seastore.read(
+ auto ret = sharded_seastore.read(
coll,
oid,
offset,
EXPECT_EQ(ret, to_check);
}
- void check_size(SeaStore &seastore) {
- auto st = seastore.stat(
+ void check_size(SeaStoreShard &sharded_seastore) {
+ auto st = sharded_seastore.stat(
coll,
oid).get0();
EXPECT_EQ(contents.length(), st.st_size);
}
void set_attr(
- SeaStore &seastore,
+ SeaStoreShard &sharded_seastore,
std::string key,
bufferlist& val) {
CTransaction t;
t.setattr(cid, oid, key, val);
- seastore.do_transaction(
+ sharded_seastore.do_transaction(
coll,
std::move(t)).get0();
}
void rm_attr(
- SeaStore &seastore,
+ SeaStoreShard &sharded_seastore,
std::string key) {
CTransaction t;
t.rmattr(cid, oid, key);
- seastore.do_transaction(
+ sharded_seastore.do_transaction(
coll,
std::move(t)).get0();
}
void rm_attrs(
- SeaStore &seastore) {
+ SeaStoreShard &sharded_seastore) {
CTransaction t;
t.rmattrs(cid, oid);
- seastore.do_transaction(
+ sharded_seastore.do_transaction(
coll,
std::move(t)).get0();
}
- SeaStore::attrs_t get_attrs(
- SeaStore &seastore) {
- return seastore.get_attrs(coll, oid)
- .handle_error(SeaStore::get_attrs_ertr::discard_all{})
+ SeaStoreShard::attrs_t get_attrs(
+ SeaStoreShard &sharded_seastore) {
+ return sharded_seastore.get_attrs(coll, oid)
+ .handle_error(SeaStoreShard::get_attrs_ertr::discard_all{})
.get();
}
ceph::bufferlist get_attr(
- SeaStore& seastore,
+ SeaStoreShard& sharded_seastore,
std::string_view name) {
- return seastore.get_attr(coll, oid, name)
+ return sharded_seastore.get_attr(coll, oid, name)
.handle_error(
- SeaStore::get_attr_errorator::discard_all{})
+ SeaStoreShard::get_attr_errorator::discard_all{})
.get();
}
void check_omap_key(
- SeaStore &seastore,
+ SeaStoreShard &sharded_seastore,
const string &key) {
std::set<string> to_check;
to_check.insert(key);
- auto result = seastore.omap_get_values(
+ auto result = sharded_seastore.omap_get_values(
coll,
oid,
to_check).unsafe_get0();
}
}
- void check_omap(SeaStore &seastore) {
+ void check_omap(SeaStoreShard &sharded_seastore) {
auto refiter = omap.begin();
std::optional<std::string> start;
while(true) {
- auto [done, kvs] = seastore.omap_get_values(
+ auto [done, kvs] = sharded_seastore.omap_get_values(
coll,
oid,
start).unsafe_get0();
void remove_object(
object_state_t &sobj) {
- sobj.remove(*seastore);
+ sobj.remove(*sharded_seastore);
auto erased = test_objects.erase(sobj.oid);
ceph_assert(erased == 1);
}
for (auto& [oid, obj] : test_objects) {
oids.emplace_back(oid);
}
- auto ret = seastore->list_objects(
+ auto ret = sharded_seastore->list_objects(
coll,
ghobject_t(),
ghobject_t::get_max(),
auto create = [this, &objs](ghobject_t hoid) {
objs.emplace_back(std::move(hoid));
auto &obj = get_object(objs.back());
- obj.touch(*seastore);
- obj.check_size(*seastore);
+ obj.touch(*sharded_seastore);
+ obj.check_size(*sharded_seastore);
};
for (unsigned i = 0; i < temp_to_create; ++i) {
create(make_temp_oid(i));
auto right_bound = in_right_bound.get_oid(*seastore, coll);
// get results from seastore
- auto [listed, next] = seastore->list_objects(
+ auto [listed, next] = sharded_seastore->list_objects(
coll, left_bound, right_bound, limit).get0();
// compute correct answer
}
// teardown
- for (auto &&hoid : objs) { get_object(hoid).remove(*seastore); }
+ for (auto &&hoid : objs) { get_object(hoid).remove(*sharded_seastore); }
}
};
run_async([this] {
coll_t test_coll{spg_t{pg_t{1, 0}}};
{
- seastore->create_new_collection(test_coll).get0();
+ sharded_seastore->create_new_collection(test_coll).get0();
{
CTransaction t;
t.create_collection(test_coll, 4);
{
run_async([this] {
auto &test_obj = get_object(make_oid(0));
- test_obj.touch(*seastore);
- test_obj.check_size(*seastore);
+ test_obj.touch(*sharded_seastore);
+ test_obj.check_size(*sharded_seastore);
validate_objects();
remove_object(test_obj);
{
run_async([this] {
auto &test_obj = get_object(make_oid(0));
- test_obj.touch(*seastore);
+ test_obj.touch(*sharded_seastore);
test_obj.set_omap(
- *seastore,
+ *sharded_seastore,
"asdf",
make_bufferlist(128));
test_obj.check_omap_key(
- *seastore,
+ *sharded_seastore,
"asdf");
});
}
{
run_async([this] {
auto& test_obj = get_object(make_oid(0));
- test_obj.touch(*seastore);
+ test_obj.touch(*sharded_seastore);
{
std::string oi("asdfasdfasdf");
bufferlist bl;
encode(oi, bl);
- test_obj.set_attr(*seastore, OI_ATTR, bl);
+ test_obj.set_attr(*sharded_seastore, OI_ATTR, bl);
std::string ss("fdsfdsfs");
bl.clear();
encode(ss, bl);
- test_obj.set_attr(*seastore, SS_ATTR, bl);
+ test_obj.set_attr(*sharded_seastore, SS_ATTR, bl);
std::string test_val("ssssssssssss");
bl.clear();
encode(test_val, bl);
- test_obj.set_attr(*seastore, "test_key", bl);
+ test_obj.set_attr(*sharded_seastore, "test_key", bl);
- auto attrs = test_obj.get_attrs(*seastore);
+ auto attrs = test_obj.get_attrs(*sharded_seastore);
std::string oi2;
bufferlist bl2 = attrs[OI_ATTR];
decode(oi2, bl2);
EXPECT_EQ(test_val, test_val2);
bl2.clear();
- bl2 = test_obj.get_attr(*seastore, "test_key");
+ bl2 = test_obj.get_attr(*sharded_seastore, "test_key");
test_val2.clear();
decode(test_val2, bl2);
EXPECT_EQ(test_val, test_val2);
//test rm_attrs
- test_obj.rm_attrs(*seastore);
- attrs = test_obj.get_attrs(*seastore);
+ test_obj.rm_attrs(*sharded_seastore);
+ attrs = test_obj.get_attrs(*sharded_seastore);
EXPECT_EQ(attrs.find(OI_ATTR), attrs.end());
EXPECT_EQ(attrs.find(SS_ATTR), attrs.end());
EXPECT_EQ(attrs.find("test_key"), attrs.end());
std::string oi_str(&oi_array[0], sizeof(oi_array));
bl.clear();
encode(oi_str, bl);
- test_obj.set_attr(*seastore, OI_ATTR, bl);
+ test_obj.set_attr(*sharded_seastore, OI_ATTR, bl);
char ss_array[onode_layout_t::MAX_SS_LENGTH + 1] = {'b'};
std::string ss_str(&ss_array[0], sizeof(ss_array));
bl.clear();
encode(ss_str, bl);
- test_obj.set_attr(*seastore, SS_ATTR, bl);
+ test_obj.set_attr(*sharded_seastore, SS_ATTR, bl);
- attrs = test_obj.get_attrs(*seastore);
+ attrs = test_obj.get_attrs(*sharded_seastore);
bl2.clear();
bl2 = attrs[OI_ATTR];
std::string oi_str2;
bl2.clear();
ss_str2.clear();
- bl2 = test_obj.get_attr(*seastore, SS_ATTR);
+ bl2 = test_obj.get_attr(*sharded_seastore, SS_ATTR);
decode(ss_str2, bl2);
EXPECT_EQ(ss_str, ss_str2);
bl2.clear();
oi_str2.clear();
- bl2 = test_obj.get_attr(*seastore, OI_ATTR);
+ bl2 = test_obj.get_attr(*sharded_seastore, OI_ATTR);
decode(oi_str2, bl2);
EXPECT_EQ(oi_str, oi_str2);
- test_obj.rm_attr(*seastore, OI_ATTR);
- test_obj.rm_attr(*seastore, SS_ATTR);
+ test_obj.rm_attr(*sharded_seastore, OI_ATTR);
+ test_obj.rm_attr(*sharded_seastore, SS_ATTR);
- attrs = test_obj.get_attrs(*seastore);
+ attrs = test_obj.get_attrs(*sharded_seastore);
EXPECT_EQ(attrs.find(OI_ATTR), attrs.end());
EXPECT_EQ(attrs.find(SS_ATTR), attrs.end());
}
std::string oi("asdfasdfasdf");
bufferlist bl;
encode(oi, bl);
- test_obj.set_attr(*seastore, OI_ATTR, bl);
+ test_obj.set_attr(*sharded_seastore, OI_ATTR, bl);
std::string ss("f");
bl.clear();
encode(ss, bl);
- test_obj.set_attr(*seastore, SS_ATTR, bl);
+ test_obj.set_attr(*sharded_seastore, SS_ATTR, bl);
std::string test_val("ssssssssssss");
bl.clear();
encode(test_val, bl);
- test_obj.set_attr(*seastore, "test_key", bl);
+ test_obj.set_attr(*sharded_seastore, "test_key", bl);
- auto attrs = test_obj.get_attrs(*seastore);
+ auto attrs = test_obj.get_attrs(*sharded_seastore);
std::string oi2;
bufferlist bl2 = attrs[OI_ATTR];
decode(oi2, bl2);
EXPECT_EQ(oi, oi2);
EXPECT_EQ(test_val, test_val2);
- test_obj.rm_attr(*seastore, OI_ATTR);
- test_obj.rm_attr(*seastore, SS_ATTR);
- test_obj.rm_attr(*seastore, "test_key");
+ test_obj.rm_attr(*sharded_seastore, OI_ATTR);
+ test_obj.rm_attr(*sharded_seastore, SS_ATTR);
+ test_obj.rm_attr(*sharded_seastore, "test_key");
- attrs = test_obj.get_attrs(*seastore);
+ attrs = test_obj.get_attrs(*sharded_seastore);
EXPECT_EQ(attrs.find(OI_ATTR), attrs.end());
EXPECT_EQ(attrs.find(SS_ATTR), attrs.end());
EXPECT_EQ(attrs.find("test_key"), attrs.end());
std::string oi(&oi_array[0], sizeof(oi_array));
bufferlist bl;
encode(oi, bl);
- test_obj.set_attr(*seastore, OI_ATTR, bl);
+ test_obj.set_attr(*sharded_seastore, OI_ATTR, bl);
oi = "asdfasdfasdf";
bl.clear();
encode(oi, bl);
- test_obj.set_attr(*seastore, OI_ATTR, bl);
+ test_obj.set_attr(*sharded_seastore, OI_ATTR, bl);
char ss_array[onode_layout_t::MAX_SS_LENGTH + 1] = {'b'};
std::string ss(&ss_array[0], sizeof(ss_array));
bl.clear();
encode(ss, bl);
- test_obj.set_attr(*seastore, SS_ATTR, bl);
+ test_obj.set_attr(*sharded_seastore, SS_ATTR, bl);
ss = "f";
bl.clear();
encode(ss, bl);
- test_obj.set_attr(*seastore, SS_ATTR, bl);
+ test_obj.set_attr(*sharded_seastore, SS_ATTR, bl);
- auto attrs = test_obj.get_attrs(*seastore);
+ auto attrs = test_obj.get_attrs(*sharded_seastore);
std::string oi2, ss2;
bufferlist bl2 = attrs[OI_ATTR];
decode(oi2, bl2);
return ss.str();
};
auto &test_obj = get_object(make_oid(0));
- test_obj.touch(*seastore);
+ test_obj.touch(*sharded_seastore);
for (unsigned i = 0; i < 20; ++i) {
test_obj.set_omap(
- *seastore,
+ *sharded_seastore,
make_key(i),
make_bufferlist(128));
}
- test_obj.check_omap(*seastore);
+ test_obj.check_omap(*sharded_seastore);
});
}
return ss.str();
};
auto &test_obj = get_object(make_oid(0));
- test_obj.touch(*seastore);
+ test_obj.touch(*sharded_seastore);
for (unsigned i = 0; i < 1024; ++i) {
test_obj.set_omap(
- *seastore,
+ *sharded_seastore,
make_key(i),
make_bufferlist(128));
}
- test_obj.check_omap(*seastore);
+ test_obj.check_omap(*sharded_seastore);
for (uint64_t i = 0; i < 16; i++) {
test_obj.write(
- *seastore,
+ *sharded_seastore,
4096 * i,
4096,
'a');
}
- test_obj.remove(*seastore);
+ test_obj.remove(*sharded_seastore);
});
}
run_async([this] {
auto &test_obj = get_object(make_oid(0));
test_obj.write(
- *seastore,
+ *sharded_seastore,
1024,
1024,
'a');
test_obj.read(
- *seastore,
+ *sharded_seastore,
1024,
1024);
- test_obj.check_size(*seastore);
+ test_obj.check_size(*sharded_seastore);
});
}
{
run_async([this] {
auto &test_obj = get_object(make_oid(0));
- test_obj.touch(*seastore);
- test_obj.truncate(*seastore, 100000);
+ test_obj.touch(*sharded_seastore);
+ test_obj.truncate(*sharded_seastore, 100000);
std::map<uint64_t, uint64_t> m;
- m = test_obj.fiemap(*seastore, 0, 100000);
+ m = test_obj.fiemap(*sharded_seastore, 0, 100000);
EXPECT_TRUE(m.empty());
- test_obj.remove(*seastore);
+ test_obj.remove(*sharded_seastore);
});
}
bufferlist bl;
bl.append("foo");
- test_obj.touch(*seastore);
+ test_obj.touch(*sharded_seastore);
for (uint64_t i = 0; i < MAX_EXTENTS; i++) {
- test_obj.write(*seastore, SKIP_STEP * i, bl);
+ test_obj.write(*sharded_seastore, SKIP_STEP * i, bl);
}
{ // fiemap test from 0 to SKIP_STEP * (MAX_EXTENTS - 1) + 3
auto m = test_obj.fiemap(
- *seastore, 0, SKIP_STEP * (MAX_EXTENTS - 1) + 3);
+ *sharded_seastore, 0, SKIP_STEP * (MAX_EXTENTS - 1) + 3);
ASSERT_EQ(m.size(), MAX_EXTENTS);
for (uint64_t i = 0; i < MAX_EXTENTS; i++) {
ASSERT_TRUE(m.count(SKIP_STEP * i));
{ // fiemap test from SKIP_STEP to SKIP_STEP * (MAX_EXTENTS - 2) + 3
auto m = test_obj.fiemap(
- *seastore, SKIP_STEP, SKIP_STEP * (MAX_EXTENTS - 3) + 3);
+ *sharded_seastore, SKIP_STEP, SKIP_STEP * (MAX_EXTENTS - 3) + 3);
ASSERT_EQ(m.size(), MAX_EXTENTS - 2);
for (uint64_t i = 1; i < MAX_EXTENTS - 1; i++) {
ASSERT_TRUE(m.count(SKIP_STEP * i));
{ // fiemap test SKIP_STEP + 1 to 2 * SKIP_STEP + 1 (partial overlap)
auto m = test_obj.fiemap(
- *seastore, SKIP_STEP + 1, SKIP_STEP + 1);
+ *sharded_seastore, SKIP_STEP + 1, SKIP_STEP + 1);
ASSERT_EQ(m.size(), 2);
ASSERT_EQ(m.begin()->first, SKIP_STEP + 1);
ASSERT_GE(m.begin()->second, bl.length());
ASSERT_EQ(m.rbegin()->first + m.rbegin()->second, 2 * SKIP_STEP + 2);
}
- test_obj.remove(*seastore);
+ test_obj.remove(*sharded_seastore);
});
}
bufferlist wbl;
wbl.append("foo");
- test_obj.touch(*seastore);
+ test_obj.touch(*sharded_seastore);
for (uint64_t i = 0; i < MAX_EXTENTS; i++) {
- test_obj.write(*seastore, SKIP_STEP * i, wbl);
+ test_obj.write(*sharded_seastore, SKIP_STEP * i, wbl);
}
interval_set<uint64_t> m;
m = interval_set<uint64_t>(
- test_obj.fiemap(*seastore, 0, SKIP_STEP * (MAX_EXTENTS - 1) + 3));
+ test_obj.fiemap(*sharded_seastore, 0, SKIP_STEP * (MAX_EXTENTS - 1) + 3));
ASSERT_TRUE(!m.empty());
uint64_t off = 0;
- auto rbl = test_obj.readv(*seastore, m);
+ auto rbl = test_obj.readv(*sharded_seastore, m);
for (auto &&miter : m) {
bufferlist subl;
ASSERT_TRUE(subl.contents_equal(wbl));
off += miter.second;
}
- test_obj.remove(*seastore);
+ test_obj.remove(*sharded_seastore);
});
}
uint64_t size = 0;
for (auto &[off, len, repeat]: writes) {
for (decltype(repeat) i = 0; i < repeat; ++i) {
- test_obj.write(*seastore, off + (len * repeat), len, 'a');
+ test_obj.write(*sharded_seastore, off + (len * repeat), len, 'a');
}
size = off + (len * (repeat + 1));
}
test_obj.read(
- *seastore,
+ *sharded_seastore,
0,
size);
- test_obj.check_size(*seastore);
- test_obj.zero(*seastore, zero_off, zero_len);
+ test_obj.check_size(*sharded_seastore);
+ test_obj.zero(*sharded_seastore, zero_off, zero_len);
test_obj.read(
- *seastore,
+ *sharded_seastore,
0,
size);
- test_obj.check_size(*seastore);
+ test_obj.check_size(*sharded_seastore);
remove_object(test_obj);
};