2 # FS QA Test No. shared/005
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
42 _supported_fs xfs ext4
46 _require_xfs_io_fiemap
47 _require_xfs_io_falloc_collapse
49 testfile=$SCRATCH_MNT/$seq.$$
52 for (( BSIZE = 1024; BSIZE <= 4096; BSIZE *= 2 )); do
54 length=$(($BLOCKS * $BSIZE))
57 _scratch_mkfs -b size=$BSIZE >> $seqres.full 2>&1
60 _scratch_mkfs -b $BSIZE >> $seqres.full 2>&1
63 _scratch_mount >> $seqres.full 2>&1
66 $XFS_IO_PROG -f -c "pwrite 0 $length" -c fsync $testfile > /dev/null
68 # Collapse alternate blocks
69 for (( i = 1; i <= 7; i++ )); do
70 for (( j=0; j < $(($BLOCKS/(2**$i))); j++ )); do
72 $XFS_IO_PROG -c "fcollapse $offset $BSIZE" $testfile > /dev/null
76 # Check if 80 extents are present
77 $XFS_IO_PROG -c "fiemap -v" $testfile | grep "^ *[0-9]*:" |wc -l