2 # FS QA Test No. generci/017
4 # Test multiple fallocate collapse range calls on same file.
5 # For different blocksizes, collapse a single alternate block multiple times
6 # until the file is left with 80 blocks and as much number of extents.
7 # Also check for file system consistency after completing this operation
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2013 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 "fcollapse"
50 _scratch_mkfs > /dev/null 2>&1
53 testfile=$SCRATCH_MNT/$seq.$$
56 BSIZE=`get_block_size $SCRATCH_MNT`
58 length=$(($BLOCKS * $BSIZE))
61 $XFS_IO_PROG -f -c "pwrite 0 $length" -c fsync $testfile > /dev/null
63 # Collapse alternate blocks
64 for (( i = 1; i <= 7; i++ )); do
65 for (( j=0; j < $(($BLOCKS/(2**$i))); j++ )); do
67 $XFS_IO_PROG -c "fcollapse $offset $BSIZE" $testfile > /dev/null
71 # Check if 80 extents are present
72 $XFS_IO_PROG -c "fiemap -v" $testfile | grep "^ *[0-9]*:" |wc -l