diff mbox

[1/2] btrfs-progs: convert: Fix a bug leads to discontinuous extents

Message ID 20160627075011.24330-1-quwenruo@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Qu Wenruo June 27, 2016, 7:50 a.m. UTC
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 <quwenruo@cn.fujitsu.com>
---
 extent-tree.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

David Sterba July 4, 2016, 11:48 a.m. UTC | #1
On Mon, Jun 27, 2016 at 03:50:10PM +0800, Qu Wenruo wrote:
> 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 <quwenruo@cn.fujitsu.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/extent-tree.c b/extent-tree.c
index 5ca53fa..a58da23 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)