xfs/{263,106}: erase max warnings printout
[xfstests-dev.git] / tests / btrfs / 203
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. 203
6 #
7 # Test that an incremental send operation works correctly when a file has shared
8 # extents with itself in the send snapshot, with a hole between them, and the
9 # file size has increased in the send snapshot.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22         rm -fr $send_files_dir
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/reflink
29
30 # real QA test starts here
31 _supported_fs btrfs
32 _supported_os Linux
33 _require_test
34 _require_scratch_reflink
35
36 send_files_dir=$TEST_DIR/btrfs-test-$seq
37
38 rm -f $seqres.full
39 rm -fr $send_files_dir
40 mkdir $send_files_dir
41
42 _scratch_mkfs >>$seqres.full 2>&1
43 _scratch_mount
44
45 # Create our test file with a size of 64K in the parent snapshot.
46 # After the parent snapshot is created, we will increase its size and then clone
47 # one of its extents into a different offset and leave a hole between the shared
48 # extents. The shared extents will be located at offsets greater then size of the
49 # file in the parent snapshot.
50 $XFS_IO_PROG -f -c "pwrite -S 0xf1 0 64K" $SCRATCH_MNT/foobar | _filter_xfs_io
51
52 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/base 2>&1 \
53         | _filter_scratch
54
55 $BTRFS_UTIL_PROG send -f $send_files_dir/1.snap $SCRATCH_MNT/base 2>&1 \
56         | _filter_scratch
57
58 # Create a 320K extent at file offset 512K, with chunks of 64K having different
59 # content (to check cloning operations from send refer to the correct ranges).
60 # After that clone a range that includes a hole and a part of the extent created
61 # before - the clone range starts at an offset (448K) lower then the extent's
62 # offset (512K). We want to see the existence of the hole doesn't confuse the
63 # kernel's send code to send an invalid clone operation (with a source range
64 # going beyond the file's current size). The hole that confused send to issue
65 # an invalid clone operation spans the file range from offset 384K to 512K.
66 #
67 # Use offsets and ranges that are aligned to 64K, so that the test can run on
68 # machines with any page size (and therefore block size).
69 #
70 $XFS_IO_PROG -c "pwrite -S 0xab 512K 64K" \
71              -c "pwrite -S 0xcd 576K 64K" \
72              -c "pwrite -S 0xef 640K 64K" \
73              -c "pwrite -S 0x64 704K 64K" \
74              -c "pwrite -S 0x73 768K 64K" \
75              -c "reflink $SCRATCH_MNT/foobar 448K 192K 192K" \
76              $SCRATCH_MNT/foobar | _filter_xfs_io
77
78 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/incr 2>&1 \
79         | _filter_scratch
80
81 $BTRFS_UTIL_PROG send -p $SCRATCH_MNT/base -f $send_files_dir/2.snap \
82                  $SCRATCH_MNT/incr 2>&1 | _filter_scratch
83
84 echo "File foobar digest in the original filesystem:"
85 _md5_checksum $SCRATCH_MNT/incr/foobar
86
87 # Now recreate the filesystem by receiving both send streams and verify we get
88 # the same file contents that the original filesystem had.
89 _scratch_unmount
90 _scratch_mkfs >>$seqres.full 2>&1
91 _scratch_mount
92
93 $BTRFS_UTIL_PROG receive -f $send_files_dir/1.snap $SCRATCH_MNT
94 $BTRFS_UTIL_PROG receive -f $send_files_dir/2.snap $SCRATCH_MNT
95
96 echo "File foobar digest in the new filesystem:"
97 _md5_checksum $SCRATCH_MNT/incr/foobar
98
99 status=0
100 exit