xfs/{263,106}: erase max warnings printout
[xfstests-dev.git] / tests / generic / 412
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2017 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FSQA Test No. 412
6 #
7 # Test that if we have a file with a hole, do a mix of direct IO and buffered
8 # writes to it and truncate the file to a size that lies in the middle of the
9 # hole, after unmounting and mounting again the filesystem, the file has a
10 # correct size and no data loss happened.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # real QA test starts here
29 _supported_fs generic
30 _supported_os Linux
31 _require_scratch
32 _require_odirect
33
34 rm -f $seqres.full
35
36 _scratch_mkfs >>$seqres.full 2>&1
37 _scratch_mount
38
39 # Create out test file with two extents and a hole between those extents.
40 # The extent that lies beyond the hole must be written using direct IO and later
41 # we truncate the file to a size that lies within the hole's range.
42 $XFS_IO_PROG -f -c "pwrite -S 0x01 0K 32K" $SCRATCH_MNT/foo | _filter_xfs_io
43 $XFS_IO_PROG -d -c "pwrite -S 0x02 -b 32K 64K 32K" $SCRATCH_MNT/foo \
44         | _filter_xfs_io
45
46 # Now truncate our file to a smaller size that lies behind the offset used by
47 # the previous direct IO write and that lies in a file hole.
48 $XFS_IO_PROG -c "truncate 60K" $SCRATCH_MNT/foo
49
50 # Now get file digests before unmounting the filesystem and after mounting it
51 # again. The digests should match (same file data and size in both cases).
52 echo "File digest before unmounting the filesystem:"
53 md5sum $SCRATCH_MNT/foo | _filter_scratch
54 _scratch_cycle_mount
55 echo "File digest after mounting again the filesystem:"
56 md5sum $SCRATCH_MNT/foo | _filter_scratch
57
58 status=0
59 exit