]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore/bluefs_types: consolidate contiguous extents
authorSage Weil <sage@redhat.com>
Mon, 1 Jul 2019 14:33:22 +0000 (09:33 -0500)
committerSage Weil <sage@redhat.com>
Mon, 1 Jul 2019 17:05:38 +0000 (12:05 -0500)
If we allocate a new extent that is contiguous with the last extent,
just extend it.  This avoids having long vectors of continguous extents
when a single large extent would suffice--especially with log files.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/bluefs_types.h

index dca0de61ca5f8e7e3e66be522a2337a0565d30d3..a32ebe4daa9459f11116f44a9c510f330938a62e 100644 (file)
@@ -87,8 +87,14 @@ struct bluefs_fnode_t {
   }
 
   void append_extent(const bluefs_extent_t& ext) {
-    extents_index.emplace_back(allocated);
-    extents.push_back(ext);
+    if (!extents.empty() &&
+       extents.back().end() == ext.offset &&
+       (uint64_t)extents.back().length + (uint64_t)ext.length < 0xffffffff) {
+      extents.back().length += ext.length;
+    } else {
+      extents_index.emplace_back(allocated);
+      extents.push_back(ext);
+    }
     allocated += ext.length;
   }