Current implementation only checks a previous ool extent
before writing a ool extent. This can miss merge opportunities
for extents that are sequential but precede the last OOL extent.
This commit fixes this by reporting a correct mergeable size.
Signed-off-by: Myoungwon Oh <ohmyoungwon@gmail.com>
// TODO : allocate a consecutive address based on a transaction
if (writes.size() != 0 &&
- writes.back().offset + writes.back().bp.length() == paddr) {
+ writes.back().offset + writes.back().get_mergeable_length() == paddr) {
// We can write both the currrent extent and the previous one at once
// if the extents are located in a row
if (writes.back().mergeable_bps.size() == 0) {
ceph::bufferptr bp;
RandomBlockManager* rbm;
std::list<ceph::bufferptr> mergeable_bps;
+
+ extent_len_t get_mergeable_length() const {
+ if (mergeable_bps.size() == 0) {
+ return bp.length();
+ }
+ extent_len_t len = 0;
+ for (auto &p : mergeable_bps) {
+ len += p.length();
+ }
+ return len;
+ }
};
alloc_write_iertr::future<> do_write(
Transaction& t,