sb_info_space_efficient_map_t sb_info;
BlueStore store(g_ceph_context, "", 4096);
- BlueStore::OnodeCacheShard *oc =
- BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL);
- BlueStore::BufferCacheShard *bc =
- BlueStore::BufferCacheShard::create(&store, "lru", NULL);
+ std::unique_ptr<BlueStore::OnodeCacheShard> oc{
+ BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL)};
+ std::unique_ptr<BlueStore::BufferCacheShard> bc{
+ BlueStore::BufferCacheShard::create(&store, "lru", NULL)};
- auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
+ auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc.get(), bc.get(), coll_t());
for (size_t i = 0; i < num_shared; i++) {
auto &sbi = sb_info.add_or_adopt(i);
TEST(Blob, put_ref) {
{
BlueStore store(g_ceph_context, "", 4096);
- BlueStore::OnodeCacheShard *oc =
- BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL);
- BlueStore::BufferCacheShard *bc =
- BlueStore::BufferCacheShard::create(&store, "lru", NULL);
-
- auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
- BlueStore::Blob b(coll.get());
- b.dirty_blob().allocated_test(bluestore_pextent_t(0x40715000, 0x2000));
- b.dirty_blob().allocated_test(
+ std::unique_ptr<BlueStore::OnodeCacheShard> oc{
+ BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL)};
+ std::unique_ptr<BlueStore::BufferCacheShard> bc{
+ BlueStore::BufferCacheShard::create(&store, "lru", NULL)};
+
+ auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc.get(), bc.get(), coll_t());
+ BlueStore::BlobRef b = coll->new_blob();
+ b->dirty_blob().allocated_test(bluestore_pextent_t(0x40715000, 0x2000));
+ b->dirty_blob().allocated_test(
bluestore_pextent_t(bluestore_pextent_t::INVALID_OFFSET, 0x8000));
- b.dirty_blob().allocated_test(bluestore_pextent_t(0x4071f000, 0x5000));
- b.get_ref(coll.get(), 0, 0x1200);
- b.get_ref(coll.get(), 0xae00, 0x4200);
- ASSERT_EQ(0x5400u, b.get_referenced_bytes());
+ b->dirty_blob().allocated_test(bluestore_pextent_t(0x4071f000, 0x5000));
+ b->get_ref(coll.get(), 0, 0x1200);
+ b->get_ref(coll.get(), 0xae00, 0x4200);
+ ASSERT_EQ(0x5400u, b->get_referenced_bytes());
cout << b << std::endl;
PExtentVector r;
- ASSERT_FALSE(b.put_ref(coll.get(), 0, 0x1200, &r));
- ASSERT_EQ(0x4200u, b.get_referenced_bytes());
+ ASSERT_FALSE(b->put_ref(coll.get(), 0, 0x1200, &r));
+ ASSERT_EQ(0x4200u, b->get_referenced_bytes());
cout << " r " << r << std::endl;
cout << b << std::endl;
r.clear();
- ASSERT_TRUE(b.put_ref(coll.get(), 0xae00, 0x4200, &r));
- ASSERT_EQ(0u, b.get_referenced_bytes());
+ ASSERT_TRUE(b->put_ref(coll.get(), 0xae00, 0x4200, &r));
+ ASSERT_EQ(0u, b->get_referenced_bytes());
cout << " r " << r << std::endl;
cout << b << std::endl;
}
unsigned mas = 4096;
BlueStore store(g_ceph_context, "", 8192);
- BlueStore::OnodeCacheShard *oc =
- BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL);
- BlueStore::BufferCacheShard *bc =
- BlueStore::BufferCacheShard::create(&store, "lru", NULL);
- auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
+ std::unique_ptr<BlueStore::OnodeCacheShard> oc{
+ BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL)};
+ std::unique_ptr<BlueStore::BufferCacheShard> bc{
+ BlueStore::BufferCacheShard::create(&store, "lru", NULL)};
+ auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc.get(), bc.get(), coll_t());
{
- BlueStore::Blob B(coll.get());
- bluestore_blob_t &b = B.dirty_blob();
+ BlueStore::BlobRef B = coll->new_blob();
+ bluestore_blob_t &b = B->dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(0, mas * 2));
- B.get_ref(coll.get(), 0, mas * 2);
- ASSERT_EQ(mas * 2, B.get_referenced_bytes());
+ B->get_ref(coll.get(), 0, mas * 2);
+ ASSERT_EQ(mas * 2, B->get_referenced_bytes());
ASSERT_TRUE(b.is_allocated(0, mas * 2));
- ASSERT_TRUE(B.put_ref(coll.get(), 0, mas * 2, &r));
- ASSERT_EQ(0u, B.get_referenced_bytes());
+ ASSERT_TRUE(B->put_ref(coll.get(), 0, mas * 2, &r));
+ ASSERT_EQ(0u, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0u, r[0].offset);
ASSERT_EQ(mas * 2, b.get_extents()[0].length);
}
{
- BlueStore::Blob B(coll.get());
- bluestore_blob_t &b = B.dirty_blob();
+ BlueStore::BlobRef B = coll->new_blob();
+ bluestore_blob_t &b = B->dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(123, mas * 2));
- B.get_ref(coll.get(), 0, mas * 2);
- ASSERT_EQ(mas * 2, B.get_referenced_bytes());
- ASSERT_FALSE(B.put_ref(coll.get(), 0, mas, &r));
- ASSERT_EQ(mas, B.get_referenced_bytes());
+ B->get_ref(coll.get(), 0, mas * 2);
+ ASSERT_EQ(mas * 2, B->get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), 0, mas, &r));
+ ASSERT_EQ(mas, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas * 2));
- ASSERT_TRUE(B.put_ref(coll.get(), mas, mas, &r));
- ASSERT_EQ(0u, B.get_referenced_bytes());
- ASSERT_EQ(0u, B.get_referenced_bytes());
+ ASSERT_TRUE(B->put_ref(coll.get(), mas, mas, &r));
+ ASSERT_EQ(0u, B->get_referenced_bytes());
+ ASSERT_EQ(0u, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(123u, r[0].offset);
ASSERT_EQ(mas * 2, b.get_extents()[0].length);
}
{
- BlueStore::Blob B(coll.get());
- bluestore_blob_t &b = B.dirty_blob();
+ BlueStore::BlobRef B = coll->new_blob();
+ bluestore_blob_t &b = B->dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(1, mas));
b.allocated_test(bluestore_pextent_t(2, mas));
b.allocated_test(bluestore_pextent_t(3, mas));
b.allocated_test(bluestore_pextent_t(4, mas));
- B.get_ref(coll.get(), 0, mas * 4);
- ASSERT_EQ(mas * 4, B.get_referenced_bytes());
- ASSERT_FALSE(B.put_ref(coll.get(), mas, mas, &r));
- ASSERT_EQ(mas * 3, B.get_referenced_bytes());
+ B->get_ref(coll.get(), 0, mas * 4);
+ ASSERT_EQ(mas * 4, B->get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas, mas, &r));
+ ASSERT_EQ(mas * 3, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas * 4));
ASSERT_TRUE(b.is_allocated(mas, mas));
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 2, mas, &r));
- ASSERT_EQ(mas * 2, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 2, mas, &r));
+ ASSERT_EQ(mas * 2, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(mas * 2, mas));
ASSERT_TRUE(b.is_allocated(0, mas * 4));
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 3, mas, &r));
- ASSERT_EQ(mas, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 3, mas, &r));
+ ASSERT_EQ(mas, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(2u, r.size());
ASSERT_EQ(3u, r[0].offset);
ASSERT_EQ(3u, b.get_extents().size());
}
{
- BlueStore::Blob B(coll.get());
- bluestore_blob_t &b = B.dirty_blob();
+ BlueStore::BlobRef B = coll->new_blob();
+ bluestore_blob_t &b = B->dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(1, mas));
b.allocated_test(bluestore_pextent_t(2, mas));
b.allocated_test(bluestore_pextent_t(4, mas));
b.allocated_test(bluestore_pextent_t(5, mas));
b.allocated_test(bluestore_pextent_t(6, mas));
- B.get_ref(coll.get(), 0, mas * 6);
- ASSERT_EQ(mas * 6, B.get_referenced_bytes());
- ASSERT_FALSE(B.put_ref(coll.get(), mas, mas, &r));
- ASSERT_EQ(mas * 5, B.get_referenced_bytes());
+ B->get_ref(coll.get(), 0, mas * 6);
+ ASSERT_EQ(mas * 6, B->get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas, mas, &r));
+ ASSERT_EQ(mas * 5, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas * 6));
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 2, mas, &r));
- ASSERT_EQ(mas * 4, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 2, mas, &r));
+ ASSERT_EQ(mas * 4, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas * 6));
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 3, mas, &r));
- ASSERT_EQ(mas * 3, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 3, mas, &r));
+ ASSERT_EQ(mas * 3, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(2u, r.size());
ASSERT_EQ(3u, r[0].offset);
ASSERT_TRUE(b.get_extents()[4].is_valid());
}
{
- BlueStore::Blob B(coll);
- bluestore_blob_t &b = B.dirty_blob();
+ BlueStore::BlobRef B = coll->new_blob();
+ bluestore_blob_t &b = B->dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(1, mas * 6));
- B.get_ref(coll.get(), 0, mas * 6);
- ASSERT_EQ(mas * 6, B.get_referenced_bytes());
- ASSERT_FALSE(B.put_ref(coll.get(), mas, mas, &r));
- ASSERT_EQ(mas * 5, B.get_referenced_bytes());
+ B->get_ref(coll.get(), 0, mas * 6);
+ ASSERT_EQ(mas * 6, B->get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas, mas, &r));
+ ASSERT_EQ(mas * 5, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas * 6));
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 2, mas, &r));
- ASSERT_EQ(mas * 4, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 2, mas, &r));
+ ASSERT_EQ(mas * 4, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas * 6));
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 3, mas, &r));
- ASSERT_EQ(mas * 3, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 3, mas, &r));
+ ASSERT_EQ(mas * 3, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0x2001u, r[0].offset);
ASSERT_TRUE(b.get_extents()[2].is_valid());
}
{
- BlueStore::Blob B(coll);
- bluestore_blob_t &b = B.dirty_blob();
+ BlueStore::BlobRef B = coll->new_blob();
+ bluestore_blob_t &b = B->dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(1, mas * 4));
b.allocated_test(bluestore_pextent_t(2, mas * 4));
b.allocated_test(bluestore_pextent_t(3, mas * 4));
- B.get_ref(coll.get(), 0, mas * 12);
- ASSERT_EQ(mas * 12, B.get_referenced_bytes());
- ASSERT_FALSE(B.put_ref(coll.get(), mas, mas, &r));
- ASSERT_EQ(mas * 11, B.get_referenced_bytes());
+ B->get_ref(coll.get(), 0, mas * 12);
+ ASSERT_EQ(mas * 12, B->get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas, mas, &r));
+ ASSERT_EQ(mas * 11, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas * 12));
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 9, mas, &r));
- ASSERT_EQ(mas * 10, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 9, mas, &r));
+ ASSERT_EQ(mas * 10, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas * 12));
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 2, mas * 7, &r));
- ASSERT_EQ(mas * 3, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 2, mas * 7, &r));
+ ASSERT_EQ(mas * 3, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(3u, r.size());
ASSERT_EQ(0x2001u, r[0].offset);
ASSERT_TRUE(b.get_extents()[2].is_valid());
}
{
- BlueStore::Blob B(coll);
- bluestore_blob_t &b = B.dirty_blob();
+ BlueStore::BlobRef B = coll->new_blob();
+ bluestore_blob_t &b = B->dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(1, mas * 4));
b.allocated_test(bluestore_pextent_t(2, mas * 4));
b.allocated_test(bluestore_pextent_t(3, mas * 4));
- B.get_ref(coll.get(), 0, mas * 12);
- ASSERT_EQ(mas * 12, B.get_referenced_bytes());
- ASSERT_FALSE(B.put_ref(coll.get(), mas, mas, &r));
- ASSERT_EQ(mas * 11, B.get_referenced_bytes());
+ B->get_ref(coll.get(), 0, mas * 12);
+ ASSERT_EQ(mas * 12, B->get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas, mas, &r));
+ ASSERT_EQ(mas * 11, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas * 12));
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 9, mas, &r));
- ASSERT_EQ(mas * 10, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 9, mas, &r));
+ ASSERT_EQ(mas * 10, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas * 12));
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 2, mas * 7, &r));
- ASSERT_EQ(mas * 3, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 2, mas * 7, &r));
+ ASSERT_EQ(mas * 3, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(3u, r.size());
ASSERT_EQ(0x2001u, r[0].offset);
ASSERT_TRUE(b.get_extents()[0].is_valid());
ASSERT_FALSE(b.get_extents()[1].is_valid());
ASSERT_TRUE(b.get_extents()[2].is_valid());
- ASSERT_FALSE(B.put_ref(coll.get(), 0, mas, &r));
- ASSERT_EQ(mas * 2, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), 0, mas, &r));
+ ASSERT_EQ(mas * 2, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0x1u, r[0].offset);
ASSERT_EQ(2u, b.get_extents().size());
ASSERT_FALSE(b.get_extents()[0].is_valid());
ASSERT_TRUE(b.get_extents()[1].is_valid());
- ASSERT_TRUE(B.put_ref(coll.get(), mas * 10, mas * 2, &r));
- ASSERT_EQ(mas * 0, B.get_referenced_bytes());
+ ASSERT_TRUE(B->put_ref(coll.get(), mas * 10, mas * 2, &r));
+ ASSERT_EQ(mas * 0, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0x2003u, r[0].offset);
ASSERT_FALSE(b.get_extents()[0].is_valid());
}
{
- BlueStore::Blob B(coll);
- bluestore_blob_t &b = B.dirty_blob();
+ BlueStore::BlobRef B = coll->new_blob();
+ bluestore_blob_t &b = B->dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(1, mas * 4));
b.allocated_test(bluestore_pextent_t(2, mas * 4));
b.allocated_test(bluestore_pextent_t(3, mas * 4));
- B.get_ref(coll.get(), 0, mas * 12);
- ASSERT_EQ(mas * 12, B.get_referenced_bytes());
- ASSERT_FALSE(B.put_ref(coll.get(), mas, mas, &r));
- ASSERT_EQ(mas * 11, B.get_referenced_bytes());
+ B->get_ref(coll.get(), 0, mas * 12);
+ ASSERT_EQ(mas * 12, B->get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas, mas, &r));
+ ASSERT_EQ(mas * 11, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas * 12));
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 9, mas, &r));
- ASSERT_EQ(mas * 10, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 9, mas, &r));
+ ASSERT_EQ(mas * 10, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas * 12));
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 2, mas * 7, &r));
- ASSERT_EQ(mas * 3, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 2, mas * 7, &r));
+ ASSERT_EQ(mas * 3, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(3u, r.size());
ASSERT_EQ(0x2001u, r[0].offset);
ASSERT_TRUE(b.get_extents()[0].is_valid());
ASSERT_FALSE(b.get_extents()[1].is_valid());
ASSERT_TRUE(b.get_extents()[2].is_valid());
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 10, mas * 2, &r));
- ASSERT_EQ(mas * 1, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 10, mas * 2, &r));
+ ASSERT_EQ(mas * 1, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0x2003u, r[0].offset);
ASSERT_EQ(2u, b.get_extents().size());
ASSERT_TRUE(b.get_extents()[0].is_valid());
ASSERT_FALSE(b.get_extents()[1].is_valid());
- ASSERT_TRUE(B.put_ref(coll.get(), 0, mas, &r));
- ASSERT_EQ(mas * 0, B.get_referenced_bytes());
+ ASSERT_TRUE(B->put_ref(coll.get(), 0, mas, &r));
+ ASSERT_EQ(mas * 0, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0x1u, r[0].offset);
ASSERT_FALSE(b.get_extents()[0].is_valid());
}
{
- BlueStore::Blob B(coll.get());
- bluestore_blob_t &b = B.dirty_blob();
+ BlueStore::BlobRef B = coll->new_blob();
+ bluestore_blob_t &b = B->dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(1, mas * 8));
- B.get_ref(coll.get(), 0, mas * 8);
- ASSERT_EQ(mas * 8, B.get_referenced_bytes());
- ASSERT_FALSE(B.put_ref(coll.get(), 0, mas, &r));
- ASSERT_EQ(mas * 7, B.get_referenced_bytes());
+ B->get_ref(coll.get(), 0, mas * 8);
+ ASSERT_EQ(mas * 8, B->get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), 0, mas, &r));
+ ASSERT_EQ(mas * 7, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas * 8));
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 7, mas, &r));
- ASSERT_EQ(mas * 6, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 7, mas, &r));
+ ASSERT_EQ(mas * 6, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas * 8));
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 2, mas, &r));
- ASSERT_EQ(mas * 5, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 2, mas, &r));
+ ASSERT_EQ(mas * 5, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, 8));
- ASSERT_FALSE(B.put_ref(coll.get(), mas * 3, mas * 4, &r));
- ASSERT_EQ(mas * 1, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), mas * 3, mas * 4, &r));
+ ASSERT_EQ(mas * 1, B->get_referenced_bytes());
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0x2001u, r[0].offset);
ASSERT_EQ(mas * 6, r[0].length);
ASSERT_EQ(2u, b.get_extents().size());
ASSERT_TRUE(b.get_extents()[0].is_valid());
ASSERT_FALSE(b.get_extents()[1].is_valid());
- ASSERT_TRUE(B.put_ref(coll.get(), mas, mas, &r));
- ASSERT_EQ(mas * 0, B.get_referenced_bytes());
+ ASSERT_TRUE(B->put_ref(coll.get(), mas, mas, &r));
+ ASSERT_EQ(mas * 0, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0x1u, r[0].offset);
}
// verify csum chunk size if factored in properly
{
- BlueStore::Blob B(coll.get());
- bluestore_blob_t &b = B.dirty_blob();
+ BlueStore::BlobRef B = coll->new_blob();
+ bluestore_blob_t &b = B->dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(0, mas * 4));
b.init_csum(Checksummer::CSUM_CRC32C, 14, mas * 4);
- B.get_ref(coll.get(), 0, mas * 4);
- ASSERT_EQ(mas * 4, B.get_referenced_bytes());
+ B->get_ref(coll.get(), 0, mas * 4);
+ ASSERT_EQ(mas * 4, B->get_referenced_bytes());
ASSERT_TRUE(b.is_allocated(0, mas * 4));
- ASSERT_FALSE(B.put_ref(coll.get(), 0, mas * 3, &r));
- ASSERT_EQ(mas * 1, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), 0, mas * 3, &r));
+ ASSERT_EQ(mas * 1, B->get_referenced_bytes());
cout << "r " << r << " " << b << std::endl;
ASSERT_EQ(0u, r.size());
ASSERT_TRUE(b.is_allocated(0, mas * 4));
ASSERT_EQ(mas * 4, b.get_extents()[0].length);
}
{
- BlueStore::Blob B(coll.get());
- bluestore_blob_t &b = B.dirty_blob();
+ BlueStore::BlobRef B = coll->new_blob();
+ bluestore_blob_t &b = B->dirty_blob();
b.allocated_test(bluestore_pextent_t(0x40101000, 0x4000));
b.allocated_test(
bluestore_pextent_t(bluestore_pextent_t::INVALID_OFFSET, 0x13000));
b.allocated_test(bluestore_pextent_t(0x40118000, 0x7000));
- B.get_ref(coll.get(), 0x0, 0x3800);
- B.get_ref(coll.get(), 0x17c00, 0x6400);
- ASSERT_EQ(0x3800u + 0x6400u, B.get_referenced_bytes());
+ B->get_ref(coll.get(), 0x0, 0x3800);
+ B->get_ref(coll.get(), 0x17c00, 0x6400);
+ ASSERT_EQ(0x3800u + 0x6400u, B->get_referenced_bytes());
b.set_flag(bluestore_blob_t::FLAG_SHARED);
b.init_csum(Checksummer::CSUM_CRC32C, 12, 0x1e000);
cout << "before: " << B << std::endl;
PExtentVector r;
- ASSERT_FALSE(B.put_ref(coll.get(), 0x1800, 0x2000, &r));
- ASSERT_EQ(0x3800u + 0x6400u - 0x2000u, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), 0x1800, 0x2000, &r));
+ ASSERT_EQ(0x3800u + 0x6400u - 0x2000u, B->get_referenced_bytes());
cout << "after: " << B << std::endl;
cout << "r " << r << std::endl;
}
{
- BlueStore::Blob B(coll.get());
- bluestore_blob_t &b = B.dirty_blob();
+ BlueStore::BlobRef B = coll->new_blob();
+ bluestore_blob_t &b = B->dirty_blob();
b.allocated_test(bluestore_pextent_t(1, 0x5000));
b.allocated_test(bluestore_pextent_t(2, 0x5000));
- B.get_ref(coll.get(), 0x0, 0xa000);
- ASSERT_EQ(0xa000u, B.get_referenced_bytes());
- cout << "before: " << B << std::endl;
+ B->get_ref(coll.get(), 0x0, 0xa000);
+ ASSERT_EQ(0xa000u, B->get_referenced_bytes());
+ cout << "before: " << *B << std::endl;
PExtentVector r;
- ASSERT_FALSE(B.put_ref(coll.get(), 0x8000, 0x2000, &r));
+ ASSERT_FALSE(B->put_ref(coll.get(), 0x8000, 0x2000, &r));
cout << "after: " << B << std::endl;
cout << "r " << r << std::endl;
- ASSERT_EQ(0x8000u, B.get_referenced_bytes());
+ ASSERT_EQ(0x8000u, B->get_referenced_bytes());
ASSERT_EQ(1u, r.size());
ASSERT_EQ(0x3002u, r[0].offset);
ASSERT_EQ(0x2000u, r[0].length);
}
{
- BlueStore::Blob B(coll.get());
- bluestore_blob_t &b = B.dirty_blob();
+ BlueStore::BlobRef B = coll->new_blob();
+ bluestore_blob_t &b = B->dirty_blob();
b.allocated_test(bluestore_pextent_t(1, 0x7000));
b.allocated_test(bluestore_pextent_t(2, 0x7000));
- B.get_ref(coll.get(), 0x0, 0xe000);
- ASSERT_EQ(0xe000u, B.get_referenced_bytes());
- cout << "before: " << B << std::endl;
+ B->get_ref(coll.get(), 0x0, 0xe000);
+ ASSERT_EQ(0xe000u, B->get_referenced_bytes());
+ cout << "before: " << *B << std::endl;
PExtentVector r;
- ASSERT_FALSE(B.put_ref(coll.get(), 0, 0xb000, &r));
- ASSERT_EQ(0x3000u, B.get_referenced_bytes());
+ ASSERT_FALSE(B->put_ref(coll.get(), 0, 0xb000, &r));
+ ASSERT_EQ(0x3000u, B->get_referenced_bytes());
cout << "after: " << B << std::endl;
cout << "r " << r << std::endl;
- ASSERT_EQ(0x3000u, B.get_referenced_bytes());
+ ASSERT_EQ(0x3000u, B->get_referenced_bytes());
ASSERT_EQ(2u, r.size());
ASSERT_EQ(1u, r[0].offset);
ASSERT_EQ(0x7000u, r[0].length);
}
{
BlueStore store(g_ceph_context, "", 0x4000);
- BlueStore::OnodeCacheShard *oc =
- BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL);
- BlueStore::BufferCacheShard *bc =
- BlueStore::BufferCacheShard::create(&store, "lru", NULL);
-
- auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
- BlueStore::Blob B(coll.get());
- bluestore_blob_t &b = B.dirty_blob();
+ std::unique_ptr<BlueStore::OnodeCacheShard> oc{
+ BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL)};
+ std::unique_ptr<BlueStore::BufferCacheShard> bc{
+ BlueStore::BufferCacheShard::create(&store, "lru", NULL)};
+
+ auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc.get(), bc.get(), coll_t());
+ // Blob assumes that it is in the coll_cache, and removes itself from the
+ // coll_cache in the dtor,
+ BlueStore::BlobRef B = coll->new_blob();
+ bluestore_blob_t &b = B->dirty_blob();
b.allocated_test(bluestore_pextent_t(1, 0x5000));
b.allocated_test(bluestore_pextent_t(2, 0x7000));
- B.get_ref(coll.get(), 0x0, 0xc000);
- ASSERT_EQ(0xc000u, B.get_referenced_bytes());
- cout << "before: " << B << std::endl;
+ B->get_ref(coll.get(), 0x0, 0xc000);
+ ASSERT_EQ(0xc000u, B->get_referenced_bytes());
+ cout << "before: " << *B << std::endl;
PExtentVector r;
- ASSERT_FALSE(B.put_ref(coll.get(), 0x2000, 0xa000, &r));
+ ASSERT_FALSE(B->put_ref(coll.get(), 0x2000, 0xa000, &r));
cout << "after: " << B << std::endl;
cout << "r " << r << std::endl;
- ASSERT_EQ(0x2000u, B.get_referenced_bytes());
+ ASSERT_EQ(0x2000u, B->get_referenced_bytes());
ASSERT_EQ(2u, r.size());
ASSERT_EQ(0x4001u, r[0].offset);
ASSERT_EQ(0x1000u, r[0].length);
TEST(Blob, split) {
BlueStore store(g_ceph_context, "", 4096);
- BlueStore::OnodeCacheShard *oc =
- BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL);
- BlueStore::BufferCacheShard *bc =
- BlueStore::BufferCacheShard::create(&store, "lru", NULL);
- auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
+ std::unique_ptr<BlueStore::OnodeCacheShard> oc{
+ BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL)};
+ std::unique_ptr<BlueStore::BufferCacheShard> bc{
+ BlueStore::BufferCacheShard::create(&store, "lru", NULL)};
+ auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc.get(), bc.get(), coll_t());
{
- BlueStore::Blob L(coll.get());
- BlueStore::Blob R(coll.get());
- L.dirty_blob().allocated_test(bluestore_pextent_t(0x2000, 0x2000));
- L.dirty_blob().init_csum(Checksummer::CSUM_CRC32C, 12, 0x2000);
- L.get_ref(coll.get(), 0, 0x2000);
- L.split(coll.get(), 0x1000, &R);
- ASSERT_EQ(0x1000u, L.get_blob().get_logical_length());
- ASSERT_EQ(4u, L.get_blob().csum_data.length());
- ASSERT_EQ(1u, L.get_blob().get_extents().size());
- ASSERT_EQ(0x2000u, L.get_blob().get_extents().front().offset);
- ASSERT_EQ(0x1000u, L.get_blob().get_extents().front().length);
- ASSERT_EQ(0x1000u, L.get_referenced_bytes());
- ASSERT_EQ(0x1000u, R.get_blob().get_logical_length());
- ASSERT_EQ(4u, R.get_blob().csum_data.length());
- ASSERT_EQ(1u, R.get_blob().get_extents().size());
- ASSERT_EQ(0x3000u, R.get_blob().get_extents().front().offset);
- ASSERT_EQ(0x1000u, R.get_blob().get_extents().front().length);
- ASSERT_EQ(0x1000u, R.get_referenced_bytes());
+ BlueStore::BlobRef L = coll->new_blob();
+ BlueStore::BlobRef R = coll->new_blob();
+ L->dirty_blob().allocated_test(bluestore_pextent_t(0x2000, 0x2000));
+ L->dirty_blob().init_csum(Checksummer::CSUM_CRC32C, 12, 0x2000);
+ L->get_ref(coll.get(), 0, 0x2000);
+ L->split(coll.get(), 0x1000, R.get());
+ ASSERT_EQ(0x1000u, L->get_blob().get_logical_length());
+ ASSERT_EQ(4u, L->get_blob().csum_data.length());
+ ASSERT_EQ(1u, L->get_blob().get_extents().size());
+ ASSERT_EQ(0x2000u, L->get_blob().get_extents().front().offset);
+ ASSERT_EQ(0x1000u, L->get_blob().get_extents().front().length);
+ ASSERT_EQ(0x1000u, L->get_referenced_bytes());
+ ASSERT_EQ(0x1000u, R->get_blob().get_logical_length());
+ ASSERT_EQ(4u, R->get_blob().csum_data.length());
+ ASSERT_EQ(1u, R->get_blob().get_extents().size());
+ ASSERT_EQ(0x3000u, R->get_blob().get_extents().front().offset);
+ ASSERT_EQ(0x1000u, R->get_blob().get_extents().front().length);
+ ASSERT_EQ(0x1000u, R->get_referenced_bytes());
}
{
- BlueStore::Blob L(coll.get());
- BlueStore::Blob R(coll.get());
- L.dirty_blob().allocated_test(bluestore_pextent_t(0x2000, 0x1000));
- L.dirty_blob().allocated_test(bluestore_pextent_t(0x12000, 0x1000));
- L.dirty_blob().init_csum(Checksummer::CSUM_CRC32C, 12, 0x2000);
- L.get_ref(coll.get(), 0, 0x1000);
- L.get_ref(coll.get(), 0x1000, 0x1000);
- L.split(coll.get(), 0x1000, &R);
- ASSERT_EQ(0x1000u, L.get_blob().get_logical_length());
- ASSERT_EQ(4u, L.get_blob().csum_data.length());
- ASSERT_EQ(1u, L.get_blob().get_extents().size());
- ASSERT_EQ(0x2000u, L.get_blob().get_extents().front().offset);
- ASSERT_EQ(0x1000u, L.get_blob().get_extents().front().length);
- ASSERT_EQ(0x1000u, L.get_referenced_bytes());
- ASSERT_EQ(0x1000u, R.get_blob().get_logical_length());
- ASSERT_EQ(4u, R.get_blob().csum_data.length());
- ASSERT_EQ(1u, R.get_blob().get_extents().size());
- ASSERT_EQ(0x12000u, R.get_blob().get_extents().front().offset);
- ASSERT_EQ(0x1000u, R.get_blob().get_extents().front().length);
- ASSERT_EQ(0x1000u, R.get_referenced_bytes());
+ BlueStore::BlobRef L = coll->new_blob();
+ BlueStore::BlobRef R = coll->new_blob();
+ L->dirty_blob().allocated_test(bluestore_pextent_t(0x2000, 0x1000));
+ L->dirty_blob().allocated_test(bluestore_pextent_t(0x12000, 0x1000));
+ L->dirty_blob().init_csum(Checksummer::CSUM_CRC32C, 12, 0x2000);
+ L->get_ref(coll.get(), 0, 0x1000);
+ L->get_ref(coll.get(), 0x1000, 0x1000);
+ L->split(coll.get(), 0x1000, R.get());
+ ASSERT_EQ(0x1000u, L->get_blob().get_logical_length());
+ ASSERT_EQ(4u, L->get_blob().csum_data.length());
+ ASSERT_EQ(1u, L->get_blob().get_extents().size());
+ ASSERT_EQ(0x2000u, L->get_blob().get_extents().front().offset);
+ ASSERT_EQ(0x1000u, L->get_blob().get_extents().front().length);
+ ASSERT_EQ(0x1000u, L->get_referenced_bytes());
+ ASSERT_EQ(0x1000u, R->get_blob().get_logical_length());
+ ASSERT_EQ(4u, R->get_blob().csum_data.length());
+ ASSERT_EQ(1u, R->get_blob().get_extents().size());
+ ASSERT_EQ(0x12000u, R->get_blob().get_extents().front().offset);
+ ASSERT_EQ(0x1000u, R->get_blob().get_extents().front().length);
+ ASSERT_EQ(0x1000u, R->get_referenced_bytes());
}
}
TEST(Blob, legacy_decode) {
BlueStore store(g_ceph_context, "", 4096);
- BlueStore::OnodeCacheShard *oc =
- BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL);
- BlueStore::BufferCacheShard *bc =
- BlueStore::BufferCacheShard::create(&store, "lru", NULL);
- auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
+ std::unique_ptr<BlueStore::OnodeCacheShard> oc{
+ BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL)};
+ std::unique_ptr<BlueStore::BufferCacheShard> bc{
+ BlueStore::BufferCacheShard::create(&store, "lru", NULL)};
+ auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc.get(), bc.get(), coll_t());
bufferlist bl, bl2;
{
- BlueStore::Blob B(coll.get());
+ BlueStore::BlobRef B = coll->new_blob();
- B.dirty_blob().allocated_test(bluestore_pextent_t(0x1, 0x2000));
- B.dirty_blob().init_csum(Checksummer::CSUM_CRC32C, 12, 0x2000);
- B.get_ref(coll.get(), 0, 0xff0);
- B.get_ref(coll.get(), 0x1fff, 1);
+ B->dirty_blob().allocated_test(bluestore_pextent_t(0x1, 0x2000));
+ B->dirty_blob().init_csum(Checksummer::CSUM_CRC32C, 12, 0x2000);
+ B->get_ref(coll.get(), 0, 0xff0);
+ B->get_ref(coll.get(), 0x1fff, 1);
bluestore_extent_ref_map_t fake_ref_map;
fake_ref_map.get(0, 0xff0);
size_t bound = 0, bound2 = 0;
- B.bound_encode(bound, 1, /*struct_v*/
- 0, /*sbid*/
- false);
+ B->bound_encode(bound, 1, /*struct_v*/
+ 0, /*sbid*/
+ false);
fake_ref_map.bound_encode(bound);
- B.bound_encode(bound2, 2, /*struct_v*/
+ B->bound_encode(bound2, 2, /*struct_v*/
0, /*sbid*/
true);
{
auto app = bl.get_contiguous_appender(bound);
auto app2 = bl2.get_contiguous_appender(bound2);
- B.encode(app, 1, /*struct_v*/
- 0, /*sbid*/
- false);
+ B->encode(app, 1, /*struct_v*/
+ 0, /*sbid*/
+ false);
fake_ref_map.encode(app);
- B.encode(app2, 2, /*struct_v*/
- 0, /*sbid*/
- true);
+ B->encode(app2, 2, /*struct_v*/
+ 0, /*sbid*/
+ true);
}
auto p = bl.front().begin_deep();
auto p2 = bl2.front().begin_deep();
- BlueStore::Blob Bres(coll.get());
- BlueStore::Blob Bres2(coll.get());
+ BlueStore::BlobRef Bres = coll->new_blob();
+ BlueStore::BlobRef Bres2 = coll->new_blob();
uint64_t sbid, sbid2;
- Bres.decode(p, 1, /*struct_v*/
- &sbid, true, coll.get());
- Bres2.decode(p2, 2, /*struct_v*/
- &sbid2, true, coll.get());
+ Bres->decode(p, 1, /*struct_v*/
+ &sbid, true, coll.get());
+ Bres2->decode(p2, 2, /*struct_v*/
+ &sbid2, true, coll.get());
- ASSERT_EQ(0xff0u + 1u, Bres.get_blob_use_tracker().get_referenced_bytes());
- ASSERT_EQ(0xff0u + 1u, Bres2.get_blob_use_tracker().get_referenced_bytes());
+ ASSERT_EQ(0xff0u + 1u, Bres->get_blob_use_tracker().get_referenced_bytes());
+ ASSERT_EQ(0xff0u + 1u, Bres2->get_blob_use_tracker().get_referenced_bytes());
ASSERT_TRUE(
- Bres.get_blob_use_tracker().equal(Bres2.get_blob_use_tracker()));
+ Bres->get_blob_use_tracker().equal(Bres2->get_blob_use_tracker()));
}
}
TEST(ExtentMap, seek_lextent) {
BlueStore store(g_ceph_context, "", 4096);
- BlueStore::OnodeCacheShard *oc =
- BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL);
- BlueStore::BufferCacheShard *bc =
- BlueStore::BufferCacheShard::create(&store, "lru", NULL);
+ std::unique_ptr<BlueStore::OnodeCacheShard> oc{
+ BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL)};
+ std::unique_ptr<BlueStore::BufferCacheShard> bc{
+ BlueStore::BufferCacheShard::create(&store, "lru", NULL)};
- auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
+ auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc.get(), bc.get(), coll_t());
BlueStore::Onode onode(coll.get(), ghobject_t(), "");
BlueStore::ExtentMap em(
&onode,
TEST(ExtentMap, has_any_lextents) {
BlueStore store(g_ceph_context, "", 4096);
- BlueStore::OnodeCacheShard *oc =
- BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL);
- BlueStore::BufferCacheShard *bc =
- BlueStore::BufferCacheShard::create(&store, "lru", NULL);
- auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
+ std::unique_ptr<BlueStore::OnodeCacheShard> oc{
+ BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL)};
+ std::unique_ptr<BlueStore::BufferCacheShard> bc{
+ BlueStore::BufferCacheShard::create(&store, "lru", NULL)};
+ auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc.get(), bc.get(), coll_t());
BlueStore::Onode onode(coll.get(), ghobject_t(), "");
BlueStore::ExtentMap em(
&onode,
TEST(ExtentMap, compress_extent_map) {
BlueStore store(g_ceph_context, "", 4096);
- BlueStore::OnodeCacheShard *oc =
- BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL);
- BlueStore::BufferCacheShard *bc =
- BlueStore::BufferCacheShard::create(&store, "lru", NULL);
+ std::unique_ptr<BlueStore::OnodeCacheShard> oc{
+ BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL)};
+ std::unique_ptr<BlueStore::BufferCacheShard> bc{
+ BlueStore::BufferCacheShard::create(&store, "lru", NULL)};
- auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
+ auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc.get(), bc.get(), coll_t());
BlueStore::Onode onode(coll.get(), ghobject_t(), "");
BlueStore::ExtentMap em(
&onode,
public:
BlueStore store;
- BlueStore::OnodeCacheShard *oc;
- BlueStore::BufferCacheShard *bc;
+ std::unique_ptr<BlueStore::OnodeCacheShard> oc;
+ std::unique_ptr<BlueStore::BufferCacheShard> bc;
BlueStore::CollectionRef coll;
static constexpr uint32_t au_size = 4096;
}
}
explicit ExtentMapFixture() : store(g_ceph_context, "", au_size) {
- oc = BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL);
- bc = BlueStore::BufferCacheShard::create(&store, "lru", NULL);
- coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
+ oc.reset(BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL));
+ bc.reset(BlueStore::BufferCacheShard::create(&store, "lru", NULL));
+ coll = ceph::make_ref<BlueStore::Collection>(&store, oc.get(), bc.get(), coll_t());
}
void SetUp() override {}
TEST(ExtentMap, dup_extent_map)
{
BlueStore store(g_ceph_context, "", 4096);
- BlueStore::OnodeCacheShard *oc =
- BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL);
- BlueStore::BufferCacheShard *bc =
- BlueStore::BufferCacheShard::create(&store, "lru", NULL);
+ std::unique_ptr<BlueStore::OnodeCacheShard> oc{
+ BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL)};
+ std::unique_ptr<BlueStore::BufferCacheShard> bc{
+ BlueStore::BufferCacheShard::create(&store, "lru", NULL)};
size_t csum_order = 12; // 1^12 = 4096 bytes
- auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
+ auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc.get(), bc.get(), coll_t());
std::unique_ptr<ceph::Formatter> formatter(Formatter::create("json"));
///////////////////////////
TEST(GarbageCollector, BasicTest) {
BlueStore store(g_ceph_context, "", 4096);
- BlueStore::OnodeCacheShard *oc =
- BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL);
- BlueStore::BufferCacheShard *bc =
- BlueStore::BufferCacheShard::create(&store, "lru", NULL);
+ std::unique_ptr<BlueStore::OnodeCacheShard> oc{
+ BlueStore::OnodeCacheShard::create(g_ceph_context, "lru", NULL)};
+ std::unique_ptr<BlueStore::BufferCacheShard> bc{
+ BlueStore::BufferCacheShard::create(&store, "lru", NULL)};
- auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
+ auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc.get(), bc.get(), coll_t());
BlueStore::Onode onode(coll.get(), ghobject_t(), "");
BlueStore::ExtentMap em(
&onode,
*/
{
BlueStore store(g_ceph_context, "", 0x10000);
- auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
+ auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc.get(), bc.get(), coll_t());
BlueStore::Onode onode(coll.get(), ghobject_t(), "");
BlueStore::ExtentMap em(
&onode,
*/
{
BlueStore store(g_ceph_context, "", 0x10000);
- auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
+ auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc.get(), bc.get(), coll_t());
BlueStore::Onode onode(coll.get(), ghobject_t(), "");
BlueStore::ExtentMap em(
&onode,