Skip to content

Commit 5016925

Browse files
committed
os/bluestore: Make write_v2 not need to use compress_extents, addendum
There was possible case that affected rightmost changed extent. It could be that 2 mergeable extents were next to each other. This change melds them together. Signed-off-by: Adam Kupczyk <[email protected]>
1 parent bfff750 commit 5016925

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/os/bluestore/Writer.cc

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,26 @@ inline void BlueStore::Writer::_place_extent_in_blob(
588588
}
589589
}
590590

591+
// Iterator it can be invalidated.
592+
void BlueStore::Writer::_maybe_meld_with_prev_extent(exmp_it it)
593+
{
594+
if (it == onode->extent_map.extent_map.end()) return; // can't merge with non-existent
595+
if (it == onode->extent_map.extent_map.begin()) return; // can't merge when there is only 1 extent
596+
if (it->logical_end() >= right_shard_bound) return; // not allowed to escape shard range
597+
auto it_p = it;
598+
--it_p;
599+
if (it_p->logical_offset < left_shard_bound) return; // we could jump here behind our inserted range
600+
if (it_p->blob == it->blob &&
601+
it_p->logical_end() == it->logical_offset &&
602+
it_p->blob_offset + it_p->length == it->blob_offset) // this one is specifc, currently is always true
603+
{
604+
it_p->length += it->length;
605+
onode->extent_map.rm(it);
606+
left_affected_range = std::min(left_affected_range, it_p->logical_offset);
607+
right_affected_range = std::max(right_affected_range, it_p->logical_end());
608+
}
609+
}
610+
591611
/**
592612
* Note from developer
593613
* This module tries to keep naming convention:
@@ -1408,8 +1428,13 @@ void BlueStore::Writer::do_write(
14081428
_collect_released_allocated();
14091429
// update statfs
14101430
txc->statfs_delta += statfs_delta;
1411-
// note: compress extent is not needed; _try_reuse_allocated_* joins extents if possible
1412-
// in other cases new blobs cannot be joined with existing ones
1431+
// Note: compress extent is mostly not needed; _try_reuse_allocated_* joins extents if possible;
1432+
// same is done after _blob_put_data_subau_allocate (allocate more to existing blob).
1433+
// New blobs cannot be joined with existing ones.
1434+
// The only case that adjecent extents can be meld together is on the boundary.
1435+
// More specific, since we are operating left side first, right side later
1436+
// the only non-joined extent is between after_punch_it - 1 and after_punch_it.
1437+
_maybe_meld_with_prev_extent(after_punch_it);
14131438
dout(25) << "result: " << std::endl << onode->print(pp_mode) << dendl;
14141439
}
14151440

src/os/bluestore/Writer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ class BlueStore::Writer {
152152
uint32_t map_end,
153153
uint32_t in_blob_offset);
154154

155+
void _maybe_meld_with_prev_extent(exmp_it after_punch_it);
156+
155157
inline void _blob_put_data_subau(
156158
Blob* blob,
157159
uint32_t in_blob_offset,

0 commit comments

Comments
 (0)