From 9e847a917f4fd462a846bdf50c363acc29cd6d1b Mon Sep 17 00:00:00 2001 From: Adam Kupczyk Date: Fri, 24 May 2024 09:50:04 +0200 Subject: [PATCH] os/bluestore: Writer, fix _try_reuse_allocated_l/r It was not checked if necessary location is still within blob range. Signed-off-by: Adam Kupczyk --- src/os/bluestore/Writer.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/os/bluestore/Writer.cc b/src/os/bluestore/Writer.cc index 9cfb25edb666e..cfdaa096418f7 100644 --- a/src/os/bluestore/Writer.cc +++ b/src/os/bluestore/Writer.cc @@ -739,8 +739,10 @@ void BlueStore::Writer::_try_reuse_allocated_l( want_subau_end = logical_offset + data.length(); if (p2phase(want_subau_end, chunk_size) !=0) continue; } + if (want_subau_begin < it->blob_start()) continue; + if (want_subau_begin >= it->blob_end()) continue; uint32_t in_blob_offset = want_subau_begin - blob_offset; - uint64_t subau_disk_offset = bb.get_allocation_at(want_subau_begin - blob_offset); + uint64_t subau_disk_offset = bb.get_allocation_at(in_blob_offset); if (subau_disk_offset == bluestore_blob_t::NO_ALLOCATION) continue; dout(25) << __func__ << " 0x" << std::hex << want_subau_begin << "-" << want_subau_end << std::dec << " -> " << b->print(pp_mode) << dendl; @@ -812,8 +814,10 @@ void BlueStore::Writer::_try_reuse_allocated_r( want_subau_begin = end_offset - data.length(); if (p2phase(want_subau_begin, chunk_size) != 0) continue; //case B } + if (want_subau_begin < it->blob_start()) continue; + if (want_subau_begin >= it->blob_end()) continue; uint32_t in_blob_offset = want_subau_begin - blob_offset; - uint64_t subau_disk_offset = bb.get_allocation_at(want_subau_begin - blob_offset); + uint64_t subau_disk_offset = bb.get_allocation_at(in_blob_offset); if (subau_disk_offset == bluestore_blob_t::NO_ALLOCATION) continue; dout(25) << __func__ << " 0x" << std::hex << want_subau_begin << "-" << want_subau_end << std::dec << " -> " << b->print(pp_mode) << dendl; -- 2.39.5