fstests: move test group info to test files
[xfstests-dev.git] / tests / btrfs / 107
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Fujitsu. All Rights Reserved.
4 #
5 # FS QA Test 107
6 #
7 # Test that calling fallocate against a range which is already
8 # allocated does not truncate beyond EOF
9 #
10 . ./common/preamble
11 _begin_fstest auto quick prealloc
12
13 # Import common functions.
14 . ./common/filter
15 . ./common/defrag
16
17 # real QA test starts here
18
19 _supported_fs btrfs
20 _require_scratch
21 _require_xfs_io_command "falloc"
22
23 # Use 64K file size to match any sectorsize
24 # And with a unaligned tailing range to ensure it will be at least 2 pages
25 filesize=$(( 64 * 1024 + 1024 ))
26
27 # Fallocate a range that will not cover the tailing page
28 fallocrange=$(( 64 * 1024 ))
29
30 _scratch_mkfs > /dev/null 2>&1
31 _scratch_mount
32 $XFS_IO_PROG -f -c "pwrite 0 $filesize" $SCRATCH_MNT/foo | _filter_xfs_io
33 sync
34 orig_extent_nr=`_extent_count $SCRATCH_MNT/foo`
35
36 # As all space are allocated and even written to disk, this falloc
37 # should do nothing with extent modification.
38 $XFS_IO_PROG -f -c "falloc 0 $fallocrange" $SCRATCH_MNT/foo
39 sync
40 new_extent_nr=`_extent_count $SCRATCH_MNT/foo`
41
42 echo "orig: $orig_extent_nr, new: $new_extent_nr" >> $seqres.full
43
44 if [ "x$orig_extent_nr" != "x$new_extent_nr" ]; then
45         echo "Extent beyond EOF is re-truncated"
46         echo "orig_extent_nr: $orig_extent_nr new_extent_nr: $new_extent_nr"
47 fi
48
49 # success, all done
50 status=0
51 exit