2 # FS QA Test No. btrfs/034
4 # Test for a btrfs incremental send data corruption issue due to
5 # bad detection of file holes.
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2014 Filipe Manana. All Rights Reserved.
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
39 # get standard environment, filters and checks
43 # real QA test starts here
50 _scratch_mkfs >/dev/null 2>&1
53 # Create a file such that its file extent items span at least 3 btree leafs.
54 # This is necessary to trigger a btrfs incremental send bug where file hole
55 # detection was not correct, leading to data corruption by overriding latest
56 # data regions of a file with zeroes.
58 $XFS_IO_PROG -f -c "truncate 104857600" $SCRATCH_MNT/foo
60 for ((i = 0; i < 940; i++))
62 OFFSET=$((32768 + i * 8192))
63 LEN=$((OFFSET + 8192))
64 $XFS_IO_PROG -c "falloc -k $OFFSET $LEN" $SCRATCH_MNT/foo
65 $XFS_IO_PROG -c "pwrite -S 0xf0 $OFFSET 4096" \
66 $SCRATCH_MNT/foo | _filter_xfs_io
69 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
71 $XFS_IO_PROG -c "truncate 3882008" $SCRATCH_MNT/foo
73 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
75 _run_btrfs_util_prog send -f $tmp/1.snap $SCRATCH_MNT/mysnap1
76 _run_btrfs_util_prog send -f $tmp/2.snap -p $SCRATCH_MNT/mysnap1 \
79 md5sum $SCRATCH_MNT/foo | _filter_scratch
80 md5sum $SCRATCH_MNT/mysnap1/foo | _filter_scratch
81 md5sum $SCRATCH_MNT/mysnap2/foo | _filter_scratch
84 _check_btrfs_filesystem $SCRATCH_DEV
85 _scratch_mkfs >/dev/null 2>&1
88 _run_btrfs_util_prog receive -f $tmp/1.snap $SCRATCH_MNT
89 md5sum $SCRATCH_MNT/mysnap1/foo | _filter_scratch
91 _run_btrfs_util_prog receive -f $tmp/2.snap $SCRATCH_MNT
92 md5sum $SCRATCH_MNT/mysnap2/foo | _filter_scratch
95 _check_btrfs_filesystem $SCRATCH_DEV