2 # FS QA Test No. generic/064
4 # Test multiple fallocate insert/collapse range calls on same file.
5 # Call insert range on alternate blocks multiple times until the file
6 # is left with 50 extents and as many holes. Then call collapse range
7 # on the previously inserted ranges to test merge code of collapse
8 # range. Also check for data integrity and file system consistency.
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2015 Samsung Electronics. All Rights Reserved.
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
34 status=1 # failure is the default!
35 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
41 # real QA test starts here
46 _require_xfs_io_command "fiemap"
47 _require_xfs_io_command "finsert"
48 _require_xfs_io_command "fcollapse"
49 src=$SCRATCH_MNT/testfile
50 dest=$SCRATCH_MNT/testfile.dest
52 BSIZE=`get_block_size $SCRATCH_MNT`
55 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
56 _scratch_mount || _fail "mount failed"
57 length=$(($BLOCKS * $BSIZE))
60 _do "$XFS_IO_PROG -f -c \"pwrite 0 $length\" -c fsync $src"
62 extent_before=`_count_extents $dest`
64 # Insert alternate blocks
65 for (( j=0; j < $(($BLOCKS/2)); j++ )); do
66 offset=$((($j*$BSIZE)*2))
67 _do "$XFS_IO_PROG -c \"finsert $offset $BSIZE\" $dest"
70 # Check if 50 extents are present, allowing some slop for file systems
71 # that don't have ideal allocation behavior
72 num_extents=`_count_extents $dest`
73 _within_tolerance "Extent count after inserts" $num_extents 50 0 6% -v
81 # Collapse alternate blocks
82 for (( j=0; j < $(($BLOCKS/2)); j++ )); do
83 offset=$((($j*$BSIZE)))
84 _do "$XFS_IO_PROG -c \"fcollapse $offset $BSIZE\" $dest"
87 extent_after=`_count_extents $dest`
88 if [ $extent_before -ne $extent_after ]; then
89 echo "extents mismatched before = $extent_before after = $extent_after"
92 # compare original file and test file.
93 cmp $src $dest || _fail "file bytes check failed"