generic: shutdown fs after log recovery
[xfstests-dev.git] / tests / generic / 071
1 #! /bin/bash
2 # FS QA Test No. 071
3 #
4 # Test extent pre-allocation (using fallocate) into a region that already has a
5 # pre-allocated extent that ends beyond the file's size. Verify that if the fs
6 # is unmounted immediately after, the file's size and content are not lost.
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
10 # Author: Filipe Manana <fdmanana@suse.com>
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34
35 _cleanup()
36 {
37         rm -f $tmp.*
38 }
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 # get standard environment, filters and checks
42 . ./common/rc
43 . ./common/filter
44
45 # real QA test starts here
46 _supported_fs generic
47 _supported_os Linux
48 _require_scratch
49 _require_xfs_io_command "falloc"
50
51 rm -f $seqres.full
52
53 _scratch_mkfs >> $seqres.full 2>&1
54 _scratch_mount
55
56 # Create our test file with a pre-allocated extent that doesn't increase the
57 # file's size.
58 $XFS_IO_PROG -f -c "falloc -k 0 1M" $SCRATCH_MNT/foo
59
60 # Write some data to our file.
61 $XFS_IO_PROG -c "pwrite -S 0xaa 0 256K" $SCRATCH_MNT/foo | _filter_xfs_io
62
63 # Now call fallocate again, but allowing it to increase the file's size and
64 # cover a range that is entirely covered by the extent that we previously
65 # pre-allocated.
66 $XFS_IO_PROG -c "falloc 0 512K" $SCRATCH_MNT/foo
67
68 # Now ummount and mount again the fs. After this we expect the file's size to
69 # be 512Kb.
70 _scratch_cycle_mount
71
72 # Now check that all data we wrote before are available and the file size is
73 # 512Kb.
74 echo "File content after remount:"
75 od -t x1 $SCRATCH_MNT/foo
76
77 status=0
78 exit