generic/402: Drop useless fail message
[xfstests-dev.git] / tests / generic / 064
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Samsung Electronics.  All Rights Reserved.
4 #
5 # FS QA Test No. generic/064
6 #
7 # Test multiple fallocate insert/collapse range calls on same file.
8 # Call insert range on alternate blocks multiple times until the file
9 # is left with 50 extents and as many holes. Then call collapse range
10 # on the previously inserted ranges to test merge code of collapse
11 # range. Also check for data integrity and file system consistency.
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
20
21 # get standard environment, filters and checks
22 . ./common/rc
23 . ./common/filter
24
25 # real QA test starts here
26 _supported_fs generic
27
28 _require_scratch
29 _require_xfs_io_command "fiemap"
30 _require_xfs_io_command "finsert"
31 _require_xfs_io_command "fcollapse"
32
33 rm -f $seqres.full
34
35 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
36 _scratch_mount
37
38 src=$SCRATCH_MNT/testfile
39 dest=$SCRATCH_MNT/testfile.dest
40 BLOCKS=100
41 BSIZE=`_get_block_size $SCRATCH_MNT`
42 length=$(($BLOCKS * $BSIZE))
43
44 # Write file
45 _do "$XFS_IO_PROG -f -c \"pwrite 0 $length\" -c fsync $src"
46 cp $src $dest
47 extent_before=`_count_extents $dest`
48
49 # Insert alternate blocks
50 for (( j=0; j < $(($BLOCKS/2)); j++ )); do
51         offset=$((($j*$BSIZE)*2))
52         _do "$XFS_IO_PROG -c \"finsert $offset $BSIZE\" $dest"
53 done
54
55 # Check if 50 extents are present, allowing some slop for file systems
56 # that don't have ideal allocation behavior
57 num_extents=`_count_extents $dest`
58 _within_tolerance "Extent count after inserts" $num_extents 50 0 6% -v
59
60 _check_scratch_fs
61 if [ $? -ne 0 ]; then
62         status=1
63         exit
64 fi
65
66 # Collapse alternate blocks
67 for (( j=0; j < $(($BLOCKS/2)); j++ )); do
68         offset=$((($j*$BSIZE)))
69         _do "$XFS_IO_PROG -c \"fcollapse $offset $BSIZE\" $dest"
70 done
71
72 extent_after=`_count_extents $dest`
73 if [ $extent_before -ne $extent_after ]; then
74         echo "extents mismatched before = $extent_before after = $extent_after"
75 fi
76
77 # compare original file and test file.
78 cmp $src $dest || _fail "file bytes check failed"
79
80 # success, all done
81 status=0
82 exit