2 # FS QA Test No. btrfs/038
4 # Test for a btrfs incremental send issue where we end up sending a
5 # wrong section of data from a file extent if the corresponding file
6 # extent is compressed and the respective file extent item has a non
9 # Fixed by the following linux kernel btrfs patch:
11 # Btrfs: use right clone root offset for compressed extents
13 #-----------------------------------------------------------------------
14 # Copyright (c) 2014 Filipe Manana. All Rights Reserved.
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License as
18 # published by the Free Software Foundation.
20 # This program is distributed in the hope that it would be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write the Free Software Foundation,
27 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 #-----------------------------------------------------------------------
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
36 status=1 # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
44 # get standard environment, filters and checks
48 # real QA test starts here
56 _scratch_mkfs >/dev/null 2>&1
57 _scratch_mount "-o compress-force=lzo"
59 $XFS_IO_PROG -f -c "truncate 118811" $SCRATCH_MNT/foo
60 $XFS_IO_PROG -c "pwrite -S 0x0d -b 39987 92267 39987" \
61 $SCRATCH_MNT/foo | _filter_xfs_io
63 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT \
66 $XFS_IO_PROG -c "pwrite -S 0x3e -b 80000 200000 80000" \
67 $SCRATCH_MNT/foo | _filter_xfs_io
69 # Sync to avoid btrfs merging file extent items, which would make the test
70 # succeed when it should fail.
71 _run_btrfs_util_prog filesystem sync $SCRATCH_MNT
73 $XFS_IO_PROG -c "pwrite -S 0xdc -b 10000 250000 10000" \
74 $SCRATCH_MNT/foo | _filter_xfs_io
75 $XFS_IO_PROG -c "pwrite -S 0xff -b 10000 300000 10000" \
76 $SCRATCH_MNT/foo | _filter_xfs_io
78 # will be used for incremental send to be able to issue clone operations
79 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT \
80 $SCRATCH_MNT/clones_snap
82 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT \
85 run_check $FSSUM_PROG -A -f -w $tmp/1.fssum $SCRATCH_MNT/mysnap1
86 run_check $FSSUM_PROG -A -f -w $tmp/2.fssum -x $SCRATCH_MNT/mysnap2/mysnap1 \
87 -x $SCRATCH_MNT/mysnap2/clones_snap $SCRATCH_MNT/mysnap2
88 run_check $FSSUM_PROG -A -f -w $tmp/clones.fssum $SCRATCH_MNT/clones_snap \
89 -x $SCRATCH_MNT/clones_snap/mysnap1 -x $SCRATCH_MNT/clones_snap/mysnap2
91 _run_btrfs_util_prog send -f $tmp/1.snap $SCRATCH_MNT/mysnap1
92 _run_btrfs_util_prog send -f $tmp/clones.snap $SCRATCH_MNT/clones_snap
93 _run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 \
94 -c $SCRATCH_MNT/clones_snap -f $tmp/2.snap $SCRATCH_MNT/mysnap2
97 _check_btrfs_filesystem $SCRATCH_DEV
99 _scratch_mkfs >/dev/null 2>&1
102 _run_btrfs_util_prog receive -f $tmp/1.snap $SCRATCH_MNT
103 run_check $FSSUM_PROG -r $tmp/1.fssum $SCRATCH_MNT/mysnap1 2>> $seqres.full
105 _run_btrfs_util_prog receive -f $tmp/clones.snap $SCRATCH_MNT
106 run_check $FSSUM_PROG -r $tmp/clones.fssum $SCRATCH_MNT/clones_snap 2>> $seqres.full
108 _run_btrfs_util_prog receive -f $tmp/2.snap $SCRATCH_MNT
109 run_check $FSSUM_PROG -r $tmp/2.fssum $SCRATCH_MNT/mysnap2 2>> $seqres.full
112 _check_btrfs_filesystem $SCRATCH_DEV