generic/405: test mkfs against thin provision device
[xfstests-dev.git] / tests / generic / 308
1 #! /bin/bash
2 # FS QA Test No. 308
3 #
4 # Regression test for commit:
5 # f17722f ext4: Fix max file size and logical block counting of extent format file
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
28
29 status=1        # failure is the default!
30 trap "_cleanup; exit \$status" 0 1 2 3 15
31
32 _cleanup()
33 {
34         cd /
35         rm -f $testfile
36 }
37
38 # get standard environment, filters and checks
39 . ./common/rc
40 . ./common/filter
41
42 testfile=$TEST_DIR/testfile.$seq
43
44 # real QA test starts here
45 _supported_fs generic
46 _supported_os Linux
47 _require_test
48
49 rm -f $seqres.full
50 echo "Silence is golden"
51
52 block_size=`_get_block_size $TEST_DIR`
53
54 # On unpatched ext4, if an extent exists which includes the block right
55 # before the maximum file offset, and the block for the maximum file offset
56 # is written, the kernel panics
57 # On patched ext4, the write would get EFBIG since we lower s_maxbytes by
58 # one fs block
59
60 # Create a sparse file with an extent lays at one block before old s_maxbytes
61 offset=$(((2**32 - 2) * $block_size))
62 $XFS_IO_PROG -f -c "pwrite $offset $block_size" -c fsync $testfile >$seqres.full 2>&1
63
64 # Write to the block after the extent just created
65 offset=$(((2**32 - 1) * $block_size))
66 $XFS_IO_PROG -f -c "pwrite $offset $block_size" -c fsync $testfile >>$seqres.full 2>&1
67
68 # Got here without hitting BUG_ON(), test passed
69 status=0
70 exit