Skip to content

Commit 71e094f

Browse files
committed
os/bluestore: Improve bluestore_blob_t::add_tail
It could happen that target blob already had empty mapping at the end. In such case, do not add more empty mappings, just expand exising one. Signed-off-by: Adam Kupczyk <[email protected]>
1 parent 5016925 commit 71e094f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/os/bluestore/bluestore_types.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,10 +1004,14 @@ struct bluestore_blob_t {
10041004
void add_tail(uint32_t new_len) {
10051005
ceph_assert(!has_unused());
10061006
ceph_assert(new_len > logical_length);
1007-
extents.emplace_back(
1008-
bluestore_pextent_t(
1009-
bluestore_pextent_t::INVALID_OFFSET,
1010-
new_len - logical_length));
1007+
if (extents.size() == 0 || extents.back().is_valid()) {
1008+
extents.emplace_back(
1009+
bluestore_pextent_t(
1010+
bluestore_pextent_t::INVALID_OFFSET,
1011+
new_len - logical_length));
1012+
} else {
1013+
extents.back().length += new_len - logical_length;
1014+
}
10111015
logical_length = new_len;
10121016
if (has_csum()) {
10131017
ceph::buffer::ptr t;

0 commit comments

Comments
 (0)