2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat Inc. All Rights Reserved.
7 # Test per-inode DAX flag by mmap direct/buffered IO.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
28 # remove previous $seqres.full before test
33 _require_scratch_dax_mountopt "dax=always"
34 _require_test_program "feature"
35 _require_test_program "t_mmap_dio"
37 _require_xfs_io_command "falloc"
39 SRC_DIR=$SCRATCH_MNT/src
40 SRC_FILE=$SRC_DIR/tf_s
41 DST_DIR=$SCRATCH_MNT/dst
42 DST_FILE=$DST_DIR/tf_d
46 mkdir -p $SRC_DIR $DST_DIR
51 rm -f $SRC_FILE $DST_FILE
52 $XFS_IO_PROG -f -c "falloc 0 $tsize" \
53 $SRC_FILE $DST_FILE >> $seqres.full 2>&1
58 $XFS_IO_PROG -c "chattr +x" $SRC_DIR $DST_DIR
61 $here/src/t_mmap_dio $SRC_FILE $DST_FILE \
65 # again with buffered IO
66 $here/src/t_mmap_dio -b $SRC_FILE $DST_FILE \
67 $1 "buffered both dax"
72 $XFS_IO_PROG -c "chattr -x" $SRC_DIR
73 $XFS_IO_PROG -c "chattr +x" $DST_DIR
75 $here/src/t_mmap_dio $SRC_FILE $DST_FILE \
76 $1 "dio nondax to dax"
79 $here/src/t_mmap_dio -b $SRC_FILE $DST_FILE \
80 $1 "buffered nondax to dax"
85 $XFS_IO_PROG -c "chattr +x" $SRC_DIR
86 $XFS_IO_PROG -c "chattr -x" $DST_DIR
88 $here/src/t_mmap_dio $SRC_FILE $DST_FILE \
89 $1 "dio dax to nondax"
92 $here/src/t_mmap_dio -b $SRC_FILE $DST_FILE \
93 $1 "buffered dax to nondax"
98 $XFS_IO_PROG -c "chattr -x" $SRC_DIR $DST_DIR
100 $here/src/t_mmap_dio $SRC_FILE $DST_FILE \
104 $here/src/t_mmap_dio -b $SRC_FILE $DST_FILE \
105 $1 "buffered both nondax"
108 # $1 mmap read/write size
109 t_dax_flag_mmap_dio()
119 local mount_option=$1
121 _scratch_mount "$mount_option"
124 # less than page size
125 t_dax_flag_mmap_dio 1024
127 t_dax_flag_mmap_dio `$here/src/feature -s`
128 # bigger sizes, for PMD faults
129 t_dax_flag_mmap_dio $((16 * 1024 * 1024))
130 t_dax_flag_mmap_dio $((64 * 1024 * 1024))
135 # make xfs aligned for PMD fault testing
136 _scratch_mkfs_geom $(_get_hugepagesize) 1 >> $seqres.full 2>&1
138 tsize=$((128 * 1024 * 1024))
140 # mount with dax=inode option
141 do_tests "-o dax=inode"
143 # mount without dax option
144 export MOUNT_OPTIONS=""
148 echo "Silence is golden"