generic/395: remove workarounds for wrong error codes
[xfstests-dev.git] / tests / generic / 473
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. 473
6 #
7 # Test for the new ranged query functionality in xfs_io's fiemap command.
8 # This tests various combinations of hole + data layout being printed.
9 # Also the test used 16k holes to be compatible with 16k block filesystems
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/punch
29
30 # remove previous $seqres.full before test
31 rm -f $seqres.full
32
33 # real QA test starts here
34
35 # Modify as appropriate.
36 _require_test
37 _require_xfs_io_command "truncate"
38 # ranged is a special argument which checks if fiemap supports
39 # [offset [len]] args
40 _require_xfs_io_command "fiemap" "ranged"
41
42 file=$TEST_DIR/fiemap.$seq
43 rm -f $file
44
45 # Create a file with 64k hole followed by 64k data, and this pattern
46 # repeats till it reaches 4M file size, so each extent has 64k data.
47 # But truncate file to its final size first, otherwise XFS would merge
48 # some extents due to speculative preallocation.
49 $XFS_IO_PROG -f -c "truncate 4m" $file
50 for i in {0..31}; do
51         $XFS_IO_PROG -c "pwrite $(($i*128+64))k 64k" $file >/dev/null;
52 done
53
54 # Query 1 data extent between 64k..64k range
55 echo "Basic data extent"
56 $XFS_IO_PROG -c "fiemap -v 64k 64k" $file | _filter_fiemap
57
58 # Query data and hole extent
59 echo "Data + Hole"
60 $XFS_IO_PROG -c "fiemap -v 64k 80k" $file | _filter_fiemap
61
62 echo "Hole + Data"
63 $XFS_IO_PROG -c "fiemap -v 0 65k" $file | _filter_fiemap
64
65 echo "Hole + Data + Hole"
66 $XFS_IO_PROG -c "fiemap -v 0k 130k" $file | _filter_fiemap
67
68 echo "Data + Hole + Data"
69 $XFS_IO_PROG -c "fiemap -v 64k 192k" $file | _filter_fiemap
70
71 echo "Beginning with a hole"
72 $XFS_IO_PROG -c "fiemap -v 0 3k" $file | _filter_fiemap
73
74 # Query for 0..160k that's 40 extents, more than the EXTENT_BATCH
75 echo "Query more than 32 extents"
76 $XFS_IO_PROG -c "fiemap -v 0 3m" $file | _filter_fiemap
77
78 echo "Larger query than file size"
79 $XFS_IO_PROG -c "fiemap -v 0 5m" $file | _filter_fiemap
80
81 # mapping past eof shouldn't print anything"
82 $XFS_IO_PROG -c "fiemap -v 5m" $file | _filter_fiemap
83
84 echo "Skip first hole"
85 # check everything without the first hole
86 $XFS_IO_PROG -c "fiemap -v 64k" $file | _filter_fiemap
87
88 # success, all done
89 status=0
90 exit