2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Fujitsu. All Rights Reserved.
6 # Change FS_XFLAG_DAX on an existing file and check if S_DAX on
7 # the file can take effect immediately by the following steps:
8 # 1) Stop all applications which are using the file.
9 # 2) Do drop_caches or umount & mount cycle.
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
26 # get standard environment, filters and checks
30 # remove previous $seqres.full before test
35 _require_scratch_dax_mountopt "dax=always"
37 _require_xfs_io_command "lsattr" "-v"
38 _require_xfs_io_command "statx" "-r"
42 local t_file=$SCRATCH_MNT/testfile
46 _check_xflag $t_file 0
47 _check_s_dax $t_file 0
51 $XFS_IO_PROG -c 'chattr +x' $t_file
52 _check_xflag $t_file 1
53 _check_s_dax $t_file 0
55 # One application is using test file and check if S_DAX on
56 # the file doesn't take effect immediately by drop_caches
57 echo 2 > /proc/sys/vm/drop_caches
58 _check_s_dax $t_file 0
62 # No application is using test file and check if S_DAX on
63 # the file takes effect immediately by drop_caches
64 echo 2 > /proc/sys/vm/drop_caches
65 _check_s_dax $t_file 1
71 local t_dir=$SCRATCH_MNT/testdir
72 local t_file=$t_dir/testfile
75 $XFS_IO_PROG -c 'chattr +x' $t_dir
78 _check_xflag $t_file 1
79 _check_s_dax $t_file 1
83 $XFS_IO_PROG -c 'chattr -x' $t_file
84 _check_xflag $t_file 0
85 _check_s_dax $t_file 1
89 # No application is using test file and check if S_DAX on
90 # the file takes effect immediately by umount & mount
91 _scratch_cycle_mount "$option"
92 _check_s_dax $t_file 0
98 local cycle_mount_option=$2
100 _scratch_mount "$mount_option"
104 test_cycle_mount "$cycle_mount_option"
109 _scratch_mkfs >> $seqres.full 2>&1
111 # Mount with dax option
112 do_tests "-o dax=inode" "dax=inode"
114 # Mount without dax option
115 export MOUNT_OPTIONS=""
119 echo "Silence is golden"