generic/554: hide permision warning on exfat
[xfstests-dev.git] / tests / generic / 605
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 605
6 #
7 # Test per-inode DAX flag by mmap direct/buffered IO.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # remove previous $seqres.full before test
29 rm -f $seqres.full
30
31 _supported_fs generic
32 _require_scratch_dax_mountopt "dax=always"
33 _require_test_program "feature"
34 _require_test_program "t_mmap_dio"
35 _require_dax_iflag
36 _require_xfs_io_command "falloc"
37
38 SRC_DIR=$SCRATCH_MNT/src
39 SRC_FILE=$SRC_DIR/tf_s
40 DST_DIR=$SCRATCH_MNT/dst
41 DST_FILE=$DST_DIR/tf_d
42
43 prep_directories()
44 {
45         mkdir -p $SRC_DIR $DST_DIR
46 }
47
48 prep_files()
49 {
50         rm -f $SRC_FILE $DST_FILE
51         $XFS_IO_PROG -f -c "falloc 0 $tsize" \
52                 $SRC_FILE $DST_FILE >> $seqres.full 2>&1
53 }
54
55 t_both_dax()
56 {
57         $XFS_IO_PROG -c "chattr +x" $SRC_DIR $DST_DIR
58         prep_files
59         # with O_DIRECT first
60         $here/src/t_mmap_dio $SRC_FILE $DST_FILE \
61                 $1 "dio both dax"
62
63         prep_files
64         # again with buffered IO
65         $here/src/t_mmap_dio -b $SRC_FILE $DST_FILE \
66                 $1 "buffered both dax"
67 }
68
69 t_nondax_to_dax()
70 {
71         $XFS_IO_PROG -c "chattr -x" $SRC_DIR
72         $XFS_IO_PROG -c "chattr +x" $DST_DIR
73         prep_files
74         $here/src/t_mmap_dio $SRC_FILE $DST_FILE \
75                 $1 "dio nondax to dax"
76
77         prep_files
78         $here/src/t_mmap_dio -b $SRC_FILE $DST_FILE \
79                 $1 "buffered nondax to dax"
80 }
81
82 t_dax_to_nondax()
83 {
84         $XFS_IO_PROG -c "chattr +x" $SRC_DIR
85         $XFS_IO_PROG -c "chattr -x" $DST_DIR
86         prep_files
87         $here/src/t_mmap_dio $SRC_FILE $DST_FILE \
88                 $1 "dio dax to nondax"
89
90         prep_files
91         $here/src/t_mmap_dio -b $SRC_FILE $DST_FILE \
92                 $1 "buffered dax to nondax"
93 }
94
95 t_both_nondax()
96 {
97         $XFS_IO_PROG -c "chattr -x" $SRC_DIR $DST_DIR
98         prep_files
99         $here/src/t_mmap_dio $SRC_FILE $DST_FILE \
100                 $1 "dio both nondax"
101
102         prep_files
103         $here/src/t_mmap_dio -b $SRC_FILE $DST_FILE \
104                 $1 "buffered both nondax"
105 }
106
107 # $1 mmap read/write size
108 t_dax_flag_mmap_dio()
109 {
110         t_both_dax $1
111         t_dax_to_nondax $1
112         t_nondax_to_dax $1
113         t_both_nondax $1
114 }
115
116 do_tests()
117 {
118         local mount_option=$1
119
120         _scratch_mount "$mount_option"
121
122         prep_directories
123         # less than page size
124         t_dax_flag_mmap_dio 1024
125         # page size
126         t_dax_flag_mmap_dio `$here/src/feature -s`
127         # bigger sizes, for PMD faults
128         t_dax_flag_mmap_dio $((16 * 1024 * 1024))
129         t_dax_flag_mmap_dio $((64 * 1024 * 1024))
130
131         _scratch_unmount
132 }
133
134 # make xfs aligned for PMD fault testing
135 _scratch_mkfs_geom $(_get_hugepagesize) 1 >> $seqres.full 2>&1
136
137 tsize=$((128 * 1024 * 1024))
138
139 # mount with dax=inode option
140 do_tests "-o dax=inode"
141
142 # mount without dax option
143 export MOUNT_OPTIONS=""
144 do_tests
145
146 # success, all done
147 echo "Silence is golden"
148 status=0
149 exit