2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Samsung Electronics. All Rights Reserved.
5 # FS QA Test No. generci/017
7 # Test multiple fallocate collapse range calls on same file.
8 # For different blocksizes, collapse a single alternate block multiple times
9 # until the file is left with 80 blocks and as much number of extents.
10 # Also check for file system consistency after completing this operation
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
21 # get standard environment, filters and checks
25 # real QA test starts here
30 _require_xfs_io_command "fiemap"
31 _require_xfs_io_command "fcollapse"
34 _scratch_mkfs > /dev/null 2>&1
37 testfile=$SCRATCH_MNT/$seq.$$
40 BSIZE=`_get_block_size $SCRATCH_MNT`
42 length=$(($BLOCKS * $BSIZE))
45 $XFS_IO_PROG -f -c "pwrite 0 $length" -c fsync $testfile > /dev/null
47 # Collapse alternate blocks
48 for (( i = 1; i <= 7; i++ )); do
49 for (( j=0; j < $(($BLOCKS/(2**$i))); j++ )); do
51 $XFS_IO_PROG -c "fcollapse $offset $BSIZE" $testfile > /dev/null
55 # Check if 80 extents are present
56 $XFS_IO_PROG -c "fiemap -v" $testfile | grep "^ *[0-9]*:" |wc -l