generic: Verify the inheritance behavior of FS_XFLAG_DAX flag in various combinations
[xfstests-dev.git] / tests / generic / 567
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. generic/567
6 #
7 # Test mapped writes against punch-hole to ensure we get the data
8 # correctly written. This can expose data corruption bugs on filesystems
9 # where the block size is smaller than the page size.
10 #
11 # (generic/029 is a similar test but for truncate.)
12 #
13 seq=`basename $0`
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.*
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31
32 # real QA test starts here
33 _supported_fs generic
34 _supported_os Linux
35 _require_scratch
36 _require_xfs_io_command "fpunch"
37
38 testfile=$SCRATCH_MNT/testfile
39
40 _scratch_mkfs > /dev/null 2>&1
41 _scratch_mount
42
43 # Punch a hole straddling two pages to check that the mapped write after the
44 # hole-punching is correctly handled.
45
46 $XFS_IO_PROG -t -f \
47 -c "pwrite -S 0x58 0 12288" \
48 -c "mmap -rw 0 12288" \
49 -c "mwrite -S 0x5a 2048 8192" \
50 -c "fpunch 2048 8192" \
51 -c "mwrite -S 0x59 2048 8192" \
52 -c "close"      \
53 $testfile | _filter_xfs_io
54
55 echo "==== Pre-Remount ==="
56 hexdump -C $testfile
57 _scratch_cycle_mount
58 echo "==== Post-Remount =="
59 hexdump -C $testfile
60
61 status=0
62 exit