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
34 _require_scratch_dax_mountopt "dax=always"
36 _require_xfs_io_command "lsattr" "-v"
37 _require_xfs_io_command "statx" "-r"
41 local t_file=$SCRATCH_MNT/testfile
45 _check_xflag $t_file 0
46 _check_s_dax $t_file 0
50 $XFS_IO_PROG -c 'chattr +x' $t_file
51 _check_xflag $t_file 1
52 _check_s_dax $t_file 0
54 # One application is using test file and check if S_DAX on
55 # the file doesn't take effect immediately by drop_caches
56 echo 2 > /proc/sys/vm/drop_caches
57 _check_s_dax $t_file 0
61 # No application is using test file and check if S_DAX on
62 # the file takes effect immediately by drop_caches
63 echo 2 > /proc/sys/vm/drop_caches
64 _check_s_dax $t_file 1
70 local t_dir=$SCRATCH_MNT/testdir
71 local t_file=$t_dir/testfile
74 $XFS_IO_PROG -c 'chattr +x' $t_dir
77 _check_xflag $t_file 1
78 _check_s_dax $t_file 1
82 $XFS_IO_PROG -c 'chattr -x' $t_file
83 _check_xflag $t_file 0
84 _check_s_dax $t_file 1
88 # No application is using test file and check if S_DAX on
89 # the file takes effect immediately by umount & mount
90 _scratch_cycle_mount "$option"
91 _check_s_dax $t_file 0
97 local cycle_mount_option=$2
99 _scratch_mount "$mount_option"
103 test_cycle_mount "$cycle_mount_option"
108 _scratch_mkfs >> $seqres.full 2>&1
110 # Mount with dax option
111 do_tests "-o dax=inode" "dax=inode"
113 # Mount without dax option
114 export MOUNT_OPTIONS=""
118 echo "Silence is golden"