bool bExit = false;
do {
if (it->blob.get() == b) {
- extents_to_collect.emplace_back(it->logical_offset, it->length);
+ extents_to_collect.insert(it->logical_offset, it->length);
}
bExit = it == bi.last_lextent;
++it;
if (ep != end && ep->logical_offset < offset + max_bsize) {
BlobRef b = ep->blob;
+
auto bstart = ep->blob_start();
+
dout(20) << __func__ << " considering " << *b
<< " bstart 0x" << std::hex << bstart << std::dec << dendl;
if (bstart >= end_offs) {
// check extent for reuse in reverse order
if (prev_ep != end && prev_ep->logical_offset >= min_off) {
BlobRef b = prev_ep->blob;
+
auto bstart = prev_ep->blob_start();
dout(20) << __func__ << " considering " << *b
<< " bstart 0x" << std::hex << bstart << std::dec << dendl;
it != extents_to_collect.end();
++it) {
bufferlist bl;
- int r = _do_read(c.get(), o, it->offset, it->length, bl, 0);
- ceph_assert(r == (int)it->length);
+ auto offset = (*it).first;
+ auto length = (*it).second;
+
+ int r = _do_read(c.get(), o, offset, length, bl, 0);
+ ceph_assert(r == (int)length);
- _do_write_data(txc, c, o, it->offset, it->length, bl, &wctx_gc);
- logger->inc(l_bluestore_gc_merged, it->length);
+ _do_write_data(txc, c, o, offset, length, bl, &wctx_gc);
+ logger->inc(l_bluestore_gc_merged, length);
- if (*dirty_start > it->offset) {
- *dirty_start = it->offset;
+ if (*dirty_start > offset) {
+ *dirty_start = offset;
dirty_range_updated = true;
}
- if (*dirty_end < it->offset + it->length) {
- *dirty_end = it->offset + it->length;
+ if (*dirty_end < offset + length) {
+ *dirty_end = offset + length;
dirty_range_updated = true;
}
}
uint64_t min_alloc_size);
/// return a collection of extents to perform GC on
- const vector<bluestore_pextent_t>& get_extents_to_collect() const {
+ const interval_set<uint64_t>& get_extents_to_collect() const {
return extents_to_collect;
}
GarbageCollector(CephContext* _cct) : cct(_cct) {}
///< specific write
///< protrusive extents that should be collected if GC takes place
- vector<bluestore_pextent_t> extents_to_collect;
+ interval_set<uint64_t> extents_to_collect;
boost::optional<uint64_t > used_alloc_unit; ///< last processed allocation
///< unit when traversing
saving = gc.estimate(300, 100, em, old_extents, 4096);
ASSERT_EQ(saving, 1);
auto& to_collect = gc.get_extents_to_collect();
- ASSERT_EQ(to_collect.size(), 1u);
- ASSERT_EQ(to_collect[0], bluestore_pextent_t(100,10) );
+ ASSERT_EQ(to_collect.num_intervals(), 1u);
+ ASSERT_EQ(*to_collect.begin(), std::make_pair(100ul, 10ul));
em.clear();
old_extents.clear();
saving = gc.estimate(0x30000, 0xf000, em, old_extents, 0x10000);
ASSERT_EQ(saving, 2);
auto& to_collect = gc.get_extents_to_collect();
- ASSERT_EQ(to_collect.size(), 2u);
- ASSERT_TRUE(to_collect[0] == bluestore_pextent_t(0x0,0x8000) ||
- to_collect[1] == bluestore_pextent_t(0x0,0x8000));
- ASSERT_TRUE(to_collect[0] == bluestore_pextent_t(0x3f000,0x1000) ||
- to_collect[1] == bluestore_pextent_t(0x3f000,0x1000));
+ ASSERT_EQ(to_collect.num_intervals(), 2u);
+ ASSERT_TRUE((*to_collect.begin()) == std::make_pair(0x0ul ,0x8000ul) ||
+ *(++to_collect.begin()) == std::make_pair(0x0ul, 0x8000ul));
+ ASSERT_TRUE((*to_collect.begin()) == std::make_pair(0x3f000ul, 0x1000ul) ||
+ *(++to_collect.begin()) == std::make_pair(0x3f000ul, 0x1000ul));
em.clear();
old_extents.clear();
saving = gc.estimate(0x3000, 0x4000, em, old_extents, 0x1000);
ASSERT_EQ(saving, 0);
auto& to_collect = gc.get_extents_to_collect();
- ASSERT_EQ(to_collect.size(), 0u);
+ ASSERT_EQ(to_collect.num_intervals(), 0u);
em.clear();
old_extents.clear();
}
saving = gc.estimate(0x30000, 0xf000, em, old_extents, 0x10000);
ASSERT_EQ(saving, 2);
auto& to_collect = gc.get_extents_to_collect();
- ASSERT_EQ(to_collect.size(), 2u);
- ASSERT_TRUE(to_collect[0] == bluestore_pextent_t(0x0,0x8000) ||
- to_collect[1] == bluestore_pextent_t(0x0,0x8000));
- ASSERT_TRUE(to_collect[0] == bluestore_pextent_t(0x3f000,0x1000) ||
- to_collect[1] == bluestore_pextent_t(0x3f000,0x1000));
+ ASSERT_EQ(to_collect.num_intervals(), 2u);
+ ASSERT_TRUE(*to_collect.begin() == std::make_pair(0x0ul, 0x8000ul) ||
+ *(++to_collect.begin()) == std::make_pair(0x0ul, 0x8000ul));
+ ASSERT_TRUE(*to_collect.begin() == std::make_pair(0x3f000ul, 0x1000ul) ||
+ *(++to_collect.begin()) == std::make_pair(0x3f000ul, 0x1000ul));
em.clear();
old_extents.clear();