4 # fallocate/truncate tests with FALLOC_FL_KEEP_SIZE option.
5 # Verify if the disk space is released after truncating a file to i_size after
6 # writing to a portion of a preallocated range.
8 # This also verifies that truncat'ing up past i_size doesn't remove the
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2015 Facebook. All Rights Reserved.
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #-----------------------------------------------------------------------
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
35 status=0 # success is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
44 # get standard environment, filters and checks
49 # real QA test starts here
51 # Modify as appropriate.
55 _require_xfs_io_command "falloc"
58 # First test to make sure that truncating at i_size trims the preallocated bit
60 $XFS_IO_PROG -f -c "falloc -k 0 10M" -c "pwrite 0 5M" -c "truncate 5M"\
61 $TEST_DIR/testfile.$seq | _filter_xfs_io
63 $XFS_IO_PROG -c "fiemap -v" $TEST_DIR/testfile.$seq | _filter_fiemap
65 # Now verify that if we truncate up past i_size we don't trim the preallocated
67 $XFS_IO_PROG -c "falloc -k 5M 5M" -c "truncate 7M" $TEST_DIR/testfile.$seq
68 $XFS_IO_PROG -c "fiemap -v" $TEST_DIR/testfile.$seq | _filter_fiemap