linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfstests: add test for btrfs cloning with file holes
@ 2014-05-31  1:17 Filipe David Borba Manana
  2014-05-31 14:12 ` [PATCH v2] " Filipe David Borba Manana
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Filipe David Borba Manana @ 2014-05-31  1:17 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe David Borba Manana

Regression test for the btrfs ioctl clone operation when the source range
contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
don't need file extent items in the btree to represent them).

This issue is fixed by the following linux kernel btrfs patch:

    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---
 tests/btrfs/055     | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/055.out |  43 ++++++++++++++++++++++
 tests/btrfs/group   |   1 +
 3 files changed, 144 insertions(+)
 create mode 100755 tests/btrfs/055
 create mode 100644 tests/btrfs/055.out

diff --git a/tests/btrfs/055 b/tests/btrfs/055
new file mode 100755
index 0000000..7241b66
--- /dev/null
+++ b/tests/btrfs/055
@@ -0,0 +1,100 @@
+#! /bin/bash
+# FS QA Test No. btrfs/055
+#
+# Regression test for the btrfs ioctl clone operation when the source range
+# contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
+# don't need file extent items in the btree to represent them).
+#
+# This issue is fixed by the following linux kernel btrfs patch:
+#
+#    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    rm -fr $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_btrfs_cloner
+_need_to_be_root
+
+rm -f $seqres.full
+
+test_btrfs_clone_with_holes()
+{
+	_scratch_mkfs "$1" >/dev/null 2>&1
+	_scratch_mount $MOUNT_OPTIONS
+
+	# Create a file with 4 extents and 1 hole, all with a size of 8Kb each.
+	$XFS_IO_PROG -f -c "pwrite -S 0x01 -b 8192 0 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+	$XFS_IO_PROG -c "pwrite -S 0x02 -b 8192 8192 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+	# After the following write we get a hole in the range [16384, 24576[
+	$XFS_IO_PROG -c "pwrite -S 0x04 -b 8192 24576 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+	$XFS_IO_PROG -c "pwrite -S 0x05 -b 8192 32768 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+
+	# Clone destination file, 1 extent of 64kb.
+	$XFS_IO_PROG -f -c "pwrite -S 0xff -b 64536 0 64536" $SCRATCH_MNT/bar \
+		| _filter_xfs_io
+	sync
+
+	# Clone 2nd extent, 8Kb hole and 3rd extent of foo into bar.
+	$CLONER_PROG -s 8192 -d 0 -l 24576 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
+
+	# Verify both extents and the hole were cloned.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Verify that there are no consistency errors.
+	_check_scratch_fs
+}
+
+echo "Testing without the NO_HOLES feature"
+test_btrfs_clone_with_holes
+
+_scratch_unmount
+
+echo "Testing with the NO_HOLES feature enabled"
+test_btrfs_clone_with_holes "-O no-holes"
+
+status=0
+exit
diff --git a/tests/btrfs/055.out b/tests/btrfs/055.out
new file mode 100644
index 0000000..faa0477
--- /dev/null
+++ b/tests/btrfs/055.out
@@ -0,0 +1,43 @@
+QA output created by 055
+Testing without the NO_HOLES feature
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 8192
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 24576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 32768
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 64536/64536 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0176020 ff ff ff ff ff ff ff ff
+0176030
+Testing with the NO_HOLES feature enabled
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 8192
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 24576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 32768
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 64536/64536 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0176020 ff ff ff ff ff ff ff ff
+0176030
diff --git a/tests/btrfs/group b/tests/btrfs/group
index b668485..2c10c5b 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -57,3 +57,4 @@
 052 auto quick
 053 auto quick
 054 auto quick
+055 auto quick
-- 
1.9.1


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

* [PATCH v2] xfstests: add test for btrfs cloning with file holes
  2014-05-31  1:17 [PATCH] xfstests: add test for btrfs cloning with file holes Filipe David Borba Manana
@ 2014-05-31 14:12 ` Filipe David Borba Manana
  2014-06-03 12:32   ` Lukáš Czerner
  2014-05-31 16:21 ` [PATCH v3] " Filipe David Borba Manana
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Filipe David Borba Manana @ 2014-05-31 14:12 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe David Borba Manana

Regression test for the btrfs ioctl clone operation when the source range
contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
don't need file extent items in the btree to represent them).

This issue is fixed by the following linux kernel btrfs patch:

    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---

V2: Increased test coverage by testing the cases where a hole overlaps
    the start and end of the cloning range.

 tests/btrfs/055     | 112 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/055.out | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/group   |   1 +
 3 files changed, 230 insertions(+)
 create mode 100755 tests/btrfs/055
 create mode 100644 tests/btrfs/055.out

diff --git a/tests/btrfs/055 b/tests/btrfs/055
new file mode 100755
index 0000000..4a1614b
--- /dev/null
+++ b/tests/btrfs/055
@@ -0,0 +1,112 @@
+#! /bin/bash
+# FS QA Test No. btrfs/055
+#
+# Regression test for the btrfs ioctl clone operation when the source range
+# contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
+# don't need file extent items in the btree to represent them).
+#
+# This issue is fixed by the following linux kernel btrfs patch:
+#
+#    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    rm -fr $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_btrfs_cloner
+_need_to_be_root
+
+rm -f $seqres.full
+
+test_btrfs_clone_with_holes()
+{
+	_scratch_mkfs "$1" >/dev/null 2>&1
+	_scratch_mount
+
+	# Create a file with 4 extents and 1 hole, all with a size of 8Kb each.
+	$XFS_IO_PROG -f -c "pwrite -S 0x01 -b 8192 0 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+	$XFS_IO_PROG -c "pwrite -S 0x02 -b 8192 8192 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+	# After the following write we get a hole in the range [16384, 24576[
+	$XFS_IO_PROG -c "pwrite -S 0x04 -b 8192 24576 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+	$XFS_IO_PROG -c "pwrite -S 0x05 -b 8192 32768 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+
+	# Clone destination file, 1 extent of 96kb.
+	$XFS_IO_PROG -f -c "pwrite -S 0xff -b 98304 0 98304" $SCRATCH_MNT/bar \
+		| _filter_xfs_io
+	sync
+
+	# Clone 2nd extent, 8Kb hole and 3rd extent of foo into bar.
+	$CLONER_PROG -s 8192 -d 0 -l 24576 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
+
+	# Verify both extents and the hole were cloned.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Cloning range starts at the middle of a hole.
+	$CLONER_PROG -s 20480 -d 32768 -l 12288 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
+
+	# Verify that half of the hole and the following 8Kb extent were cloned.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Cloning range ends at the middle of a hole.
+	$CLONER_PROG -s 0 -d 65536 -l 20480 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
+
+	# Verify that 2 extents of 8kb and a 4kb hole were cloned.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Verify that there are no consistency errors.
+	_check_scratch_fs
+}
+
+echo "Testing without the NO_HOLES feature"
+test_btrfs_clone_with_holes
+
+_scratch_unmount
+
+echo "Testing with the NO_HOLES feature enabled"
+test_btrfs_clone_with_holes "-O no-holes"
+
+status=0
+exit
diff --git a/tests/btrfs/055.out b/tests/btrfs/055.out
new file mode 100644
index 0000000..cd627ce
--- /dev/null
+++ b/tests/btrfs/055.out
@@ -0,0 +1,117 @@
+QA output created by 055
+Testing without the NO_HOLES feature
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 8192
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 24576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 32768
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 98304/98304 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+Testing with the NO_HOLES feature enabled
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 8192
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 24576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 32768
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 98304/98304 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
diff --git a/tests/btrfs/group b/tests/btrfs/group
index b668485..2c10c5b 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -57,3 +57,4 @@
 052 auto quick
 053 auto quick
 054 auto quick
+055 auto quick
-- 
1.9.1


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

* [PATCH v3] xfstests: add test for btrfs cloning with file holes
  2014-05-31  1:17 [PATCH] xfstests: add test for btrfs cloning with file holes Filipe David Borba Manana
  2014-05-31 14:12 ` [PATCH v2] " Filipe David Borba Manana
@ 2014-05-31 16:21 ` Filipe David Borba Manana
  2014-06-01 13:06 ` [PATCH v4] " Filipe David Borba Manana
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Filipe David Borba Manana @ 2014-05-31 16:21 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe David Borba Manana

Regression test for the btrfs ioctl clone operation when the source range
contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
don't need file extent items in the btree to represent them).

This issue is fixed by the following linux kernel btrfs patch:

    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---

V2: Increased test coverage by testing the cases where a hole overlaps
    the start and end of the cloning range.

V3: Test the case where the cloning range includes an hole at the end
    of the source file and might increase the size of the target file.

 tests/btrfs/055     | 141 ++++++++++++++++++++++++++++++++
 tests/btrfs/055.out | 225 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/group   |   1 +
 3 files changed, 367 insertions(+)
 create mode 100755 tests/btrfs/055
 create mode 100644 tests/btrfs/055.out

diff --git a/tests/btrfs/055 b/tests/btrfs/055
new file mode 100755
index 0000000..fad4b1c
--- /dev/null
+++ b/tests/btrfs/055
@@ -0,0 +1,141 @@
+#! /bin/bash
+# FS QA Test No. btrfs/055
+#
+# Regression test for the btrfs ioctl clone operation when the source range
+# contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
+# don't need file extent items in the btree to represent them).
+#
+# This issue is fixed by the following linux kernel btrfs patch:
+#
+#    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    rm -fr $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_btrfs_cloner
+_need_to_be_root
+
+rm -f $seqres.full
+
+test_btrfs_clone_with_holes()
+{
+	_scratch_mkfs "$1" >/dev/null 2>&1
+	_scratch_mount
+
+	# Create a file with 4 extents and 1 hole, all with a size of 8Kb each.
+	$XFS_IO_PROG -f -c "pwrite -S 0x01 -b 8192 0 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+	$XFS_IO_PROG -c "pwrite -S 0x02 -b 8192 8192 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+	# After the following write we get a hole in the range [16384, 24576[
+	$XFS_IO_PROG -c "pwrite -S 0x04 -b 8192 24576 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+	$XFS_IO_PROG -c "pwrite -S 0x05 -b 8192 32768 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+
+	# Clone destination file, 1 extent of 96kb.
+	$XFS_IO_PROG -f -c "pwrite -S 0xff -b 98304 0 98304" $SCRATCH_MNT/bar \
+		| _filter_xfs_io
+	sync
+
+	# Clone 2nd extent, 8Kb hole and 3rd extent of foo into bar.
+	$CLONER_PROG -s 8192 -d 0 -l 24576 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
+
+	# Verify both extents and the hole were cloned.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Cloning range starts at the middle of a hole.
+	$CLONER_PROG -s 20480 -d 32768 -l 12288 $SCRATCH_MNT/foo \
+		$SCRATCH_MNT/bar
+
+	# Verify that half of the hole and the following 8Kb extent were cloned.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Cloning range ends at the middle of a hole.
+	$CLONER_PROG -s 0 -d 65536 -l 20480 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
+
+	# Verify that 2 extents of 8kb and a 4kb hole were cloned.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Create a 24Kb hole at the end of the source file (foo).
+	$XFS_IO_PROG -c "truncate 65536" $SCRATCH_MNT/foo
+	sync
+
+	# Now clone a range that overlaps that hole at the end of the foo file.
+	# It should clone the last 4Kb of the extent at offset 32768 and the
+	# first 8kb of the 24kb hole at the end of foo.
+	$CLONER_PROG -s 36864 -d 86016 -l 12288 $SCRATCH_MNT/foo \
+		$SCRATCH_MNT/bar
+
+	# Verify that the second half of the 8Kb extent at offset 32768 of foo
+	# and the first 8Kb of the 24kb hole of foo were cloned into bar.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Clone the same range as before, but clone it into a different offset
+	# of the target (bar) such that it increases the size of the target
+	# by 8Kb.
+	$CLONER_PROG -s 36864 -d 94208 -l 12288 $SCRATCH_MNT/foo \
+		$SCRATCH_MNT/bar
+
+	# Verify that the second half of the 8Kb extent at offset 32768 of foo
+	# and the first 8Kb of the 24kb hole of foo were cloned into bar at
+	# bar's offset 94208 and that bar's size increased by 8Kb.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Verify that there are no consistency errors.
+	_check_scratch_fs
+}
+
+# Regardless of the NO_HOLES feature being enabled or not, the test results
+# should be exactly the same for both cases.
+
+echo "Testing without the NO_HOLES feature"
+test_btrfs_clone_with_holes
+
+_scratch_unmount
+
+echo "Testing with the NO_HOLES feature enabled"
+test_btrfs_clone_with_holes "-O no-holes"
+
+status=0
+exit
diff --git a/tests/btrfs/055.out b/tests/btrfs/055.out
new file mode 100644
index 0000000..795c8d1
--- /dev/null
+++ b/tests/btrfs/055.out
@@ -0,0 +1,225 @@
+QA output created by 055
+Testing without the NO_HOLES feature
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 8192
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 24576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 32768
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 98304/98304 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0320000
+Testing with the NO_HOLES feature enabled
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 8192
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 24576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 32768
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 98304/98304 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0320000
diff --git a/tests/btrfs/group b/tests/btrfs/group
index b668485..2c10c5b 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -57,3 +57,4 @@
 052 auto quick
 053 auto quick
 054 auto quick
+055 auto quick
-- 
1.9.1


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

* [PATCH v4] xfstests: add test for btrfs cloning with file holes
  2014-05-31  1:17 [PATCH] xfstests: add test for btrfs cloning with file holes Filipe David Borba Manana
  2014-05-31 14:12 ` [PATCH v2] " Filipe David Borba Manana
  2014-05-31 16:21 ` [PATCH v3] " Filipe David Borba Manana
@ 2014-06-01 13:06 ` Filipe David Borba Manana
  2014-06-03 12:46   ` Lukáš Czerner
  2014-06-03 14:37 ` [PATCH v5] " Filipe David Borba Manana
  2014-06-10 10:12 ` [PATCH v6] " Filipe David Borba Manana
  4 siblings, 1 reply; 10+ messages in thread
From: Filipe David Borba Manana @ 2014-06-01 13:06 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe David Borba Manana

Regression test for the btrfs ioctl clone operation when the source range
contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
don't need file extent items in the btree to represent them).

This issue is fixed by the following linux kernel btrfs patch:

    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---

V2: Increased test coverage by testing the cases where a hole overlaps
    the start and end of the cloning range.

V3: Test the case where the cloning range includes an hole at the end
    of the source file and might increase the size of the target file.

V4: Added test for the case where the clone range covers only a hole at
    the beginning of the source file.
    Made the test be skipped if the available version of mkfs.btrfs
    doesn't support the no-holes feature. And when testing the case
    where the no-holes feature isn't enabled, explicitly ask mkfs.btrfs
    to disable no-holes (future versions of mkfs.btrfs might enable
    this feature by default).

 common/rc           |  13 ++
 tests/btrfs/055     | 165 ++++++++++++++++++++++++++
 tests/btrfs/055.out | 333 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/group   |   1 +
 4 files changed, 512 insertions(+)
 create mode 100755 tests/btrfs/055
 create mode 100644 tests/btrfs/055.out

diff --git a/common/rc b/common/rc
index f27ee53..0ef0ece 100644
--- a/common/rc
+++ b/common/rc
@@ -2177,6 +2177,19 @@ _require_btrfs_send_stream_version()
 	fi
 }
 
+_require_btrfs_fs_feature()
+{
+	if [ -z $1 ]; then
+		echo "Missing feature name argument for _require_btrfs_fs_feature"
+		exit 1
+	fi
+	feat=$1
+	$MKFS_BTRFS_PROG -O list-all 2>&1 | \
+		grep '^[ \t]*'"$feat"'\b' > /dev/null 2>&1
+	[ $? -eq 0 ] || \
+		_notrun "Feature $feat not supported in the available version of mkfs.btrfs"
+}
+
 init_rc()
 {
 	if [ "$iam" == new ]
diff --git a/tests/btrfs/055 b/tests/btrfs/055
new file mode 100755
index 0000000..0e67c88
--- /dev/null
+++ b/tests/btrfs/055
@@ -0,0 +1,165 @@
+#! /bin/bash
+# FS QA Test No. btrfs/055
+#
+# Regression test for the btrfs ioctl clone operation when the source range
+# contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
+# don't need file extent items in the btree to represent them).
+#
+# This issue is fixed by the following linux kernel btrfs patch:
+#
+#    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    rm -fr $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_btrfs_cloner
+_require_btrfs_fs_feature "no-holes"
+_need_to_be_root
+
+rm -f $seqres.full
+
+test_btrfs_clone_with_holes()
+{
+	_scratch_mkfs "$1" >/dev/null 2>&1
+	_scratch_mount
+
+	# Create a file with 4 extents and 1 hole, all with a size of 8Kb each.
+	$XFS_IO_PROG -f -c "pwrite -S 0x01 -b 8192 0 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+	$XFS_IO_PROG -c "pwrite -S 0x02 -b 8192 8192 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+	# After the following write we get a hole in the range [16384, 24576[
+	$XFS_IO_PROG -c "pwrite -S 0x04 -b 8192 24576 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+	$XFS_IO_PROG -c "pwrite -S 0x05 -b 8192 32768 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+
+	# Clone destination file, 1 extent of 96kb.
+	$XFS_IO_PROG -f -c "pwrite -S 0xff -b 98304 0 98304" $SCRATCH_MNT/bar \
+		| _filter_xfs_io
+	sync
+
+	# Clone 2nd extent, 8Kb hole and 3rd extent of foo into bar.
+	$CLONER_PROG -s 8192 -d 0 -l 24576 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
+
+	# Verify both extents and the hole were cloned.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Cloning range starts at the middle of a hole.
+	$CLONER_PROG -s 20480 -d 32768 -l 12288 $SCRATCH_MNT/foo \
+		$SCRATCH_MNT/bar
+
+	# Verify that half of the hole and the following 8Kb extent were cloned.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Cloning range ends at the middle of a hole.
+	$CLONER_PROG -s 0 -d 65536 -l 20480 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
+
+	# Verify that 2 extents of 8kb and a 4kb hole were cloned.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Create a 24Kb hole at the end of the source file (foo).
+	$XFS_IO_PROG -c "truncate 65536" $SCRATCH_MNT/foo
+	sync
+
+	# Now clone a range that overlaps that hole at the end of the foo file.
+	# It should clone the last 4Kb of the extent at offset 32768 and the
+	# first 8kb of the 24kb hole at the end of foo.
+	$CLONER_PROG -s 36864 -d 86016 -l 12288 $SCRATCH_MNT/foo \
+		$SCRATCH_MNT/bar
+
+	# Verify that the second half of the 8Kb extent at offset 32768 of foo
+	# and the first 8Kb of the 24kb hole of foo were cloned into bar.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Clone the same range as before, but clone it into a different offset
+	# of the target (bar) such that it increases the size of the target
+	# by 8Kb.
+	$CLONER_PROG -s 36864 -d 94208 -l 12288 $SCRATCH_MNT/foo \
+		$SCRATCH_MNT/bar
+
+	# Verify that the second half of the 8Kb extent at offset 32768 of foo
+	# and the first 8Kb of the 24kb hole of foo were cloned into bar at
+	# bar's offset 94208 and that bar's size increased by 8Kb.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Create a new completely sparse file (no extents, it's a big hole).
+	$XFS_IO_PROG -f -c "truncate 100000" $SCRATCH_MNT/qwerty
+	sync
+
+	# Test cloning a range from the sparse file to the bar file without
+	# increasing bar's size.
+	$CLONER_PROG -s 4096 -d 0 -l 8192 $SCRATCH_MNT/qwerty $SCRATCH_MNT/bar
+
+	# First 8Kb of bar should now be zeroes.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Test cloning a range from the sparse file to the end of the bar file.
+	# The bar file currently has a size of 106496 bytes.
+	$CLONER_PROG -s 0 -d 106496 -l 32768 $SCRATCH_MNT/qwerty \
+		$SCRATCH_MNT/bar
+
+	# Verify bar's size increased to 106496 + 32768 bytes (136Kb), and its
+	# last 32768 bytes are all zeroes.
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Verify that there are no consistency errors.
+	_check_scratch_fs
+}
+
+# Regardless of the NO_HOLES feature being enabled or not, the test results
+# should be exactly the same for both cases.
+
+echo "Testing without the NO_HOLES feature"
+# As of btrfs-progs 3.14.x, the no-holes feature isn't enabled by default.
+# But explicitly disable it at mkfs time as it might be enabled by default
+# in future versions.
+test_btrfs_clone_with_holes "-O ^no-holes"
+
+_scratch_unmount
+
+echo "Testing with the NO_HOLES feature enabled"
+test_btrfs_clone_with_holes "-O no-holes"
+
+status=0
+exit
diff --git a/tests/btrfs/055.out b/tests/btrfs/055.out
new file mode 100644
index 0000000..714ede8
--- /dev/null
+++ b/tests/btrfs/055.out
@@ -0,0 +1,333 @@
+QA output created by 055
+Testing without the NO_HOLES feature
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 8192
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 24576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 32768
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 98304/98304 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0320000
+0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0320000
+0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0420000
+Testing with the NO_HOLES feature enabled
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 8192
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 24576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 32768
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 98304/98304 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0300000
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0320000
+0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0320000
+0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0420000
diff --git a/tests/btrfs/group b/tests/btrfs/group
index b668485..2c10c5b 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -57,3 +57,4 @@
 052 auto quick
 053 auto quick
 054 auto quick
+055 auto quick
-- 
1.9.1


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

* Re: [PATCH v2] xfstests: add test for btrfs cloning with file holes
  2014-05-31 14:12 ` [PATCH v2] " Filipe David Borba Manana
@ 2014-06-03 12:32   ` Lukáš Czerner
  0 siblings, 0 replies; 10+ messages in thread
From: Lukáš Czerner @ 2014-06-03 12:32 UTC (permalink / raw)
  To: Filipe David Borba Manana; +Cc: fstests, linux-btrfs

On Sat, 31 May 2014, Filipe David Borba Manana wrote:

> Date: Sat, 31 May 2014 15:12:45 +0100
> From: Filipe David Borba Manana <fdmanana@gmail.com>
> To: fstests@vger.kernel.org
> Cc: linux-btrfs@vger.kernel.org,
>     Filipe David Borba Manana <fdmanana@gmail.com>
> Subject: [PATCH v2] xfstests: add test for btrfs cloning with file holes
> 
> Regression test for the btrfs ioctl clone operation when the source range
> contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
> don't need file extent items in the btree to represent them).
> 
> This issue is fixed by the following linux kernel btrfs patch:
> 
>     Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled
> 
> Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
> ---
> 
> V2: Increased test coverage by testing the cases where a hole overlaps
>     the start and end of the cloning range.
> 
>  tests/btrfs/055     | 112 +++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/055.out | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/group   |   1 +
>  3 files changed, 230 insertions(+)
>  create mode 100755 tests/btrfs/055
>  create mode 100644 tests/btrfs/055.out
> 
> diff --git a/tests/btrfs/055 b/tests/btrfs/055
> new file mode 100755
> index 0000000..4a1614b
> --- /dev/null
> +++ b/tests/btrfs/055
> @@ -0,0 +1,112 @@
> +#! /bin/bash
> +# FS QA Test No. btrfs/055
> +#
> +# Regression test for the btrfs ioctl clone operation when the source range
> +# contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
> +# don't need file extent items in the btree to represent them).
> +#
> +# This issue is fixed by the following linux kernel btrfs patch:
> +#
> +#    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it would be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#-----------------------------------------------------------------------
> +#
> +
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +tmp=/tmp/$$
> +status=1	# failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +    rm -fr $tmp
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_fs btrfs
> +_supported_os Linux
> +_require_scratch
> +_require_btrfs_cloner
> +_need_to_be_root
> +
> +rm -f $seqres.full
> +
> +test_btrfs_clone_with_holes()
> +{
> +	_scratch_mkfs "$1" >/dev/null 2>&1
> +	_scratch_mount
> +
> +	# Create a file with 4 extents and 1 hole, all with a size of 8Kb each.
> +	$XFS_IO_PROG -f -c "pwrite -S 0x01 -b 8192 0 8192" $SCRATCH_MNT/foo \
> +		| _filter_xfs_io
> +	sync
> +	$XFS_IO_PROG -c "pwrite -S 0x02 -b 8192 8192 8192" $SCRATCH_MNT/foo \
> +		| _filter_xfs_io
> +	sync
> +	# After the following write we get a hole in the range [16384, 24576[
> +	$XFS_IO_PROG -c "pwrite -S 0x04 -b 8192 24576 8192" $SCRATCH_MNT/foo \
> +		| _filter_xfs_io
> +	sync
> +	$XFS_IO_PROG -c "pwrite -S 0x05 -b 8192 32768 8192" $SCRATCH_MNT/foo \
> +		| _filter_xfs_io
> +	sync
> +
> +	# Clone destination file, 1 extent of 96kb.
> +	$XFS_IO_PROG -f -c "pwrite -S 0xff -b 98304 0 98304" $SCRATCH_MNT/bar \
> +		| _filter_xfs_io
> +	sync

you could merge all the XFS_IO_PROG calls into one. and use -W to
sync it.

Otherwise it looks good to me.

Reviewed-by: Lukas Czerner <lczerner@redhat.com>

> +
> +	# Clone 2nd extent, 8Kb hole and 3rd extent of foo into bar.
> +	$CLONER_PROG -s 8192 -d 0 -l 24576 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
> +
> +	# Verify both extents and the hole were cloned.
> +	od -t x1 $SCRATCH_MNT/bar
> +
> +	# Cloning range starts at the middle of a hole.
> +	$CLONER_PROG -s 20480 -d 32768 -l 12288 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
> +
> +	# Verify that half of the hole and the following 8Kb extent were cloned.
> +	od -t x1 $SCRATCH_MNT/bar
> +
> +	# Cloning range ends at the middle of a hole.
> +	$CLONER_PROG -s 0 -d 65536 -l 20480 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
> +
> +	# Verify that 2 extents of 8kb and a 4kb hole were cloned.
> +	od -t x1 $SCRATCH_MNT/bar
> +
> +	# Verify that there are no consistency errors.
> +	_check_scratch_fs
> +}
> +
> +echo "Testing without the NO_HOLES feature"
> +test_btrfs_clone_with_holes
> +
> +_scratch_unmount
> +
> +echo "Testing with the NO_HOLES feature enabled"
> +test_btrfs_clone_with_holes "-O no-holes"
> +
> +status=0
> +exit
> diff --git a/tests/btrfs/055.out b/tests/btrfs/055.out
> new file mode 100644
> index 0000000..cd627ce
> --- /dev/null
> +++ b/tests/btrfs/055.out
> @@ -0,0 +1,117 @@
> +QA output created by 055
> +Testing without the NO_HOLES feature
> +wrote 8192/8192 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 8192/8192 bytes at offset 8192
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 8192/8192 bytes at offset 24576
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 8192/8192 bytes at offset 32768
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 98304/98304 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0300000
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0300000
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
> +*
> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0300000
> +Testing with the NO_HOLES feature enabled
> +wrote 8192/8192 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 8192/8192 bytes at offset 8192
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 8192/8192 bytes at offset 24576
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 8192/8192 bytes at offset 32768
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 98304/98304 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0300000
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0300000
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
> +*
> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0300000
> diff --git a/tests/btrfs/group b/tests/btrfs/group
> index b668485..2c10c5b 100644
> --- a/tests/btrfs/group
> +++ b/tests/btrfs/group
> @@ -57,3 +57,4 @@
>  052 auto quick
>  053 auto quick
>  054 auto quick
> +055 auto quick
> 

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

* Re: [PATCH v4] xfstests: add test for btrfs cloning with file holes
  2014-06-01 13:06 ` [PATCH v4] " Filipe David Borba Manana
@ 2014-06-03 12:46   ` Lukáš Czerner
  2014-06-03 13:36     ` Filipe David Manana
  0 siblings, 1 reply; 10+ messages in thread
From: Lukáš Czerner @ 2014-06-03 12:46 UTC (permalink / raw)
  To: Filipe David Borba Manana; +Cc: fstests, linux-btrfs

On Sun, 1 Jun 2014, Filipe David Borba Manana wrote:

> Date: Sun,  1 Jun 2014 14:06:06 +0100
> From: Filipe David Borba Manana <fdmanana@gmail.com>
> To: fstests@vger.kernel.org
> Cc: linux-btrfs@vger.kernel.org,
>     Filipe David Borba Manana <fdmanana@gmail.com>
> Subject: [PATCH v4] xfstests: add test for btrfs cloning with file holes
> 
> Regression test for the btrfs ioctl clone operation when the source range
> contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
> don't need file extent items in the btree to represent them).
> 
> This issue is fixed by the following linux kernel btrfs patch:
> 
>     Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled
> 
> Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
> ---
> 
> V2: Increased test coverage by testing the cases where a hole overlaps
>     the start and end of the cloning range.
> 
> V3: Test the case where the cloning range includes an hole at the end
>     of the source file and might increase the size of the target file.
> 
> V4: Added test for the case where the clone range covers only a hole at
>     the beginning of the source file.
>     Made the test be skipped if the available version of mkfs.btrfs
>     doesn't support the no-holes feature. And when testing the case
>     where the no-holes feature isn't enabled, explicitly ask mkfs.btrfs
>     to disable no-holes (future versions of mkfs.btrfs might enable
>     this feature by default).
> 
>  common/rc           |  13 ++
>  tests/btrfs/055     | 165 ++++++++++++++++++++++++++
>  tests/btrfs/055.out | 333 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/group   |   1 +
>  4 files changed, 512 insertions(+)
>  create mode 100755 tests/btrfs/055
>  create mode 100644 tests/btrfs/055.out
> 
> diff --git a/common/rc b/common/rc
> index f27ee53..0ef0ece 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2177,6 +2177,19 @@ _require_btrfs_send_stream_version()
>  	fi
>  }
>  
> +_require_btrfs_fs_feature()
> +{
> +	if [ -z $1 ]; then
> +		echo "Missing feature name argument for _require_btrfs_fs_feature"
> +		exit 1
> +	fi
> +	feat=$1
> +	$MKFS_BTRFS_PROG -O list-all 2>&1 | \
> +		grep '^[ \t]*'"$feat"'\b' > /dev/null 2>&1
> +	[ $? -eq 0 ] || \
> +		_notrun "Feature $feat not supported in the available version of mkfs.btrfs"

And what if kernel does not support this ?

> +}
> +
>  init_rc()
>  {
>  	if [ "$iam" == new ]
> diff --git a/tests/btrfs/055 b/tests/btrfs/055
> new file mode 100755
> index 0000000..0e67c88
> --- /dev/null
> +++ b/tests/btrfs/055
> @@ -0,0 +1,165 @@
> +#! /bin/bash
> +# FS QA Test No. btrfs/055
> +#
> +# Regression test for the btrfs ioctl clone operation when the source range
> +# contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
> +# don't need file extent items in the btree to represent them).
> +#
> +# This issue is fixed by the following linux kernel btrfs patch:
> +#
> +#    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it would be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#-----------------------------------------------------------------------
> +#
> +
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +tmp=/tmp/$$
> +status=1	# failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +    rm -fr $tmp
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_fs btrfs
> +_supported_os Linux
> +_require_scratch
> +_require_btrfs_cloner
> +_require_btrfs_fs_feature "no-holes"
> +_need_to_be_root
> +
> +rm -f $seqres.full
> +
> +test_btrfs_clone_with_holes()
> +{
> +	_scratch_mkfs "$1" >/dev/null 2>&1
> +	_scratch_mount
> +
> +	# Create a file with 4 extents and 1 hole, all with a size of 8Kb each.
> +	$XFS_IO_PROG -f -c "pwrite -S 0x01 -b 8192 0 8192" $SCRATCH_MNT/foo \
> +		| _filter_xfs_io
> +	sync
> +	$XFS_IO_PROG -c "pwrite -S 0x02 -b 8192 8192 8192" $SCRATCH_MNT/foo \
> +		| _filter_xfs_io
> +	sync
> +	# After the following write we get a hole in the range [16384, 24576[
> +	$XFS_IO_PROG -c "pwrite -S 0x04 -b 8192 24576 8192" $SCRATCH_MNT/foo \
> +		| _filter_xfs_io
> +	sync
> +	$XFS_IO_PROG -c "pwrite -S 0x05 -b 8192 32768 8192" $SCRATCH_MNT/foo \
> +		| _filter_xfs_io
> +	sync
> +
> +	# Clone destination file, 1 extent of 96kb.
> +	$XFS_IO_PROG -f -c "pwrite -S 0xff -b 98304 0 98304" $SCRATCH_MNT/bar \
> +		| _filter_xfs_io
> +	sync

Again you could merge all pwrite calls into one XFS_IO_PROG command
and use -W to sync.

> +
> +	# Clone 2nd extent, 8Kb hole and 3rd extent of foo into bar.
> +	$CLONER_PROG -s 8192 -d 0 -l 24576 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
> +
> +	# Verify both extents and the hole were cloned.
> +	od -t x1 $SCRATCH_MNT/bar

At this point there are many "od" outputs, so it would be convenient
to at least echo some information so if there is a problem in the
output we can easily identify what caused it.

For example

echo "2. Cloning range starts at the middle of a hole"

Thanks!
-Lukas

> +
> +	# Cloning range starts at the middle of a hole.
> +	$CLONER_PROG -s 20480 -d 32768 -l 12288 $SCRATCH_MNT/foo \
> +		$SCRATCH_MNT/bar
> +
> +	# Verify that half of the hole and the following 8Kb extent were cloned.
> +	od -t x1 $SCRATCH_MNT/bar
> +
> +	# Cloning range ends at the middle of a hole.
> +	$CLONER_PROG -s 0 -d 65536 -l 20480 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
> +
> +	# Verify that 2 extents of 8kb and a 4kb hole were cloned.
> +	od -t x1 $SCRATCH_MNT/bar
> +
> +	# Create a 24Kb hole at the end of the source file (foo).
> +	$XFS_IO_PROG -c "truncate 65536" $SCRATCH_MNT/foo
> +	sync
> +
> +	# Now clone a range that overlaps that hole at the end of the foo file.
> +	# It should clone the last 4Kb of the extent at offset 32768 and the
> +	# first 8kb of the 24kb hole at the end of foo.
> +	$CLONER_PROG -s 36864 -d 86016 -l 12288 $SCRATCH_MNT/foo \
> +		$SCRATCH_MNT/bar
> +
> +	# Verify that the second half of the 8Kb extent at offset 32768 of foo
> +	# and the first 8Kb of the 24kb hole of foo were cloned into bar.
> +	od -t x1 $SCRATCH_MNT/bar
> +
> +	# Clone the same range as before, but clone it into a different offset
> +	# of the target (bar) such that it increases the size of the target
> +	# by 8Kb.
> +	$CLONER_PROG -s 36864 -d 94208 -l 12288 $SCRATCH_MNT/foo \
> +		$SCRATCH_MNT/bar
> +
> +	# Verify that the second half of the 8Kb extent at offset 32768 of foo
> +	# and the first 8Kb of the 24kb hole of foo were cloned into bar at
> +	# bar's offset 94208 and that bar's size increased by 8Kb.
> +	od -t x1 $SCRATCH_MNT/bar
> +
> +	# Create a new completely sparse file (no extents, it's a big hole).
> +	$XFS_IO_PROG -f -c "truncate 100000" $SCRATCH_MNT/qwerty
> +	sync
> +
> +	# Test cloning a range from the sparse file to the bar file without
> +	# increasing bar's size.
> +	$CLONER_PROG -s 4096 -d 0 -l 8192 $SCRATCH_MNT/qwerty $SCRATCH_MNT/bar
> +
> +	# First 8Kb of bar should now be zeroes.
> +	od -t x1 $SCRATCH_MNT/bar
> +
> +	# Test cloning a range from the sparse file to the end of the bar file.
> +	# The bar file currently has a size of 106496 bytes.
> +	$CLONER_PROG -s 0 -d 106496 -l 32768 $SCRATCH_MNT/qwerty \
> +		$SCRATCH_MNT/bar
> +
> +	# Verify bar's size increased to 106496 + 32768 bytes (136Kb), and its
> +	# last 32768 bytes are all zeroes.
> +	od -t x1 $SCRATCH_MNT/bar
> +
> +	# Verify that there are no consistency errors.
> +	_check_scratch_fs
> +}
> +
> +# Regardless of the NO_HOLES feature being enabled or not, the test results
> +# should be exactly the same for both cases.
> +
> +echo "Testing without the NO_HOLES feature"
> +# As of btrfs-progs 3.14.x, the no-holes feature isn't enabled by default.
> +# But explicitly disable it at mkfs time as it might be enabled by default
> +# in future versions.
> +test_btrfs_clone_with_holes "-O ^no-holes"
> +
> +_scratch_unmount
> +
> +echo "Testing with the NO_HOLES feature enabled"
> +test_btrfs_clone_with_holes "-O no-holes"
> +
> +status=0
> +exit
> diff --git a/tests/btrfs/055.out b/tests/btrfs/055.out
> new file mode 100644
> index 0000000..714ede8
> --- /dev/null
> +++ b/tests/btrfs/055.out
> @@ -0,0 +1,333 @@
> +QA output created by 055
> +Testing without the NO_HOLES feature
> +wrote 8192/8192 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 8192/8192 bytes at offset 8192
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 8192/8192 bytes at offset 24576
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 8192/8192 bytes at offset 32768
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 98304/98304 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0300000
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0300000
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
> +*
> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0300000
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
> +*
> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
> +*
> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0300000
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
> +*
> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
> +*
> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
> +*
> +0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0320000
> +0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
> +*
> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
> +*
> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
> +*
> +0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0320000
> +0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
> +*
> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
> +*
> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
> +*
> +0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0420000
> +Testing with the NO_HOLES feature enabled
> +wrote 8192/8192 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 8192/8192 bytes at offset 8192
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 8192/8192 bytes at offset 24576
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 8192/8192 bytes at offset 32768
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +wrote 98304/98304 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0300000
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0300000
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
> +*
> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0300000
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
> +*
> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
> +*
> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0300000
> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
> +*
> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
> +*
> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
> +*
> +0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0320000
> +0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
> +*
> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
> +*
> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
> +*
> +0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0320000
> +0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
> +*
> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
> +*
> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
> +*
> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
> +*
> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
> +*
> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
> +*
> +0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> +*
> +0420000
> diff --git a/tests/btrfs/group b/tests/btrfs/group
> index b668485..2c10c5b 100644
> --- a/tests/btrfs/group
> +++ b/tests/btrfs/group
> @@ -57,3 +57,4 @@
>  052 auto quick
>  053 auto quick
>  054 auto quick
> +055 auto quick
> 

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

* Re: [PATCH v4] xfstests: add test for btrfs cloning with file holes
  2014-06-03 12:46   ` Lukáš Czerner
@ 2014-06-03 13:36     ` Filipe David Manana
  0 siblings, 0 replies; 10+ messages in thread
From: Filipe David Manana @ 2014-06-03 13:36 UTC (permalink / raw)
  To: Lukáš Czerner; +Cc: fstests, linux-btrfs

On Tue, Jun 3, 2014 at 1:46 PM, Lukáš Czerner <lczerner@redhat.com> wrote:
> On Sun, 1 Jun 2014, Filipe David Borba Manana wrote:
>
>> Date: Sun,  1 Jun 2014 14:06:06 +0100
>> From: Filipe David Borba Manana <fdmanana@gmail.com>
>> To: fstests@vger.kernel.org
>> Cc: linux-btrfs@vger.kernel.org,
>>     Filipe David Borba Manana <fdmanana@gmail.com>
>> Subject: [PATCH v4] xfstests: add test for btrfs cloning with file holes
>>
>> Regression test for the btrfs ioctl clone operation when the source range
>> contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
>> don't need file extent items in the btree to represent them).
>>
>> This issue is fixed by the following linux kernel btrfs patch:
>>
>>     Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled
>>
>> Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
>> ---
>>
>> V2: Increased test coverage by testing the cases where a hole overlaps
>>     the start and end of the cloning range.
>>
>> V3: Test the case where the cloning range includes an hole at the end
>>     of the source file and might increase the size of the target file.
>>
>> V4: Added test for the case where the clone range covers only a hole at
>>     the beginning of the source file.
>>     Made the test be skipped if the available version of mkfs.btrfs
>>     doesn't support the no-holes feature. And when testing the case
>>     where the no-holes feature isn't enabled, explicitly ask mkfs.btrfs
>>     to disable no-holes (future versions of mkfs.btrfs might enable
>>     this feature by default).
>>
>>  common/rc           |  13 ++
>>  tests/btrfs/055     | 165 ++++++++++++++++++++++++++
>>  tests/btrfs/055.out | 333 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>>  tests/btrfs/group   |   1 +
>>  4 files changed, 512 insertions(+)
>>  create mode 100755 tests/btrfs/055
>>  create mode 100644 tests/btrfs/055.out
>>
>> diff --git a/common/rc b/common/rc
>> index f27ee53..0ef0ece 100644
>> --- a/common/rc
>> +++ b/common/rc
>> @@ -2177,6 +2177,19 @@ _require_btrfs_send_stream_version()
>>       fi
>>  }
>>
>> +_require_btrfs_fs_feature()
>> +{
>> +     if [ -z $1 ]; then
>> +             echo "Missing feature name argument for _require_btrfs_fs_feature"
>> +             exit 1
>> +     fi
>> +     feat=$1
>> +     $MKFS_BTRFS_PROG -O list-all 2>&1 | \
>> +             grep '^[ \t]*'"$feat"'\b' > /dev/null 2>&1
>> +     [ $? -eq 0 ] || \
>> +             _notrun "Feature $feat not supported in the available version of mkfs.btrfs"
>
> And what if kernel does not support this ?

Right. Due to the version number relationship between btrfs-progs and
kernel, it's unlikely to have an older kernel with a more recent
version of btrfs-progs (e.g. 3.10 kernel and 3.14 btrfs-progs).
Either way, I added it to v5 (following shortly).

>
>> +}
>> +
>>  init_rc()
>>  {
>>       if [ "$iam" == new ]
>> diff --git a/tests/btrfs/055 b/tests/btrfs/055
>> new file mode 100755
>> index 0000000..0e67c88
>> --- /dev/null
>> +++ b/tests/btrfs/055
>> @@ -0,0 +1,165 @@
>> +#! /bin/bash
>> +# FS QA Test No. btrfs/055
>> +#
>> +# Regression test for the btrfs ioctl clone operation when the source range
>> +# contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
>> +# don't need file extent items in the btree to represent them).
>> +#
>> +# This issue is fixed by the following linux kernel btrfs patch:
>> +#
>> +#    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled
>> +#
>> +#-----------------------------------------------------------------------
>> +# Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
>> +#
>> +# This program is free software; you can redistribute it and/or
>> +# modify it under the terms of the GNU General Public License as
>> +# published by the Free Software Foundation.
>> +#
>> +# This program is distributed in the hope that it would be useful,
>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> +# GNU General Public License for more details.
>> +#
>> +# You should have received a copy of the GNU General Public License
>> +# along with this program; if not, write the Free Software Foundation,
>> +# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
>> +#-----------------------------------------------------------------------
>> +#
>> +
>> +seq=`basename $0`
>> +seqres=$RESULT_DIR/$seq
>> +echo "QA output created by $seq"
>> +
>> +tmp=/tmp/$$
>> +status=1     # failure is the default!
>> +trap "_cleanup; exit \$status" 0 1 2 3 15
>> +
>> +_cleanup()
>> +{
>> +    rm -fr $tmp
>> +}
>> +
>> +# get standard environment, filters and checks
>> +. ./common/rc
>> +. ./common/filter
>> +
>> +# real QA test starts here
>> +_supported_fs btrfs
>> +_supported_os Linux
>> +_require_scratch
>> +_require_btrfs_cloner
>> +_require_btrfs_fs_feature "no-holes"
>> +_need_to_be_root
>> +
>> +rm -f $seqres.full
>> +
>> +test_btrfs_clone_with_holes()
>> +{
>> +     _scratch_mkfs "$1" >/dev/null 2>&1
>> +     _scratch_mount
>> +
>> +     # Create a file with 4 extents and 1 hole, all with a size of 8Kb each.
>> +     $XFS_IO_PROG -f -c "pwrite -S 0x01 -b 8192 0 8192" $SCRATCH_MNT/foo \
>> +             | _filter_xfs_io
>> +     sync
>> +     $XFS_IO_PROG -c "pwrite -S 0x02 -b 8192 8192 8192" $SCRATCH_MNT/foo \
>> +             | _filter_xfs_io
>> +     sync
>> +     # After the following write we get a hole in the range [16384, 24576[
>> +     $XFS_IO_PROG -c "pwrite -S 0x04 -b 8192 24576 8192" $SCRATCH_MNT/foo \
>> +             | _filter_xfs_io
>> +     sync
>> +     $XFS_IO_PROG -c "pwrite -S 0x05 -b 8192 32768 8192" $SCRATCH_MNT/foo \
>> +             | _filter_xfs_io
>> +     sync
>> +
>> +     # Clone destination file, 1 extent of 96kb.
>> +     $XFS_IO_PROG -f -c "pwrite -S 0xff -b 98304 0 98304" $SCRATCH_MNT/bar \
>> +             | _filter_xfs_io
>> +     sync
>
> Again you could merge all pwrite calls into one XFS_IO_PROG command
> and use -W to sync.

Yes, I am aware of that possibility.
I find it easier to follow/read as it is (this is highly relative, and
don't expect everyone to agree with this style).

>
>> +
>> +     # Clone 2nd extent, 8Kb hole and 3rd extent of foo into bar.
>> +     $CLONER_PROG -s 8192 -d 0 -l 24576 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
>> +
>> +     # Verify both extents and the hole were cloned.
>> +     od -t x1 $SCRATCH_MNT/bar
>
> At this point there are many "od" outputs, so it would be convenient
> to at least echo some information so if there is a problem in the
> output we can easily identify what caused it.
>
> For example
>
> echo "2. Cloning range starts at the middle of a hole"

Agreed, good idea.
Included in v5 (following shortly).

Thanks Lukas

>
> Thanks!
> -Lukas
>
>> +
>> +     # Cloning range starts at the middle of a hole.
>> +     $CLONER_PROG -s 20480 -d 32768 -l 12288 $SCRATCH_MNT/foo \
>> +             $SCRATCH_MNT/bar
>> +
>> +     # Verify that half of the hole and the following 8Kb extent were cloned.
>> +     od -t x1 $SCRATCH_MNT/bar
>> +
>> +     # Cloning range ends at the middle of a hole.
>> +     $CLONER_PROG -s 0 -d 65536 -l 20480 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
>> +
>> +     # Verify that 2 extents of 8kb and a 4kb hole were cloned.
>> +     od -t x1 $SCRATCH_MNT/bar
>> +
>> +     # Create a 24Kb hole at the end of the source file (foo).
>> +     $XFS_IO_PROG -c "truncate 65536" $SCRATCH_MNT/foo
>> +     sync
>> +
>> +     # Now clone a range that overlaps that hole at the end of the foo file.
>> +     # It should clone the last 4Kb of the extent at offset 32768 and the
>> +     # first 8kb of the 24kb hole at the end of foo.
>> +     $CLONER_PROG -s 36864 -d 86016 -l 12288 $SCRATCH_MNT/foo \
>> +             $SCRATCH_MNT/bar
>> +
>> +     # Verify that the second half of the 8Kb extent at offset 32768 of foo
>> +     # and the first 8Kb of the 24kb hole of foo were cloned into bar.
>> +     od -t x1 $SCRATCH_MNT/bar
>> +
>> +     # Clone the same range as before, but clone it into a different offset
>> +     # of the target (bar) such that it increases the size of the target
>> +     # by 8Kb.
>> +     $CLONER_PROG -s 36864 -d 94208 -l 12288 $SCRATCH_MNT/foo \
>> +             $SCRATCH_MNT/bar
>> +
>> +     # Verify that the second half of the 8Kb extent at offset 32768 of foo
>> +     # and the first 8Kb of the 24kb hole of foo were cloned into bar at
>> +     # bar's offset 94208 and that bar's size increased by 8Kb.
>> +     od -t x1 $SCRATCH_MNT/bar
>> +
>> +     # Create a new completely sparse file (no extents, it's a big hole).
>> +     $XFS_IO_PROG -f -c "truncate 100000" $SCRATCH_MNT/qwerty
>> +     sync
>> +
>> +     # Test cloning a range from the sparse file to the bar file without
>> +     # increasing bar's size.
>> +     $CLONER_PROG -s 4096 -d 0 -l 8192 $SCRATCH_MNT/qwerty $SCRATCH_MNT/bar
>> +
>> +     # First 8Kb of bar should now be zeroes.
>> +     od -t x1 $SCRATCH_MNT/bar
>> +
>> +     # Test cloning a range from the sparse file to the end of the bar file.
>> +     # The bar file currently has a size of 106496 bytes.
>> +     $CLONER_PROG -s 0 -d 106496 -l 32768 $SCRATCH_MNT/qwerty \
>> +             $SCRATCH_MNT/bar
>> +
>> +     # Verify bar's size increased to 106496 + 32768 bytes (136Kb), and its
>> +     # last 32768 bytes are all zeroes.
>> +     od -t x1 $SCRATCH_MNT/bar
>> +
>> +     # Verify that there are no consistency errors.
>> +     _check_scratch_fs
>> +}
>> +
>> +# Regardless of the NO_HOLES feature being enabled or not, the test results
>> +# should be exactly the same for both cases.
>> +
>> +echo "Testing without the NO_HOLES feature"
>> +# As of btrfs-progs 3.14.x, the no-holes feature isn't enabled by default.
>> +# But explicitly disable it at mkfs time as it might be enabled by default
>> +# in future versions.
>> +test_btrfs_clone_with_holes "-O ^no-holes"
>> +
>> +_scratch_unmount
>> +
>> +echo "Testing with the NO_HOLES feature enabled"
>> +test_btrfs_clone_with_holes "-O no-holes"
>> +
>> +status=0
>> +exit
>> diff --git a/tests/btrfs/055.out b/tests/btrfs/055.out
>> new file mode 100644
>> index 0000000..714ede8
>> --- /dev/null
>> +++ b/tests/btrfs/055.out
>> @@ -0,0 +1,333 @@
>> +QA output created by 055
>> +Testing without the NO_HOLES feature
>> +wrote 8192/8192 bytes at offset 0
>> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +wrote 8192/8192 bytes at offset 8192
>> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +wrote 8192/8192 bytes at offset 24576
>> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +wrote 8192/8192 bytes at offset 32768
>> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +wrote 98304/98304 bytes at offset 0
>> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0300000
>> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0300000
>> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
>> +*
>> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0300000
>> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
>> +*
>> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
>> +*
>> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0300000
>> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
>> +*
>> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
>> +*
>> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
>> +*
>> +0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0320000
>> +0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
>> +*
>> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
>> +*
>> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
>> +*
>> +0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0320000
>> +0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
>> +*
>> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
>> +*
>> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
>> +*
>> +0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0420000
>> +Testing with the NO_HOLES feature enabled
>> +wrote 8192/8192 bytes at offset 0
>> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +wrote 8192/8192 bytes at offset 8192
>> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +wrote 8192/8192 bytes at offset 24576
>> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +wrote 8192/8192 bytes at offset 32768
>> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +wrote 98304/98304 bytes at offset 0
>> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0300000
>> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0300000
>> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
>> +*
>> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0300000
>> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
>> +*
>> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
>> +*
>> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0300000
>> +0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
>> +*
>> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
>> +*
>> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
>> +*
>> +0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0320000
>> +0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
>> +*
>> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
>> +*
>> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
>> +*
>> +0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0320000
>> +0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
>> +*
>> +0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>> +*
>> +0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
>> +*
>> +0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
>> +*
>> +0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
>> +*
>> +0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
>> +*
>> +0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>> +*
>> +0420000
>> diff --git a/tests/btrfs/group b/tests/btrfs/group
>> index b668485..2c10c5b 100644
>> --- a/tests/btrfs/group
>> +++ b/tests/btrfs/group
>> @@ -57,3 +57,4 @@
>>  052 auto quick
>>  053 auto quick
>>  054 auto quick
>> +055 auto quick
>>



-- 
Filipe David Manana,

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

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

* [PATCH v5] xfstests: add test for btrfs cloning with file holes
  2014-05-31  1:17 [PATCH] xfstests: add test for btrfs cloning with file holes Filipe David Borba Manana
                   ` (2 preceding siblings ...)
  2014-06-01 13:06 ` [PATCH v4] " Filipe David Borba Manana
@ 2014-06-03 14:37 ` Filipe David Borba Manana
  2014-06-10  1:39   ` Dave Chinner
  2014-06-10 10:12 ` [PATCH v6] " Filipe David Borba Manana
  4 siblings, 1 reply; 10+ messages in thread
From: Filipe David Borba Manana @ 2014-06-03 14:37 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, lczerner, Filipe David Borba Manana

Regression test for the btrfs ioctl clone operation when the source range
contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
don't need file extent items in the btree to represent them).

This issue is fixed by the following linux kernel btrfs patch:

    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---

V2: Increased test coverage by testing the cases where a hole overlaps
    the start and end of the cloning range.

V3: Test the case where the cloning range includes an hole at the end
    of the source file and might increase the size of the target file.

V4: Added test for the case where the clone range covers only a hole at
    the beginning of the source file.
    Made the test be skipped if the available version of mkfs.btrfs
    doesn't support the no-holes feature. And when testing the case
    where the no-holes feature isn't enabled, explicitly ask mkfs.btrfs
    to disable no-holes (future versions of mkfs.btrfs might enable
    this feature by default).

V5: Detect if kernel supports NO_HOLES feature too. Added some messages
    (echoes) before each od call to make it easier to match output
    with each specific test.

 common/rc           |  25 ++++
 tests/btrfs/055     | 173 ++++++++++++++++++++++++++
 tests/btrfs/055.out | 347 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/group   |   1 +
 4 files changed, 546 insertions(+)
 create mode 100755 tests/btrfs/055
 create mode 100644 tests/btrfs/055.out

diff --git a/common/rc b/common/rc
index f27ee53..e2136d0 100644
--- a/common/rc
+++ b/common/rc
@@ -2177,6 +2177,31 @@ _require_btrfs_send_stream_version()
 	fi
 }
 
+_require_btrfs_mkfs_feature()
+{
+	if [ -z $1 ]; then
+		echo "Missing feature name argument for _require_btrfs_mkfs_feature"
+		exit 1
+	fi
+	feat=$1
+	$MKFS_BTRFS_PROG -O list-all 2>&1 | \
+		grep '^[ \t]*'"$feat"'\b' > /dev/null 2>&1
+	[ $? -eq 0 ] || \
+		_notrun "Feature $feat not supported in the available version of mkfs.btrfs"
+}
+
+_require_btrfs_fs_feature()
+{
+	if [ -z $1 ]; then
+		echo "Missing feature name argument for _require_btrfs_fs_feature"
+		exit 1
+	fi
+	feat=$1
+	modprobe btrfs > /dev/null 2>&1
+	[ -e /sys/fs/btrfs/features/$feat ] || \
+		_notrun "Feature $feat not supported by the available btrfs version"
+}
+
 init_rc()
 {
 	if [ "$iam" == new ]
diff --git a/tests/btrfs/055 b/tests/btrfs/055
new file mode 100755
index 0000000..be38d09
--- /dev/null
+++ b/tests/btrfs/055
@@ -0,0 +1,173 @@
+#! /bin/bash
+# FS QA Test No. btrfs/055
+#
+# Regression test for the btrfs ioctl clone operation when the source range
+# contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
+# don't need file extent items in the btree to represent them).
+#
+# This issue is fixed by the following linux kernel btrfs patch:
+#
+#    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    rm -fr $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_btrfs_cloner
+_require_btrfs_fs_feature "no_holes"
+_require_btrfs_mkfs_feature "no-holes"
+_need_to_be_root
+
+rm -f $seqres.full
+
+test_btrfs_clone_with_holes()
+{
+	_scratch_mkfs "$1" >/dev/null 2>&1
+	_scratch_mount
+
+	# Create a file with 4 extents and 1 hole, all with a size of 8Kb each.
+	$XFS_IO_PROG -f -c "pwrite -S 0x01 -b 8192 0 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+	$XFS_IO_PROG -c "pwrite -S 0x02 -b 8192 8192 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+	# After the following write we get an hole in the range [16384, 24576[
+	$XFS_IO_PROG -c "pwrite -S 0x04 -b 8192 24576 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+	$XFS_IO_PROG -c "pwrite -S 0x05 -b 8192 32768 8192" $SCRATCH_MNT/foo \
+		| _filter_xfs_io
+	sync
+
+	# Clone destination file, 1 extent of 96kb.
+	$XFS_IO_PROG -f -c "pwrite -S 0xff -b 98304 0 98304" $SCRATCH_MNT/bar \
+		| _filter_xfs_io
+	sync
+
+	# Clone 2nd extent, 8Kb hole and 3rd extent of foo into bar.
+	$CLONER_PROG -s 8192 -d 0 -l 24576 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
+
+	# Verify both extents and the hole were cloned.
+	echo "1) Check both extents and the hole were cloned"
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Cloning range starts at the middle of an hole.
+	$CLONER_PROG -s 20480 -d 32768 -l 12288 $SCRATCH_MNT/foo \
+		$SCRATCH_MNT/bar
+
+	# Verify that half of the hole and the following 8Kb extent were cloned.
+	echo "2) Check half hole and one 8Kb extent were cloned"
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Cloning range ends at the middle of an hole.
+	$CLONER_PROG -s 0 -d 65536 -l 20480 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
+
+	# Verify that 2 extents of 8kb and a 4kb hole were cloned.
+	echo "3) Check that 2 extents of 8kb eacg and a 4kb hole were cloned"
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Create a 24Kb hole at the end of the source file (foo).
+	$XFS_IO_PROG -c "truncate 65536" $SCRATCH_MNT/foo
+	sync
+
+	# Now clone a range that overlaps that hole at the end of the foo file.
+	# It should clone the last 4Kb of the extent at offset 32768 and the
+	# first 8kb of the 24kb hole at the end of foo.
+	$CLONER_PROG -s 36864 -d 86016 -l 12288 $SCRATCH_MNT/foo \
+		$SCRATCH_MNT/bar
+
+	# Verify that the second half of the 8Kb extent at offset 32768 of foo
+	# and the first 8Kb of the 24kb hole of foo were cloned into bar.
+	echo "4) Check that 4kb of 1 extent and 8Kb of an hole were cloned"
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Clone the same range as before, but clone it into a different offset
+	# of the target (bar) such that it increases the size of the target
+	# by 8Kb.
+	$CLONER_PROG -s 36864 -d 94208 -l 12288 $SCRATCH_MNT/foo \
+		$SCRATCH_MNT/bar
+
+	# Verify that the second half of the 8Kb extent at offset 32768 of foo
+	# and the first 8Kb of the 24kb hole of foo were cloned into bar at
+	# bar's offset 94208 and that bar's size increased by 8Kb.
+	echo "5) Check that 4kb of 1 extent and 8Kb of an hole were cloned and file size increased"
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Create a new completely sparse file (no extents, it's a big hole).
+	$XFS_IO_PROG -f -c "truncate 100000" $SCRATCH_MNT/qwerty
+	sync
+
+	# Test cloning a range from the sparse file to the bar file without
+	# increasing bar's size.
+	$CLONER_PROG -s 4096 -d 0 -l 8192 $SCRATCH_MNT/qwerty $SCRATCH_MNT/bar
+
+	# First 8Kb of bar should now be zeroes.
+	echo "6) Check that 8kb of the hole were cloned"
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Test cloning a range from the sparse file to the end of the bar file.
+	# The bar file currently has a size of 106496 bytes.
+	$CLONER_PROG -s 0 -d 106496 -l 32768 $SCRATCH_MNT/qwerty \
+		$SCRATCH_MNT/bar
+
+	# Verify bar's size increased to 106496 + 32768 bytes (136Kb), and its
+	# last 32768 bytes are all zeroes.
+	echo "7) Check that 32kb of the hole were cloned and the file size increased"
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Verify that there are no consistency errors.
+	_check_scratch_fs
+}
+
+# Regardless of the NO_HOLES feature being enabled or not, the test results
+# should be exactly the same for both cases.
+
+echo "Testing without the NO_HOLES feature"
+# As of btrfs-progs 3.14.x, the no-holes feature isn't enabled by default.
+# But explicitly disable it at mkfs time as it might be enabled by default
+# in future versions.
+test_btrfs_clone_with_holes "-O ^no-holes"
+
+_scratch_unmount
+
+echo "Testing with the NO_HOLES feature enabled"
+test_btrfs_clone_with_holes "-O no-holes"
+
+status=0
+exit
diff --git a/tests/btrfs/055.out b/tests/btrfs/055.out
new file mode 100644
index 0000000..d8d4893
--- /dev/null
+++ b/tests/btrfs/055.out
@@ -0,0 +1,347 @@
+QA output created by 055
+Testing without the NO_HOLES feature
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 8192
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 24576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 32768
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 98304/98304 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+1) Check both extents and the hole were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+2) Check half hole and one 8Kb extent were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+3) Check that 2 extents of 8kb eacg and a 4kb hole were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+4) Check that 4kb of 1 extent and 8Kb of an hole were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0300000
+5) Check that 4kb of 1 extent and 8Kb of an hole were cloned and file size increased
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0320000
+6) Check that 8kb of the hole were cloned
+0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0320000
+7) Check that 32kb of the hole were cloned and the file size increased
+0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0420000
+Testing with the NO_HOLES feature enabled
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 8192
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 24576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 32768
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 98304/98304 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+1) Check both extents and the hole were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+2) Check half hole and one 8Kb extent were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+3) Check that 2 extents of 8kb eacg and a 4kb hole were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+4) Check that 4kb of 1 extent and 8Kb of an hole were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0300000
+5) Check that 4kb of 1 extent and 8Kb of an hole were cloned and file size increased
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0320000
+6) Check that 8kb of the hole were cloned
+0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0320000
+7) Check that 32kb of the hole were cloned and the file size increased
+0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0420000
diff --git a/tests/btrfs/group b/tests/btrfs/group
index b668485..2c10c5b 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -57,3 +57,4 @@
 052 auto quick
 053 auto quick
 054 auto quick
+055 auto quick
-- 
1.9.1


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

* Re: [PATCH v5] xfstests: add test for btrfs cloning with file holes
  2014-06-03 14:37 ` [PATCH v5] " Filipe David Borba Manana
@ 2014-06-10  1:39   ` Dave Chinner
  0 siblings, 0 replies; 10+ messages in thread
From: Dave Chinner @ 2014-06-10  1:39 UTC (permalink / raw)
  To: Filipe David Borba Manana; +Cc: fstests, linux-btrfs, lczerner

On Tue, Jun 03, 2014 at 03:37:41PM +0100, Filipe David Borba Manana wrote:
> Regression test for the btrfs ioctl clone operation when the source range
> contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
> don't need file extent items in the btree to represent them).
> 
> This issue is fixed by the following linux kernel btrfs patch:
> 
>     Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled
> 
> Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
> ---
> 
> V2: Increased test coverage by testing the cases where a hole overlaps
>     the start and end of the cloning range.
> 
> V3: Test the case where the cloning range includes an hole at the end
>     of the source file and might increase the size of the target file.
> 
> V4: Added test for the case where the clone range covers only a hole at
>     the beginning of the source file.
>     Made the test be skipped if the available version of mkfs.btrfs
>     doesn't support the no-holes feature. And when testing the case
>     where the no-holes feature isn't enabled, explicitly ask mkfs.btrfs
>     to disable no-holes (future versions of mkfs.btrfs might enable
>     this feature by default).
> 
> V5: Detect if kernel supports NO_HOLES feature too. Added some messages
>     (echoes) before each od call to make it easier to match output
>     with each specific test.
> 
>  common/rc           |  25 ++++
>  tests/btrfs/055     | 173 ++++++++++++++++++++++++++
>  tests/btrfs/055.out | 347 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/group   |   1 +
>  4 files changed, 546 insertions(+)
>  create mode 100755 tests/btrfs/055
>  create mode 100644 tests/btrfs/055.out
> 
> diff --git a/common/rc b/common/rc
> index f27ee53..e2136d0 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2177,6 +2177,31 @@ _require_btrfs_send_stream_version()
>  	fi
>  }
>  
> +_require_btrfs_mkfs_feature()
> +{
> +	if [ -z $1 ]; then
> +		echo "Missing feature name argument for _require_btrfs_mkfs_feature"
> +		exit 1
> +	fi
> +	feat=$1
> +	$MKFS_BTRFS_PROG -O list-all 2>&1 | \
> +		grep '^[ \t]*'"$feat"'\b' > /dev/null 2>&1
> +	[ $? -eq 0 ] || \
> +		_notrun "Feature $feat not supported in the available version of mkfs.btrfs"
> +}
> +
> +_require_btrfs_fs_feature()
> +{
> +	if [ -z $1 ]; then
> +		echo "Missing feature name argument for _require_btrfs_fs_feature"
> +		exit 1
> +	fi
> +	feat=$1
> +	modprobe btrfs > /dev/null 2>&1
> +	[ -e /sys/fs/btrfs/features/$feat ] || \
> +		_notrun "Feature $feat not supported by the available btrfs version"
> +}
> +
>  init_rc()
>  {
>  	if [ "$iam" == new ]
> diff --git a/tests/btrfs/055 b/tests/btrfs/055
> new file mode 100755
> index 0000000..be38d09
> --- /dev/null
> +++ b/tests/btrfs/055
> @@ -0,0 +1,173 @@
> +#! /bin/bash
> +# FS QA Test No. btrfs/055
> +#
> +# Regression test for the btrfs ioctl clone operation when the source range
> +# contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
> +# don't need file extent items in the btree to represent them).
> +#
> +# This issue is fixed by the following linux kernel btrfs patch:
> +#
> +#    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it would be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#-----------------------------------------------------------------------
> +#
> +
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +tmp=/tmp/$$
> +status=1	# failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +    rm -fr $tmp
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_fs btrfs
> +_supported_os Linux
> +_require_scratch
> +_require_btrfs_cloner
> +_require_btrfs_fs_feature "no_holes"
> +_require_btrfs_mkfs_feature "no-holes"

Nice kernel/userspace consistency in naming there ;)

> +_need_to_be_root
> +
> +rm -f $seqres.full
> +
> +test_btrfs_clone_with_holes()
> +{
> +	_scratch_mkfs "$1" >/dev/null 2>&1
> +	_scratch_mount
> +
> +	# Create a file with 4 extents and 1 hole, all with a size of 8Kb each.
> +	$XFS_IO_PROG -f -c "pwrite -S 0x01 -b 8192 0 8192" $SCRATCH_MNT/foo \
> +		| _filter_xfs_io
> +	sync
> +	$XFS_IO_PROG -c "pwrite -S 0x02 -b 8192 8192 8192" $SCRATCH_MNT/foo \
> +		| _filter_xfs_io
> +	sync
> +	# After the following write we get an hole in the range [16384, 24576[
> +	$XFS_IO_PROG -c "pwrite -S 0x04 -b 8192 24576 8192" $SCRATCH_MNT/foo \
> +		| _filter_xfs_io
> +	sync
> +	$XFS_IO_PROG -c "pwrite -S 0x05 -b 8192 32768 8192" $SCRATCH_MNT/foo \
> +		| _filter_xfs_io
> +	sync
> +
> +	# Clone destination file, 1 extent of 96kb.
> +	$XFS_IO_PROG -f -c "pwrite -S 0xff -b 98304 0 98304" $SCRATCH_MNT/bar \
> +		| _filter_xfs_io
> +	sync

As Lukas mentioned, this is way too verbose and hard to read.
This:

	# Create a file with 4 extents and 1 hole, all with a size of 8Kb each.
	$XFS_IO_PROG -fs \
		-c "pwrite -S 0x01 -b 8192 0 8192" \
		-c "pwrite -S 0x02 -b 8192 8192 8192" \
		-c "pwrite -S 0x04 -b 8192 24576 8192" \
		-c "pwrite -S 0x05 -b 8192 32768 8192" \
		$SCRATCH_MNT/foo | _filter_xfs_io

	# Clone destination file, 1 extent of 96kb.
	$XFS_IO_PROG -fs -c "pwrite -S 0xff -b 98304 0 98304" \
		$SCRATCH_MNT/bar | _filter_xfs_io

is much more compact and far easier to read. It's also the same
style as many of the other tests use for compound operations like
this.

Other than that the test look sgood.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

* [PATCH v6] xfstests: add test for btrfs cloning with file holes
  2014-05-31  1:17 [PATCH] xfstests: add test for btrfs cloning with file holes Filipe David Borba Manana
                   ` (3 preceding siblings ...)
  2014-06-03 14:37 ` [PATCH v5] " Filipe David Borba Manana
@ 2014-06-10 10:12 ` Filipe David Borba Manana
  4 siblings, 0 replies; 10+ messages in thread
From: Filipe David Borba Manana @ 2014-06-10 10:12 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe David Borba Manana

Regression test for the btrfs ioctl clone operation when the source range
contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
don't need file extent items in the btree to represent them).

This issue is fixed by the following linux kernel btrfs patch:

    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
---

V2: Increased test coverage by testing the cases where a hole overlaps
    the start and end of the cloning range.

V3: Test the case where the cloning range includes an hole at the end
    of the source file and might increase the size of the target file.

V4: Added test for the case where the clone range covers only a hole at
    the beginning of the source file.
    Made the test be skipped if the available version of mkfs.btrfs
    doesn't support the no-holes feature. And when testing the case
    where the no-holes feature isn't enabled, explicitly ask mkfs.btrfs
    to disable no-holes (future versions of mkfs.btrfs might enable
    this feature by default).

V5: Detect if kernel supports NO_HOLES feature too. Added some messages
    (echoes) before each od call to make it easier to match output
    with each specific test.

V6: Pass -s to xfs_io when creating the test files.

 common/rc           |  25 ++++
 tests/btrfs/055     | 165 +++++++++++++++++++++++++
 tests/btrfs/055.out | 347 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/group   |   1 +
 4 files changed, 538 insertions(+)
 create mode 100755 tests/btrfs/055
 create mode 100644 tests/btrfs/055.out

diff --git a/common/rc b/common/rc
index f27ee53..e2136d0 100644
--- a/common/rc
+++ b/common/rc
@@ -2177,6 +2177,31 @@ _require_btrfs_send_stream_version()
 	fi
 }
 
+_require_btrfs_mkfs_feature()
+{
+	if [ -z $1 ]; then
+		echo "Missing feature name argument for _require_btrfs_mkfs_feature"
+		exit 1
+	fi
+	feat=$1
+	$MKFS_BTRFS_PROG -O list-all 2>&1 | \
+		grep '^[ \t]*'"$feat"'\b' > /dev/null 2>&1
+	[ $? -eq 0 ] || \
+		_notrun "Feature $feat not supported in the available version of mkfs.btrfs"
+}
+
+_require_btrfs_fs_feature()
+{
+	if [ -z $1 ]; then
+		echo "Missing feature name argument for _require_btrfs_fs_feature"
+		exit 1
+	fi
+	feat=$1
+	modprobe btrfs > /dev/null 2>&1
+	[ -e /sys/fs/btrfs/features/$feat ] || \
+		_notrun "Feature $feat not supported by the available btrfs version"
+}
+
 init_rc()
 {
 	if [ "$iam" == new ]
diff --git a/tests/btrfs/055 b/tests/btrfs/055
new file mode 100755
index 0000000..10c6040
--- /dev/null
+++ b/tests/btrfs/055
@@ -0,0 +1,165 @@
+#! /bin/bash
+# FS QA Test No. btrfs/055
+#
+# Regression test for the btrfs ioctl clone operation when the source range
+# contains hole(s) and the FS has the NO_HOLES feature enabled (file holes
+# don't need file extent items in the btree to represent them).
+#
+# This issue is fixed by the following linux kernel btrfs patch:
+#
+#    Btrfs: fix clone to deal with holes when NO_HOLES feature is enabled
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    rm -fr $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_btrfs_cloner
+_require_btrfs_fs_feature "no_holes"
+_require_btrfs_mkfs_feature "no-holes"
+_need_to_be_root
+
+rm -f $seqres.full
+
+test_btrfs_clone_with_holes()
+{
+	_scratch_mkfs "$1" >/dev/null 2>&1
+	_scratch_mount
+
+	# Create a file with 4 extents and 1 hole, all with a size of 8Kb each.
+	# The hole is in the range [16384, 24576[.
+	$XFS_IO_PROG -s -f -c "pwrite -S 0x01 -b 8192 0 8192" \
+			-c "pwrite -S 0x02 -b 8192 8192 8192" \
+			-c "pwrite -S 0x04 -b 8192 24576 8192" \
+			-c "pwrite -S 0x05 -b 8192 32768 8192" \
+		$SCRATCH_MNT/foo | _filter_xfs_io
+
+	# Clone destination file, 1 extent of 96kb.
+	$XFS_IO_PROG -s -f -c "pwrite -S 0xff -b 98304 0 98304" \
+		$SCRATCH_MNT/bar | _filter_xfs_io
+
+	# Clone 2nd extent, 8Kb hole and 3rd extent of foo into bar.
+	$CLONER_PROG -s 8192 -d 0 -l 24576 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
+
+	# Verify both extents and the hole were cloned.
+	echo "1) Check both extents and the hole were cloned"
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Cloning range starts at the middle of an hole.
+	$CLONER_PROG -s 20480 -d 32768 -l 12288 $SCRATCH_MNT/foo \
+		$SCRATCH_MNT/bar
+
+	# Verify that half of the hole and the following 8Kb extent were cloned.
+	echo "2) Check half hole and one 8Kb extent were cloned"
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Cloning range ends at the middle of an hole.
+	$CLONER_PROG -s 0 -d 65536 -l 20480 $SCRATCH_MNT/foo $SCRATCH_MNT/bar
+
+	# Verify that 2 extents of 8kb and a 4kb hole were cloned.
+	echo "3) Check that 2 extents of 8kb eacg and a 4kb hole were cloned"
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Create a 24Kb hole at the end of the source file (foo).
+	$XFS_IO_PROG -c "truncate 65536" $SCRATCH_MNT/foo
+	sync
+
+	# Now clone a range that overlaps that hole at the end of the foo file.
+	# It should clone the last 4Kb of the extent at offset 32768 and the
+	# first 8kb of the 24kb hole at the end of foo.
+	$CLONER_PROG -s 36864 -d 86016 -l 12288 $SCRATCH_MNT/foo \
+		$SCRATCH_MNT/bar
+
+	# Verify that the second half of the 8Kb extent at offset 32768 of foo
+	# and the first 8Kb of the 24kb hole of foo were cloned into bar.
+	echo "4) Check that 4kb of 1 extent and 8Kb of an hole were cloned"
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Clone the same range as before, but clone it into a different offset
+	# of the target (bar) such that it increases the size of the target
+	# by 8Kb.
+	$CLONER_PROG -s 36864 -d 94208 -l 12288 $SCRATCH_MNT/foo \
+		$SCRATCH_MNT/bar
+
+	# Verify that the second half of the 8Kb extent at offset 32768 of foo
+	# and the first 8Kb of the 24kb hole of foo were cloned into bar at
+	# bar's offset 94208 and that bar's size increased by 8Kb.
+	echo "5) Check that 4kb of 1 extent and 8Kb of an hole were cloned and file size increased"
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Create a new completely sparse file (no extents, it's a big hole).
+	$XFS_IO_PROG -f -c "truncate 100000" $SCRATCH_MNT/qwerty
+	sync
+
+	# Test cloning a range from the sparse file to the bar file without
+	# increasing bar's size.
+	$CLONER_PROG -s 4096 -d 0 -l 8192 $SCRATCH_MNT/qwerty $SCRATCH_MNT/bar
+
+	# First 8Kb of bar should now be zeroes.
+	echo "6) Check that 8kb of the hole were cloned"
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Test cloning a range from the sparse file to the end of the bar file.
+	# The bar file currently has a size of 106496 bytes.
+	$CLONER_PROG -s 0 -d 106496 -l 32768 $SCRATCH_MNT/qwerty \
+		$SCRATCH_MNT/bar
+
+	# Verify bar's size increased to 106496 + 32768 bytes (136Kb), and its
+	# last 32768 bytes are all zeroes.
+	echo "7) Check that 32kb of the hole were cloned and the file size increased"
+	od -t x1 $SCRATCH_MNT/bar
+
+	# Verify that there are no consistency errors.
+	_check_scratch_fs
+}
+
+# Regardless of the NO_HOLES feature being enabled or not, the test results
+# should be exactly the same for both cases.
+
+echo "Testing without the NO_HOLES feature"
+# As of btrfs-progs 3.14.x, the no-holes feature isn't enabled by default.
+# But explicitly disable it at mkfs time as it might be enabled by default
+# in future versions.
+test_btrfs_clone_with_holes "-O ^no-holes"
+
+_scratch_unmount
+
+echo "Testing with the NO_HOLES feature enabled"
+test_btrfs_clone_with_holes "-O no-holes"
+
+status=0
+exit
diff --git a/tests/btrfs/055.out b/tests/btrfs/055.out
new file mode 100644
index 0000000..d8d4893
--- /dev/null
+++ b/tests/btrfs/055.out
@@ -0,0 +1,347 @@
+QA output created by 055
+Testing without the NO_HOLES feature
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 8192
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 24576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 32768
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 98304/98304 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+1) Check both extents and the hole were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+2) Check half hole and one 8Kb extent were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+3) Check that 2 extents of 8kb eacg and a 4kb hole were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+4) Check that 4kb of 1 extent and 8Kb of an hole were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0300000
+5) Check that 4kb of 1 extent and 8Kb of an hole were cloned and file size increased
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0320000
+6) Check that 8kb of the hole were cloned
+0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0320000
+7) Check that 32kb of the hole were cloned and the file size increased
+0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0420000
+Testing with the NO_HOLES feature enabled
+wrote 8192/8192 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 8192
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 24576
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 8192/8192 bytes at offset 32768
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 98304/98304 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+1) Check both extents and the hole were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+2) Check half hole and one 8Kb extent were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+3) Check that 2 extents of 8kb eacg and a 4kb hole were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0300000
+4) Check that 4kb of 1 extent and 8Kb of an hole were cloned
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0300000
+5) Check that 4kb of 1 extent and 8Kb of an hole were cloned and file size increased
+0000000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0020000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0320000
+6) Check that 8kb of the hole were cloned
+0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0320000
+7) Check that 32kb of the hole were cloned and the file size increased
+0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0040000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0060000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0100000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0110000 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04 04
+*
+0130000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+*
+0200000 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01
+*
+0220000 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
+*
+0240000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0250000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0260000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0270000 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05
+*
+0300000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+*
+0420000
diff --git a/tests/btrfs/group b/tests/btrfs/group
index b668485..2c10c5b 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -57,3 +57,4 @@
 052 auto quick
 053 auto quick
 054 auto quick
+055 auto quick
-- 
1.9.1


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

end of thread, other threads:[~2014-06-10  9:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-31  1:17 [PATCH] xfstests: add test for btrfs cloning with file holes Filipe David Borba Manana
2014-05-31 14:12 ` [PATCH v2] " Filipe David Borba Manana
2014-06-03 12:32   ` Lukáš Czerner
2014-05-31 16:21 ` [PATCH v3] " Filipe David Borba Manana
2014-06-01 13:06 ` [PATCH v4] " Filipe David Borba Manana
2014-06-03 12:46   ` Lukáš Czerner
2014-06-03 13:36     ` Filipe David Manana
2014-06-03 14:37 ` [PATCH v5] " Filipe David Borba Manana
2014-06-10  1:39   ` Dave Chinner
2014-06-10 10:12 ` [PATCH v6] " Filipe David Borba Manana

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).