generic/405: test mkfs against thin provision device
[xfstests-dev.git] / tests / generic / 092
1 #! /bin/bash
2 # FS QA Test No. 092
3 #
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.
7 #
8 # This also verifies that truncat'ing up past i_size doesn't remove the
9 # preallocated space.
10 #
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2015 Facebook.  All Rights Reserved.
13 #
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.
17 #
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.
22 #
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 #-----------------------------------------------------------------------
27 #
28
29 seq=`basename $0`
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
35 status=0        # success is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
37
38 _cleanup()
39 {
40         cd /
41         rm -f $tmp.*
42 }
43
44 # get standard environment, filters and checks
45 . ./common/rc
46 . ./common/filter
47 . ./common/punch
48
49 # real QA test starts here
50
51 # Modify as appropriate.
52 _supported_fs generic
53 _supported_os Linux
54 _require_test
55 _require_xfs_io_command "falloc"
56 _require_fiemap
57
58 # First test to make sure that truncating at i_size trims the preallocated bit
59 # past i_size
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
62 sync
63 $XFS_IO_PROG -c "fiemap -v" $TEST_DIR/testfile.$seq | _filter_fiemap
64
65 # Now verify that if we truncate up past i_size we don't trim the preallocated
66 # bit
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
69
70 # success, all done
71 exit