2 # FS QA Test No. btrfs/137
4 # Test that both incremental and full send operations preserve file holes.
6 #-----------------------------------------------------------------------
8 # Copyright (C) 2017 SUSE Linux Products GmbH. All Rights Reserved.
9 # Author: Filipe Manana <fdmanana@suse.com>
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
37 rm -fr $send_files_dir
41 # get standard environment, filters and checks
46 # real QA test starts here
51 _require_xfs_io_command "fiemap"
53 send_files_dir=$TEST_DIR/btrfs-test-$seq
56 rm -fr $send_files_dir
59 _scratch_mkfs >>$seqres.full 2>&1
62 # Create the first test file.
63 $XFS_IO_PROG -f -c "pwrite -S 0xaa 0 4K" $SCRATCH_MNT/foo | _filter_xfs_io
65 # Create a second test file with a 1Mb hole.
67 -c "pwrite -S 0xaa 0 4K" \
68 -c "pwrite -S 0xbb 1028K 4K" \
69 $SCRATCH_MNT/bar | _filter_xfs_io
71 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
72 $SCRATCH_MNT/snap1 >/dev/null
74 # Now add one new extent to our first test file, increasing its size and leaving
75 # a 1Mb hole between the first extent and this new extent.
76 $XFS_IO_PROG -c "pwrite -S 0xbb 1028K 4K" $SCRATCH_MNT/foo | _filter_xfs_io
78 # Now overwrite the last extent of our second test file.
79 $XFS_IO_PROG -c "pwrite -S 0xcc 1028K 4K" $SCRATCH_MNT/bar | _filter_xfs_io
81 $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
82 $SCRATCH_MNT/snap2 >/dev/null
85 echo "File digests in the original filesystem:"
86 md5sum $SCRATCH_MNT/snap1/foo | _filter_scratch
87 md5sum $SCRATCH_MNT/snap1/bar | _filter_scratch
88 md5sum $SCRATCH_MNT/snap2/foo | _filter_scratch
89 md5sum $SCRATCH_MNT/snap2/bar | _filter_scratch
92 echo "File snap1/foo fiemap results in the original filesystem:"
93 $XFS_IO_PROG -r -c "fiemap -v" $SCRATCH_MNT/snap1/foo | _filter_fiemap
95 echo "File snap1/bar fiemap results in the original filesystem:"
96 $XFS_IO_PROG -r -c "fiemap -v" $SCRATCH_MNT/snap1/bar | _filter_fiemap
98 echo "File snap2/foo fiemap results in the original filesystem:"
99 $XFS_IO_PROG -r -c "fiemap -v" $SCRATCH_MNT/snap2/foo | _filter_fiemap
101 echo "File snap2/bar fiemap results in the original filesystem:"
102 $XFS_IO_PROG -r -c "fiemap -v" $SCRATCH_MNT/snap2/bar | _filter_fiemap
105 # Create the send streams to apply later on a new filesystem.
106 $BTRFS_UTIL_PROG send -f $send_files_dir/1.snap $SCRATCH_MNT/snap1 2>&1 \
108 $BTRFS_UTIL_PROG send -p $SCRATCH_MNT/snap1 -f $send_files_dir/2.snap \
109 $SCRATCH_MNT/snap2 2>&1 | _filter_scratch
111 # Create a new filesystem, receive the send streams and verify that the file
112 # contents are the same as in the original filesystem and that the file holes
113 # exists in both snapshots.
115 _scratch_mkfs >>$seqres.full 2>&1
117 $BTRFS_UTIL_PROG receive -f $send_files_dir/1.snap $SCRATCH_MNT >/dev/null
118 $BTRFS_UTIL_PROG receive -f $send_files_dir/2.snap $SCRATCH_MNT >/dev/null
121 echo "File digests in the new filesystem:"
122 md5sum $SCRATCH_MNT/snap1/foo | _filter_scratch
123 md5sum $SCRATCH_MNT/snap1/bar | _filter_scratch
124 md5sum $SCRATCH_MNT/snap2/foo | _filter_scratch
125 md5sum $SCRATCH_MNT/snap2/bar | _filter_scratch
128 echo "File snap1/foo fiemap results in the new filesystem:"
129 $XFS_IO_PROG -r -c "fiemap -v" $SCRATCH_MNT/snap1/foo | _filter_fiemap
131 echo "File snap1/bar fiemap results in the new filesystem:"
132 $XFS_IO_PROG -r -c "fiemap -v" $SCRATCH_MNT/snap1/bar | _filter_fiemap
134 echo "File snap2/foo fiemap results in the new filesystem:"
135 $XFS_IO_PROG -r -c "fiemap -v" $SCRATCH_MNT/snap2/foo | _filter_fiemap
137 echo "File snap2/bar fiemap results in the new filesystem:"
138 $XFS_IO_PROG -r -c "fiemap -v" $SCRATCH_MNT/snap2/bar | _filter_fiemap