All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] btrfs-progs: convert: Fix a bug leads to discontinuous extents
@ 2016-06-27  7:50 Qu Wenruo
  2016-06-27  7:50 ` [PATCH 2/2] btrfs-progs: convert-test: Add test case for discontinuous hole extent Qu Wenruo
  2016-07-04 11:48 ` [PATCH 1/2] btrfs-progs: convert: Fix a bug leads to discontinuous extents David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Qu Wenruo @ 2016-06-27  7:50 UTC (permalink / raw)
  To: linux-btrfs

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(-)

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)
-- 
2.9.0




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] btrfs-progs: convert-test: Add test case for discontinuous hole extent
  2016-06-27  7:50 [PATCH 1/2] btrfs-progs: convert: Fix a bug leads to discontinuous extents Qu Wenruo
@ 2016-06-27  7:50 ` Qu Wenruo
  2016-07-04 11:48 ` [PATCH 1/2] btrfs-progs: convert: Fix a bug leads to discontinuous extents David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2016-06-27  7:50 UTC (permalink / raw)
  To: linux-btrfs

For ext* fs containing a large hole(larger than 128M), btrfs-convert
will only insert one 128M hole extent and skip the remaining.

This leads to discontinuous file extents.

Add test case for it, and since it's a pinpoint regression test case, no
combination of convert options nor checksum verification.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 tests/convert-tests/006-large-hole-extent/test.sh | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100755 tests/convert-tests/006-large-hole-extent/test.sh

diff --git a/tests/convert-tests/006-large-hole-extent/test.sh b/tests/convert-tests/006-large-hole-extent/test.sh
new file mode 100755
index 0000000..d3bc093
--- /dev/null
+++ b/tests/convert-tests/006-large-hole-extent/test.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+# Create a base image with large hole extent, then convert to btrfs,
+# check the converted image.
+# Check if btrfs-convert can handle such large hole.
+# Fast pinpoint regression test. No options combination nor checksum
+# verification
+
+source $TOP/tests/common
+source $TOP/tests/common.convert
+
+setup_root_helper
+prepare_test_dev 512M
+check_prereq btrfs-convert
+
+default_mke2fs="mke2fs -t ext4 -b 4096"
+convert_test_preamble '' 'large hole extent test' 16k "$default_mke2fs"
+convert_test_prep_fs $default_mke2fs
+
+run_check $SUDO_HELPER dd if=/dev/zero of=$TEST_MNT/file bs=1M \
+	count=1 seek=1024 > /dev/null 2>&1
+
+run_check_umount_test_dev
+convert_test_do_convert 
-- 
2.9.0




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] btrfs-progs: convert: Fix a bug leads to discontinuous extents
  2016-06-27  7:50 [PATCH 1/2] btrfs-progs: convert: Fix a bug leads to discontinuous extents Qu Wenruo
  2016-06-27  7:50 ` [PATCH 2/2] btrfs-progs: convert-test: Add test case for discontinuous hole extent Qu Wenruo
@ 2016-07-04 11:48 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2016-07-04 11:48 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-04 11:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-27  7:50 [PATCH 1/2] btrfs-progs: convert: Fix a bug leads to discontinuous extents Qu Wenruo
2016-06-27  7:50 ` [PATCH 2/2] btrfs-progs: convert-test: Add test case for discontinuous hole extent Qu Wenruo
2016-07-04 11:48 ` [PATCH 1/2] btrfs-progs: convert: Fix a bug leads to discontinuous extents David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.