generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 413
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test 413
6 #
7 # mmap direct/buffered io between DAX and non-DAX mountpoints.
8 #
9 . ./common/preamble
10 _begin_fstest auto quick dax
11
12 # Import common functions.
13 . ./common/filter
14
15 _supported_fs generic
16 _require_test
17 _require_scratch_dax_mountopt "dax"
18 _require_test_program "feature"
19 _require_test_program "t_mmap_dio"
20 _require_xfs_io_command "falloc"
21
22 prep_files()
23 {
24         rm -f $SCRATCH_MNT/tf_{s,d}
25         rm -f $TEST_DIR/tf_{s,d}
26
27         $XFS_IO_PROG -f -c "falloc 0 $tsize" \
28                 $SCRATCH_MNT/tf_{s,d} >> $seqres.full 2>&1
29         $XFS_IO_PROG -f -c "falloc 0 $tsize" \
30                 $TEST_DIR/tf_{s,d} >> $seqres.full 2>&1
31 }
32
33 t_both_dax()
34 {
35         prep_files
36         # with O_DIRECT first
37         $here/src/t_mmap_dio $SCRATCH_MNT/tf_{s,d} $1 "dio both dax"
38
39         prep_files
40         # again with buffered IO
41         $here/src/t_mmap_dio -b $SCRATCH_MNT/tf_{s,d} \
42                 $1 "buffered both dax"
43 }
44
45 t_nondax_to_dax()
46 {
47         prep_files
48         $here/src/t_mmap_dio $TEST_DIR/tf_s \
49                 $SCRATCH_MNT/tf_d $1 "dio nondax to dax"
50
51         prep_files
52         $here/src/t_mmap_dio -b $TEST_DIR/tf_s \
53                 $SCRATCH_MNT/tf_d $1 "buffered nondax to dax"
54 }
55
56 t_dax_to_nondax()
57 {
58         prep_files
59         $here/src/t_mmap_dio $SCRATCH_MNT/tf_s \
60                 $TEST_DIR/tf_d $1 "dio dax to nondax"
61
62         prep_files
63         $here/src/t_mmap_dio -b $SCRATCH_MNT/tf_s \
64                 $TEST_DIR/tf_d $1 "buffered dax to nondax"
65 }
66
67 t_both_nondax()
68 {
69         prep_files
70         $here/src/t_mmap_dio $TEST_DIR/tf_{s,d} $1 "dio both nondax"
71
72         prep_files
73         $here/src/t_mmap_dio -b $TEST_DIR/tf_{s,d} \
74                 $1 "buffered both nondax"
75 }
76
77 # $1 mmap read/write size
78 t_mmap_dio_dax()
79 {
80         t_both_dax $1
81         t_dax_to_nondax $1
82         t_nondax_to_dax $1
83         t_both_nondax $1
84 }
85
86 do_tests()
87 {
88         # less than page size
89         t_mmap_dio_dax 1024
90         # page size
91         t_mmap_dio_dax `$here/src/feature -s`
92         # bigger sizes, for PMD faults
93         t_mmap_dio_dax $((16 * 1024 * 1024))
94         t_mmap_dio_dax $((64 * 1024 * 1024))
95 }
96
97 # make fs aligned for PMD fault testing
98 _scratch_mkfs_geom $(_get_hugepagesize) 1 >> $seqres.full 2>&1
99
100 # mount SCRATCH_DEV with dax option, TEST_DEV not
101 export MOUNT_OPTIONS=""
102 export TEST_FS_MOUNT_OPTS=""
103 _test_cycle_mount
104 _fs_options $TEST_DEV | grep -qw "dax" && \
105         _notrun "we need $TEST_DEV mount without dax"
106 _scratch_mount "-o dax"
107
108 tsize=$((128 * 1024 * 1024))
109
110 do_tests
111
112 # success, all done
113 echo "Silence is golden"
114 status=0
115 exit