]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Make write_v2 calculate affected range
authorAdam Kupczyk <akupczyk@ibm.com>
Tue, 25 Feb 2025 09:56:43 +0000 (09:56 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Thu, 13 Mar 2025 06:52:03 +0000 (06:52 +0000)
This reduces size for dirty_range and need_reshard range.

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

index cd36ad6eabe24a4c21c795404944507bbae57ecc..00d07ec6ec5be413fe9cca9fa3fe24b1c7805eb3 100644 (file)
@@ -17656,9 +17656,13 @@ int BlueStore::_do_write_v2(
   BlueStore::Writer wr(this, txc, &wctx, o);
   uint64_t start = p2align(offset, min_alloc_size);
   uint64_t end = p2roundup(offset + length, min_alloc_size);
+  wr.left_affected_range = start;
+  wr.right_affected_range = end;
   std::tie(wr.left_shard_bound, wr.right_shard_bound) =
     o->extent_map.fault_range_ex(db, start, end - start);
   wr.do_write(offset, bl);
+  o->extent_map.dirty_range(wr.left_affected_range, wr.right_affected_range - wr.left_affected_range);
+  o->extent_map.maybe_reshard(wr.left_affected_range, wr.right_affected_range);
   return r;
 }
 
index ef9d4b18971f481a89bab575ec4b16fdcc2c35a3..41f2845e85ef0ec501b4e4503689853e09d8f39c 100644 (file)
@@ -558,12 +558,14 @@ inline void BlueStore::Writer::_place_extent_in_blob(
       // we can just expand existing Extent
       ex->length += map_end - map_begin;
       dout(20) << __func__ << " expanded extent " << ex->print(pp_mode) << dendl;
+      left_affected_range = std::min(left_affected_range, ex->logical_offset);
     } else {
       // disjointed, new extent needed
       Extent *le = new Extent(
         map_begin, in_blob_offset, map_end - map_begin, ex->blob);
       dout(20) << __func__ << " new extent " << le->print(pp_mode) << dendl;
       onode->extent_map.extent_map.insert(*le);
+      left_affected_range = std::min(left_affected_range, le->logical_offset);
     }
   } else if (ex->logical_offset >= map_end) {
     // we are adding to left side of target
@@ -574,12 +576,14 @@ inline void BlueStore::Writer::_place_extent_in_blob(
       ex->blob_offset -= (map_end - map_begin);
       ex->length += (map_end - map_begin);
       dout(20) << __func__ << " expanded extent " << ex->print(pp_mode) << dendl;
+      right_affected_range = std::max(right_affected_range, ex->logical_end());
     } else {
       // disjointed, new extent needed
       Extent *le = new Extent(
         map_begin, in_blob_offset, map_end - map_begin, ex->blob);
       dout(20) << __func__ << " new extent " << le->print(pp_mode) << dendl;
       onode->extent_map.extent_map.insert(*le);
+      right_affected_range = std::max(right_affected_range, le->logical_end());
     }
   }
 }
@@ -1404,8 +1408,6 @@ void BlueStore::Writer::do_write(
   _collect_released_allocated();
   // update statfs
   txc->statfs_delta += statfs_delta;
-  onode->extent_map.dirty_range(location, data_end-location);
-  onode->extent_map.maybe_reshard(location, data_end);
   // note: compress extent is not needed; _try_reuse_allocated_* joins extents if possible
   // in other cases new blobs cannot be joined with existing ones
   dout(25) << "result: " << std::endl << onode->print(pp_mode) << dendl;
index ae24066bdcc0628c3d7ccdb4519d253e2cc92e8f..39f7c477b15b2edf65c141bae22ea0600d81cc29 100644 (file)
@@ -70,7 +70,8 @@ public:
   volatile_statfs statfs_delta;
   uint32_t left_shard_bound;  // if sharding is in effect,
   uint32_t right_shard_bound; // do not cross this line
-
+  uint32_t left_affected_range;
+  uint32_t right_affected_range;
 private:
   BlueStore* bstore;
   TransContext* txc;