auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
BlueStore::Blob b;
- b.shared_blob = new BlueStore::SharedBlob(nullptr);
- b.shared_blob->get(); // hack to avoid dtor from running
+ b.shared_blob = new BlueStore::SharedBlob(coll.get());
b.dirty_blob().allocated_test(bluestore_pextent_t(0x40715000, 0x2000));
b.dirty_blob().allocated_test(
bluestore_pextent_t(bluestore_pextent_t::INVALID_OFFSET, 0x8000));
{
BlueStore::Blob B;
- B.shared_blob = new BlueStore::SharedBlob(nullptr);
- B.shared_blob->get(); // hack to avoid dtor from running
+ B.shared_blob = new BlueStore::SharedBlob(coll.get());
bluestore_blob_t& b = B.dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(0, mas * 2));
}
{
BlueStore::Blob B;
- B.shared_blob = new BlueStore::SharedBlob(nullptr);
- B.shared_blob->get(); // hack to avoid dtor from running
+ B.shared_blob = new BlueStore::SharedBlob(coll.get());
bluestore_blob_t& b = B.dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(123, mas * 2));
}
{
BlueStore::Blob B;
- B.shared_blob = new BlueStore::SharedBlob(nullptr);
- B.shared_blob->get(); // hack to avoid dtor from running
+ B.shared_blob = new BlueStore::SharedBlob(coll.get());
bluestore_blob_t& b = B.dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(1, mas));
}
{
BlueStore::Blob B;
- B.shared_blob = new BlueStore::SharedBlob(nullptr);
- B.shared_blob->get(); // hack to avoid dtor from running
+ B.shared_blob = new BlueStore::SharedBlob(coll.get());
bluestore_blob_t& b = B.dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(1, mas));
}
{
BlueStore::Blob B;
- B.shared_blob = new BlueStore::SharedBlob(nullptr);
- B.shared_blob->get(); // hack to avoid dtor from running
+ B.shared_blob = new BlueStore::SharedBlob(coll.get());
bluestore_blob_t& b = B.dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(1, mas * 6));
}
{
BlueStore::Blob B;
- B.shared_blob = new BlueStore::SharedBlob(nullptr);
- B.shared_blob->get(); // hack to avoid dtor from running
+ B.shared_blob = new BlueStore::SharedBlob(coll.get());
bluestore_blob_t& b = B.dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(1, mas * 4));
}
{
BlueStore::Blob B;
- B.shared_blob = new BlueStore::SharedBlob(nullptr);
- B.shared_blob->get(); // hack to avoid dtor from running
+ B.shared_blob = new BlueStore::SharedBlob(coll.get());
bluestore_blob_t& b = B.dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(1, mas * 4));
}
{
BlueStore::Blob B;
- B.shared_blob = new BlueStore::SharedBlob(nullptr);
- B.shared_blob->get(); // hack to avoid dtor from running
+ B.shared_blob = new BlueStore::SharedBlob(coll.get());
bluestore_blob_t& b = B.dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(1, mas * 4));
}
{
BlueStore::Blob B;
- B.shared_blob = new BlueStore::SharedBlob(nullptr);
- B.shared_blob->get(); // hack to avoid dtor from running
+ B.shared_blob = new BlueStore::SharedBlob(coll.get());
bluestore_blob_t& b = B.dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(1, mas * 8));
// verify csum chunk size if factored in properly
{
BlueStore::Blob B;
- B.shared_blob = new BlueStore::SharedBlob(nullptr);
- B.shared_blob->get(); // hack to avoid dtor from running
+ B.shared_blob = new BlueStore::SharedBlob(coll.get());
bluestore_blob_t& b = B.dirty_blob();
PExtentVector r;
b.allocated_test(bluestore_pextent_t(0, mas*4));
}
{
BlueStore::Blob B;
- B.shared_blob = new BlueStore::SharedBlob(nullptr);
- B.shared_blob->get(); // hack to avoid dtor from running
+ B.shared_blob = new BlueStore::SharedBlob(coll.get());
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,
}
{
BlueStore::Blob B;
- B.shared_blob = new BlueStore::SharedBlob(nullptr);
- B.shared_blob->get(); // hack to avoid dtor from running
+ B.shared_blob = new BlueStore::SharedBlob(coll.get());
bluestore_blob_t& b = B.dirty_blob();
b.allocated_test(bluestore_pextent_t(1, 0x5000));
b.allocated_test(bluestore_pextent_t(2, 0x5000));
}
{
BlueStore::Blob B;
- B.shared_blob = new BlueStore::SharedBlob(nullptr);
- B.shared_blob->get(); // hack to avoid dtor from running
+ B.shared_blob = new BlueStore::SharedBlob(coll.get());
bluestore_blob_t& b = B.dirty_blob();
b.allocated_test(bluestore_pextent_t(1, 0x7000));
b.allocated_test(bluestore_pextent_t(2, 0x7000));
auto coll = ceph::make_ref<BlueStore::Collection>(&store, oc, bc, coll_t());
BlueStore::Blob B;
- B.shared_blob = new BlueStore::SharedBlob(nullptr);
- B.shared_blob->get(); // hack to avoid dtor from running
+ B.shared_blob = new BlueStore::SharedBlob(coll.get());
bluestore_blob_t& b = B.dirty_blob();
b.allocated_test(bluestore_pextent_t(1, 0x5000));
b.allocated_test(bluestore_pextent_t(2, 0x7000));
{
BlueStore::Blob L, R;
L.shared_blob = new BlueStore::SharedBlob(coll.get());
- L.shared_blob->get(); // hack to avoid dtor from running
R.shared_blob = new BlueStore::SharedBlob(coll.get());
- R.shared_blob->get(); // hack to avoid dtor from running
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);
{
BlueStore::Blob L, R;
L.shared_blob = new BlueStore::SharedBlob(coll.get());
- L.shared_blob->get(); // hack to avoid dtor from running
R.shared_blob = new BlueStore::SharedBlob(coll.get());
- R.shared_blob->get(); // hack to avoid dtor from running
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);
ASSERT_FALSE(em.has_any_lextents(500, 1000));
}
+void erase_and_delete(BlueStore::ExtentMap& em, size_t v)
+{
+ auto d = em.find(v);
+ ASSERT_NE(d, em.extent_map.end());
+ em.extent_map.erase(d);
+ delete &*d;
+}
+
TEST(ExtentMap, compress_extent_map)
{
BlueStore store(g_ceph_context, "", 4096);
ASSERT_EQ(0, em.compress_extent_map(100000, 1000));
ASSERT_EQ(2, em.compress_extent_map(0, 100000));
ASSERT_EQ(2u, em.extent_map.size());
-
- em.extent_map.erase(em.find(100));
+ erase_and_delete(em, 100);
em.extent_map.insert(*new BlueStore::Extent(100, 0, 100, b2));
em.extent_map.insert(*new BlueStore::Extent(200, 100, 100, b3));
em.extent_map.insert(*new BlueStore::Extent(300, 200, 100, b2));
ASSERT_EQ(0, em.compress_extent_map(800, 1000));
ASSERT_EQ(2, em.compress_extent_map(100, 500));
ASSERT_EQ(7u, em.extent_map.size());
- em.extent_map.erase(em.find(300));
- em.extent_map.erase(em.find(500));
- em.extent_map.erase(em.find(700));
+ erase_and_delete(em, 300);
+ erase_and_delete(em, 500);
+ erase_and_delete(em, 700);
em.extent_map.insert(*new BlueStore::Extent(400, 300, 100, b2));
em.extent_map.insert(*new BlueStore::Extent(500, 400, 100, b2));
em.extent_map.insert(*new BlueStore::Extent(700, 500, 100, b2));
ASSERT_EQ(6u, em.extent_map.size());
}
+
+void clear_and_dispose(BlueStore::old_extent_map_t& old_em)
+{
+ auto oep = old_em.begin();
+ while (oep != old_em.end()) {
+ auto &lo = *oep;
+ oep = old_em.erase(oep);
+ delete &lo;
+ }
+}
+
TEST(GarbageCollector, BasicTest)
{
BlueStore::OnodeCacheShard *oc = BlueStore::OnodeCacheShard::create(
auto v = p{100ul, 10ul};
ASSERT_EQ(*it, v);
}
-
em.clear();
- old_extents.clear();
+ clear_and_dispose(old_extents);
}
/*
original disposition
}
em.clear();
- old_extents.clear();
+ clear_and_dispose(old_extents);
}
/*
original disposition
auto& to_collect = gc.get_extents_to_collect();
ASSERT_EQ(to_collect.num_intervals(), 0u);
em.clear();
- old_extents.clear();
+ clear_and_dispose(old_extents);
}
/*
original disposition
}
em.clear();
- old_extents.clear();
+ clear_and_dispose(old_extents);
}
}