fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: add test for incremental send for file with shared extents
@ 2020-01-24 11:52 fdmanana
  2020-01-24 13:55 ` Josef Bacik
  0 siblings, 1 reply; 2+ messages in thread
From: fdmanana @ 2020-01-24 11:52 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

Test that an incremental send operation works correctly when a file has
shared extents with itself in the send snapshot, with a hole between them,
and the file size has increased in the send snapshot.

This currently fails in 5.5-rc kernels (regression) but is fixed by a
patch that has the following subject:

  Btrfs: send, fix emission of invalid clone operations within the same file

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 tests/btrfs/203     | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/203.out |  25 +++++++++++++
 tests/btrfs/group   |   1 +
 3 files changed, 126 insertions(+)
 create mode 100755 tests/btrfs/203
 create mode 100644 tests/btrfs/203.out

diff --git a/tests/btrfs/203 b/tests/btrfs/203
new file mode 100755
index 00000000..2ba5463c
--- /dev/null
+++ b/tests/btrfs/203
@@ -0,0 +1,100 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
+#
+# FS QA Test No. 203
+#
+# Test that an incremental send operation works correctly when a file has shared
+# extents with itself in the send snapshot, with a hole between them, and the
+# file size has increased in the send snapshot.
+#
+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()
+{
+	cd /
+	rm -f $tmp.*
+	rm -fr $send_files_dir
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_test
+_require_scratch_reflink
+
+send_files_dir=$TEST_DIR/btrfs-test-$seq
+
+rm -f $seqres.full
+rm -fr $send_files_dir
+mkdir $send_files_dir
+
+_scratch_mkfs >>$seqres.full 2>&1
+_scratch_mount
+
+# Create our test file with a size of 64K in the parent snapshot.
+# After the parent snapshot is created, we will increase its size and then clone
+# one of its extents into a different offset and leave a hole between the shared
+# extents. The shared extents will be located at offsets greater then size of the
+# file in the parent snapshot.
+$XFS_IO_PROG -f -c "pwrite -S 0xf1 0 64K" $SCRATCH_MNT/foobar | _filter_xfs_io
+
+$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/base 2>&1 \
+	| _filter_scratch
+
+$BTRFS_UTIL_PROG send -f $send_files_dir/1.snap $SCRATCH_MNT/base 2>&1 \
+	| _filter_scratch
+
+# Create a 320K extent at file offset 512K, with chunks of 64K having different
+# content (to check cloning operations from send refer to the correct ranges).
+# After that clone a range that includes a hole and a part of the extent created
+# before - the clone range starts at an offset (448K) lower then the extent's
+# offset (512K). We want to see the existence of the hole doesn't confuse the
+# kernel's send code to send an invalid clone operation (with a source range
+# going beyond the file's current size). The hole that confused send to issue
+# an invalid clone operation spans the file range from offset 384K to 512K.
+#
+# Use offsets and ranges that are aligned to 64K, so that the test can run on
+# machines with any page size (and therefore block size).
+#
+$XFS_IO_PROG -c "pwrite -S 0xab 512K 64K" \
+	     -c "pwrite -S 0xcd 576K 64K" \
+	     -c "pwrite -S 0xef 640K 64K" \
+	     -c "pwrite -S 0x64 704K 64K" \
+	     -c "pwrite -S 0x73 768K 64K" \
+	     -c "reflink $SCRATCH_MNT/foobar 448K 192K 192K" \
+	     $SCRATCH_MNT/foobar | _filter_xfs_io
+
+$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/incr 2>&1 \
+	| _filter_scratch
+
+$BTRFS_UTIL_PROG send -p $SCRATCH_MNT/base -f $send_files_dir/2.snap \
+		 $SCRATCH_MNT/incr 2>&1 | _filter_scratch
+
+echo "File foobar digest in the original filesystem:"
+_md5_checksum $SCRATCH_MNT/incr/foobar
+
+# Now recreate the filesystem by receiving both send streams and verify we get
+# the same file contents that the original filesystem had.
+_scratch_unmount
+_scratch_mkfs >>$seqres.full 2>&1
+_scratch_mount
+
+$BTRFS_UTIL_PROG receive -f $send_files_dir/1.snap $SCRATCH_MNT
+$BTRFS_UTIL_PROG receive -f $send_files_dir/2.snap $SCRATCH_MNT
+
+echo "File foobar digest in the new filesystem:"
+_md5_checksum $SCRATCH_MNT/incr/foobar
+
+status=0
+exit
diff --git a/tests/btrfs/203.out b/tests/btrfs/203.out
new file mode 100644
index 00000000..58739a98
--- /dev/null
+++ b/tests/btrfs/203.out
@@ -0,0 +1,25 @@
+QA output created by 203
+wrote 65536/65536 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Create a readonly snapshot of 'SCRATCH_MNT' in 'SCRATCH_MNT/base'
+At subvol SCRATCH_MNT/base
+wrote 65536/65536 bytes at offset 524288
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 65536/65536 bytes at offset 589824
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 65536/65536 bytes at offset 655360
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 65536/65536 bytes at offset 720896
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 65536/65536 bytes at offset 786432
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+linked 196608/196608 bytes at offset 196608
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Create a readonly snapshot of 'SCRATCH_MNT' in 'SCRATCH_MNT/incr'
+At subvol SCRATCH_MNT/incr
+File foobar digest in the original filesystem:
+2b76b23b62fdbbbcae1ee37eec84fd7d
+At subvol base
+At snapshot incr
+File foobar digest in the new filesystem:
+2b76b23b62fdbbbcae1ee37eec84fd7d
diff --git a/tests/btrfs/group b/tests/btrfs/group
index d21bf438..8533c5e1 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -205,3 +205,4 @@
 200 auto quick send clone
 201 auto quick punch log
 202 auto quick subvol snapshot
+203 auto quick send clone
-- 
2.11.0


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

end of thread, other threads:[~2020-01-24 13:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-24 11:52 [PATCH] btrfs: add test for incremental send for file with shared extents fdmanana
2020-01-24 13:55 ` Josef Bacik

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