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.
38 _require_xfs_io_command "truncate"
39 # ranged is a special argument which checks if fiemap supports
41 _require_xfs_io_command "fiemap" "ranged"
43 file=$TEST_DIR/fiemap.$seq
46 # Create a file with 64k hole followed by 64k data, and this pattern
47 # repeats till it reaches 4M file size, so each extent has 64k data.
48 # But truncate file to its final size first, otherwise XFS would merge
49 # some extents due to speculative preallocation.
50 $XFS_IO_PROG -f -c "truncate 4m" $file
52 $XFS_IO_PROG -c "pwrite $(($i*128+64))k 64k" $file >/dev/null;
55 # Query 1 data extent between 64k..64k range
56 echo "Basic data extent"
57 $XFS_IO_PROG -c "fiemap -v 64k 64k" $file | _filter_fiemap
59 # Query data and hole extent
61 $XFS_IO_PROG -c "fiemap -v 64k 80k" $file | _filter_fiemap
64 $XFS_IO_PROG -c "fiemap -v 0 65k" $file | _filter_fiemap
66 echo "Hole + Data + Hole"
67 $XFS_IO_PROG -c "fiemap -v 0k 130k" $file | _filter_fiemap
69 echo "Data + Hole + Data"
70 $XFS_IO_PROG -c "fiemap -v 64k 192k" $file | _filter_fiemap
72 echo "Beginning with a hole"
73 $XFS_IO_PROG -c "fiemap -v 0 3k" $file | _filter_fiemap
75 # Query for 0..160k that's 40 extents, more than the EXTENT_BATCH
76 echo "Query more than 32 extents"
77 $XFS_IO_PROG -c "fiemap -v 0 3m" $file | _filter_fiemap
79 echo "Larger query than file size"
80 $XFS_IO_PROG -c "fiemap -v 0 5m" $file | _filter_fiemap
82 # mapping past eof shouldn't print anything"
83 $XFS_IO_PROG -c "fiemap -v 5m" $file | _filter_fiemap
85 echo "Skip first hole"
86 # check everything without the first hole
87 $XFS_IO_PROG -c "fiemap -v 64k" $file | _filter_fiemap