2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Fujitsu. All Rights Reserved.
7 # Test that calling fallocate against a range which is already
8 # allocated does not truncate beyond EOF
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
30 # remove previous $seqres.full before test
33 # real QA test starts here
37 _require_xfs_io_command "falloc"
39 # Use 64K file size to match any sectorsize
40 # And with a unaligned tailing range to ensure it will be at least 2 pages
41 filesize=$(( 64 * 1024 + 1024 ))
43 # Fallocate a range that will not cover the tailing page
44 fallocrange=$(( 64 * 1024 ))
46 _scratch_mkfs > /dev/null 2>&1
48 $XFS_IO_PROG -f -c "pwrite 0 $filesize" $SCRATCH_MNT/foo | _filter_xfs_io
50 orig_extent_nr=`_extent_count $SCRATCH_MNT/foo`
52 # As all space are allocated and even written to disk, this falloc
53 # should do nothing with extent modification.
54 $XFS_IO_PROG -f -c "falloc 0 $fallocrange" $SCRATCH_MNT/foo
56 new_extent_nr=`_extent_count $SCRATCH_MNT/foo`
58 echo "orig: $orig_extent_nr, new: $new_extent_nr" >> $seqres.full
60 if [ "x$orig_extent_nr" != "x$new_extent_nr" ]; then
61 echo "Extent beyond EOF is re-truncated"
62 echo "orig_extent_nr: $orig_extent_nr new_extent_nr: $new_extent_nr"