2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 SUSE Linux Products GmbH. All Rights Reserved.
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
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
26 # get standard environment, filters and checks
30 # remove previous $seqres.full before test
33 # real QA test starts here
35 # Modify as appropriate.
37 _require_xfs_io_command "truncate"
38 # ranged is a special argument which checks if fiemap supports
40 _require_xfs_io_command "fiemap" "ranged"
42 file=$TEST_DIR/fiemap.$seq
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
51 $XFS_IO_PROG -c "pwrite $(($i*128+64))k 64k" $file >/dev/null;
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
58 # Query data and hole extent
60 $XFS_IO_PROG -c "fiemap -v 64k 80k" $file | _filter_fiemap
63 $XFS_IO_PROG -c "fiemap -v 0 65k" $file | _filter_fiemap
65 echo "Hole + Data + Hole"
66 $XFS_IO_PROG -c "fiemap -v 0k 130k" $file | _filter_fiemap
68 echo "Data + Hole + Data"
69 $XFS_IO_PROG -c "fiemap -v 64k 192k" $file | _filter_fiemap
71 echo "Beginning with a hole"
72 $XFS_IO_PROG -c "fiemap -v 0 3k" $file | _filter_fiemap
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
78 echo "Larger query than file size"
79 $XFS_IO_PROG -c "fiemap -v 0 5m" $file | _filter_fiemap
81 # mapping past eof shouldn't print anything"
82 $XFS_IO_PROG -c "fiemap -v 5m" $file | _filter_fiemap
84 echo "Skip first hole"
85 # check everything without the first hole
86 $XFS_IO_PROG -c "fiemap -v 64k" $file | _filter_fiemap