path: root/extent-tree.c
diff options
authorQu Wenruo <>2016-06-27 15:50:10 +0800
committerDavid Sterba <>2016-07-04 13:44:54 +0200
commitafded5ea48e32e27ed407d920ce8dbb94649c319 (patch)
tree1a72a025bd1fa897c6d34e10c7748882d40ecb91 /extent-tree.c
parent82aaf603e0e3e2d4302616c0b5c6e45246deca71 (diff)
btrfs-progs: convert: Fix a bug leads to discontinuous extents
Btrfs_record_file_extent() will split extents using max extent size(128M). It works well for real file extents, but not that well for large hole extent, as hole doesn't have extent size limit. In that case, it will only insert one 128M hole, and skip the rest, leading to discontinuous extent error for converted btrfs. Fix it by not splitting hole extents. Signed-off-by: Qu Wenruo <> Signed-off-by: David Sterba <>
Diffstat (limited to 'extent-tree.c')
1 files changed, 3 insertions, 1 deletions
diff --git a/extent-tree.c b/extent-tree.c
index 5ca53fa9..a58da237 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -3985,10 +3985,11 @@ static int __btrfs_record_file_extent(struct btrfs_trans_handle *trans,
u64 extent_offset;
u64 num_bytes = *ret_num_bytes;
- num_bytes = min_t(u64, num_bytes, BTRFS_MAX_EXTENT_SIZE);
* All supported file system should not use its 0 extent.
* As it's for hole
+ *
+ * And hole extent has no size limit, no need to loop.
if (disk_bytenr == 0) {
ret = btrfs_insert_file_extent(trans, root, objectid,
@@ -3996,6 +3997,7 @@ static int __btrfs_record_file_extent(struct btrfs_trans_handle *trans,
num_bytes, num_bytes);
return ret;
+ num_bytes = min_t(u64, num_bytes, BTRFS_MAX_EXTENT_SIZE);
path = btrfs_alloc_path();
if (!path)