generic: hole punching followed by writes in the same range
[xfstests-dev.git] / tests / generic / 439
1 #! /bin/bash
2 # FS QA Test No. generic/439
3 #
4 # Test that if we punch a hole in a file, with either a range that goes beyond
5 # the file's size or covers a file range that is already a hole, and that if
6 # after we do some buffered write operations that cover different parts of the
7 # hole, no warnings are emmitted in syslog/dmesg and the file's content is
8 # correct after remounting the filesystem.
9 #
10 #-----------------------------------------------------------------------
11 #
12 # Copyright (C) 2017 SUSE Linux Products GmbH. All Rights Reserved.
13 # Author: Filipe Manana <fdmanana@suse.com>
14 #
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
18 #
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
27 #-----------------------------------------------------------------------
28 #
29
30 seq=`basename $0`
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
33
34 tmp=/tmp/$$
35 status=1        # failure 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
48 # real QA test starts here
49 _supported_fs generic
50 _supported_os Linux
51 _require_test
52 _require_scratch
53 _require_xfs_io_command "fpunch"
54
55 rm -f $seqres.full
56
57 _scratch_mkfs >>$seqres.full 2>&1
58 _scratch_mount
59
60 $XFS_IO_PROG -f -c "pwrite -S 0xaa 0 100K" $SCRATCH_MNT/f | _filter_xfs_io
61 $XFS_IO_PROG -c "fpunch 60K 90K" $SCRATCH_MNT/f
62 $XFS_IO_PROG -c "pwrite -S 0xbb -b 100K 50K 100K" $SCRATCH_MNT/f | _filter_xfs_io
63 $XFS_IO_PROG -c "pwrite -S 0xcc -b 50K 100K 50K" $SCRATCH_MNT/f | _filter_xfs_io
64
65 $XFS_IO_PROG -f -c "fpunch 695K 820K" $SCRATCH_MNT/f2
66 $XFS_IO_PROG -c "pwrite -S 0xaa 1008K 307K" $SCRATCH_MNT/f2 |  _filter_xfs_io
67 $XFS_IO_PROG -c "pwrite -S 0xbb -b 630K 1073K 630K" $SCRATCH_MNT/f2 \
68         | _filter_xfs_io
69 $XFS_IO_PROG -c "pwrite -S 0xcc -b 459K 1068K 459K" $SCRATCH_MNT/f2 \
70         | _filter_xfs_io
71
72 _scratch_cycle_mount
73
74 echo "File f contents after remounting filesystem:"
75 od -t x1 $SCRATCH_MNT/f
76 echo "File f2 contents after remounting filesystem:"
77 od -t x1 $SCRATCH_MNT/f2
78
79 status=0
80 exit