generic: Verify the inheritance behavior of FS_XFLAG_DAX flag in various combinations
[xfstests-dev.git] / tests / generic / 250
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 250
6 #
7 # Create an unwritten extent, set up dm-error, try a DIO write, then
8 # make sure we can't read back old disk contents.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
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     cd /
22     rm -rf $tmp.* $testdir
23     _dmerror_cleanup
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/dmerror
30
31 # real QA test starts here
32 _supported_os Linux
33 _require_scratch
34 _require_dm_target error
35 _require_xfs_io_command "falloc"
36 _require_odirect
37 # This test uses "dm" without taking into account the data could be on
38 # realtime subvolume, thus the test will fail with rtinherit=1
39 _require_no_rtinherit
40
41 rm -f $seqres.full
42
43 fssize=$((196 * 1048576))
44 echo "Format and mount"
45 $XFS_IO_PROG -d -c "pwrite -S 0x69 -b 1048576 0 $fssize" $SCRATCH_DEV >> $seqres.full
46 _scratch_mkfs_sized $fssize > $seqres.full 2>&1
47 _dmerror_init
48 _dmerror_mount >> $seqres.full 2>&1
49 _dmerror_unmount
50 _dmerror_mount
51
52 testdir=$SCRATCH_MNT/test-$seq
53 mkdir $testdir
54
55 blksz=65536
56 nr=640
57 bufnr=128
58 filesize=$((blksz * nr))
59 bufsize=$((blksz * bufnr))
60
61 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 5 / 4))
62
63 echo "Create the original files"
64 $XFS_IO_PROG -f -c "falloc 0 $filesize" $testdir/file2 >> $seqres.full
65 _dmerror_unmount
66 _dmerror_mount
67
68 echo "Compare files"
69 md5sum $testdir/file2 | _filter_scratch
70
71 echo "Write and unmount"
72 $XFS_IO_PROG -f -c "pwrite -S 0x63 $bufsize 1" $testdir/file2 >> $seqres.full
73 sync
74 _dmerror_load_error_table
75 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 \
76         >> $seqres.full 2>&1
77 _dmerror_load_working_table
78 _dmerror_unmount
79 _dmerror_mount
80
81 echo "Compare files"
82 md5sum $testdir/file2 | _filter_scratch
83
84 echo "Check for damage"
85 _dmerror_unmount
86 _dmerror_cleanup
87 _repair_scratch_fs >> $seqres.full
88
89 # success, all done
90 status=0
91 exit