]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Writer, fix _try_reuse_allocated_l/r
authorAdam Kupczyk <akupczyk@ibm.com>
Fri, 24 May 2024 07:50:04 +0000 (09:50 +0200)
committerAdam Kupczyk <akupczyk@ibm.com>
Wed, 7 Aug 2024 10:55:46 +0000 (10:55 +0000)
It was not checked if necessary location is still within blob range.

Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
src/os/bluestore/Writer.cc

index 9cfb25edb666e57cd04af142fb026828b527ccff..cfdaa096418f7bbab0f1a34e16de600f033ea213 100644 (file)
@@ -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;