From: Sage Weil Date: Mon, 1 Jul 2019 14:33:22 +0000 (-0500) Subject: os/bluestore/bluefs_types: consolidate contiguous extents X-Git-Tag: v15.1.0~2307^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4f3ce9bc201c20d10d739d42e3f7018408f110a6;p=ceph-ci.git os/bluestore/bluefs_types: consolidate contiguous extents 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 --- diff --git a/src/os/bluestore/bluefs_types.h b/src/os/bluestore/bluefs_types.h index dca0de61ca5..a32ebe4daa9 100644 --- a/src/os/bluestore/bluefs_types.h +++ b/src/os/bluestore/bluefs_types.h @@ -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; }