Skip to content

Commit 1b24c7c

Browse files
committed
os/bluestore: Write_v2 changes
1) moved stats and blobs update to Writer::do_write 2) preallocate space in Writer:_split_data 3) fixed Writer::_write_expand_l that could check one extent too much Signed-off-by: Adam Kupczyk <[email protected]>
1 parent 7b0d27e commit 1b24c7c

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/os/bluestore/BlueStore.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17379,14 +17379,6 @@ int BlueStore::_do_write_v2(
1737917379
o->extent_map.fault_range(db, offset, length);
1738017380
BlueStore::Writer wr(this, txc, &wctx, o);
1738117381
wr.do_write(offset, bl);
17382-
// equivalent of wctx_finish
17383-
// do_write updates allocations itself
17384-
// update statfs
17385-
txc->statfs_delta += wr.statfs_delta;
17386-
// update shared blobs
17387-
for (auto b: wr.shared_changed) {
17388-
txc->write_shared_blob(b);
17389-
}
1739017382
o->extent_map.compress_extent_map(offset, length);
1739117383
o->extent_map.dirty_range(offset, length);
1739217384
o->extent_map.maybe_reshard(offset, offset + length);

src/os/bluestore/Writer.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,11 +1101,12 @@ std::pair<bool, uint32_t> BlueStore::Writer::_write_expand_l(
11011101
bool new_data_pad = true; // unless otherwise stated, we pad
11021102
exmp_it it = onode->extent_map.seek_lextent(logical_offset);
11031103
// it can be extent in which we are interested in
1104-
if (it == onode->extent_map.extent_map.end()) {
1104+
if (it == onode->extent_map.extent_map.end() ||
1105+
it->logical_offset >= logical_offset) {
11051106
if (it == onode->extent_map.extent_map.begin()) {
11061107
goto done;
11071108
}
1108-
--it; //step back to first element
1109+
--it; //step back to the first extent to consider
11091110
}
11101111
do {
11111112
if (it->logical_end() < off_stop) {
@@ -1247,6 +1248,8 @@ void BlueStore::Writer::_split_data(
12471248
bufferlist& data,
12481249
blob_vec& bd)
12491250
{
1251+
ceph_assert(bd.empty());
1252+
bd.reserve(data.length() / wctx->target_blob_size + 2);
12501253
auto lof = location;
12511254
uint32_t end_offset = location + data.length();
12521255
while (lof < end_offset) {
@@ -1371,6 +1374,12 @@ void BlueStore::Writer::do_write(
13711374
if (onode->onode.size < ref_end)
13721375
onode->onode.size = ref_end;
13731376
_collect_released_allocated();
1377+
// update statfs
1378+
txc->statfs_delta += statfs_delta;
1379+
// update shared blobs
1380+
for (auto b: shared_changed) {
1381+
txc->write_shared_blob(b);
1382+
}
13741383
dout(25) << "result: " << std::endl << onode->print(pp_mode) << dendl;
13751384
}
13761385

0 commit comments

Comments
 (0)