Skip to content

Commit 5326fed

Browse files
committed
os/bluestore: Writer, fix find_mutable_blob
1) Algorithm assumed that blob->blob_start() is aligned to csum size. It is true for blobs created by write_v2, but write_v1 can generate blob like: begin = 0x9000, size = 0x6000, csum = 0x2000. 2) Blobs with unused were selected even if those need to be expanded. This is illegal since we cannot expand unused. Fixed blob selection algorithm. Signed-off-by: Adam Kupczyk <[email protected]>
1 parent 938a0f1 commit 5326fed

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/os/bluestore/Writer.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,14 @@ inline BlueStore::extent_map_t::iterator BlueStore::Writer::_find_mutable_blob_l
243243
auto bblob = it->blob->get_blob();
244244
if (!bblob.is_mutable()) continue;
245245
if (bblob.has_csum()) {
246-
uint32_t mask = mapmust_begin | mapmust_end;
246+
uint32_t mask = (mapmust_begin - it->blob_start()) |
247+
(mapmust_end - it->blob_start());
247248
if (p2phase(mask, bblob.get_csum_chunk_size()) != 0) continue;
248249
}
250+
if (bblob.has_unused()) {
251+
// very difficult to expand blob with unused (our unused logic is ekhm)
252+
if (it->blob_end() <= mapmust_end) continue;
253+
}
249254
return it;
250255
} while (it != map.begin());
251256
return map.end();
@@ -267,12 +272,16 @@ inline BlueStore::extent_map_t::iterator BlueStore::Writer::_find_mutable_blob_r
267272
auto bblob = it->blob->get_blob();
268273
if (!bblob.is_mutable()) continue;
269274
if (bblob.has_csum()) {
270-
uint32_t mask = mapmust_begin | mapmust_end;
275+
uint32_t mask = (mapmust_begin - it->blob_start()) |
276+
(mapmust_end - it->blob_start());
271277
if (p2phase(mask, bblob.get_csum_chunk_size()) != 0) continue;
272278
}
279+
if (bblob.has_unused()) {
280+
// very difficult to expand blob with unused (our unused logic is ekhm)
281+
if (it->blob_end() <= mapmust_end) continue;
282+
}
273283
return it;
274284
break;
275-
//++it;
276285
};
277286
return map.end();
278287
}

0 commit comments

Comments
 (0)