Skip to content

Commit 938a0f1

Browse files
committed
os/bluestore: Writer, improved calculation of need_size
More diligent calcualtion algorithm of need_size. Takes into account front and back alignment. Signed-off-by: Adam Kupczyk <[email protected]>
1 parent d2fda6c commit 938a0f1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/os/bluestore/Writer.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,8 +1344,15 @@ void BlueStore::Writer::do_write(
13441344
_try_put_data_on_allocated(location, data_end, ref_end, bd, after_punch_it);
13451345
}
13461346
if (location != data_end) {
1347-
uint32_t need_size = p2roundup(data_end, au_size) - p2align(location, au_size);
13481347
// make a deferred decision
1348+
uint32_t need_size = 0;
1349+
uint32_t location_tmp = location;
1350+
for (auto& i : bd) {
1351+
uint32_t location_end = location_tmp + i.real_length;
1352+
need_size += p2roundup(location_end, au_size) - p2align(location_tmp, au_size);
1353+
location_tmp = location_end;
1354+
}
1355+
13491356
_defer_or_allocate(need_size);
13501357
_do_put_blobs(location, data_end, ref_end, bd, after_punch_it);
13511358
} else {

0 commit comments

Comments
 (0)