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 _begin_fstest auto attr quick dax
12 # Import common functions.
16 _require_scratch_dax_mountopt "dax=always"
17 _require_test_program "feature"
18 _require_test_program "t_mmap_dio"
20 _require_xfs_io_command "falloc"
22 SRC_DIR=$SCRATCH_MNT/src
23 SRC_FILE=$SRC_DIR/tf_s
24 DST_DIR=$SCRATCH_MNT/dst
25 DST_FILE=$DST_DIR/tf_d
29 mkdir -p $SRC_DIR $DST_DIR
34 rm -f $SRC_FILE $DST_FILE
35 $XFS_IO_PROG -f -c "falloc 0 $tsize" \
36 $SRC_FILE $DST_FILE >> $seqres.full 2>&1
41 $XFS_IO_PROG -c "chattr +x" $SRC_DIR $DST_DIR
44 $here/src/t_mmap_dio $SRC_FILE $DST_FILE \
48 # again with buffered IO
49 $here/src/t_mmap_dio -b $SRC_FILE $DST_FILE \
50 $1 "buffered both dax"
55 $XFS_IO_PROG -c "chattr -x" $SRC_DIR
56 $XFS_IO_PROG -c "chattr +x" $DST_DIR
58 $here/src/t_mmap_dio $SRC_FILE $DST_FILE \
59 $1 "dio nondax to dax"
62 $here/src/t_mmap_dio -b $SRC_FILE $DST_FILE \
63 $1 "buffered nondax to dax"
68 $XFS_IO_PROG -c "chattr +x" $SRC_DIR
69 $XFS_IO_PROG -c "chattr -x" $DST_DIR
71 $here/src/t_mmap_dio $SRC_FILE $DST_FILE \
72 $1 "dio dax to nondax"
75 $here/src/t_mmap_dio -b $SRC_FILE $DST_FILE \
76 $1 "buffered dax to nondax"
81 $XFS_IO_PROG -c "chattr -x" $SRC_DIR $DST_DIR
83 $here/src/t_mmap_dio $SRC_FILE $DST_FILE \
87 $here/src/t_mmap_dio -b $SRC_FILE $DST_FILE \
88 $1 "buffered both nondax"
91 # $1 mmap read/write size
102 local mount_option=$1
104 _scratch_mount "$mount_option"
107 # less than page size
108 t_dax_flag_mmap_dio 1024
110 t_dax_flag_mmap_dio `$here/src/feature -s`
111 # bigger sizes, for PMD faults
112 t_dax_flag_mmap_dio $((16 * 1024 * 1024))
113 t_dax_flag_mmap_dio $((64 * 1024 * 1024))
118 # make xfs aligned for PMD fault testing
119 _scratch_mkfs_geom $(_get_hugepagesize) 1 >> $seqres.full 2>&1
121 tsize=$((128 * 1024 * 1024))
123 # mount with dax=inode option
124 do_tests "-o dax=inode"
126 # mount without dax option
127 export MOUNT_OPTIONS=""
131 echo "Silence is golden"