2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Fujitsu. All Rights Reserved.
7 # Verify the inheritance behavior of FS_XFLAG_DAX flag in various combinations.
8 # 1) New files and directories automatically inherit FS_XFLAG_DAX from their parent directory.
9 # 2) cp operation make files and directories inherit the FS_XFLAG_DAX from new parent directory.
10 # 3) mv operation make files and directories preserve the FS_XFLAG_DAX from old parent directory.
11 # In addition, setting/clearing FS_XFLAG_DAX flag is not impacted by dax mount options.
14 _begin_fstest auto attr quick dax
16 # Import common functions.
22 _require_xfs_io_command "lsattr" "-v"
24 # Make sure we can call FSGETXATTR on a directory...
25 output="$($XFS_IO_PROG -c "lsattr -v" $TEST_DIR 2>&1)"
26 echo "$output" | grep -q "Inappropriate ioctl for device" && \
27 _notrun "$FSTYP: FSGETXATTR not supported on directories."
29 # If a/ is +x, check that a's new children
31 test_xflag_inheritance1()
34 $XFS_IO_PROG -c "chattr +x" a
41 _check_xflag a/b/c/d 1
46 # If a/ is +x and b/ is -x, check that:
47 # 1) b's new children inherit -x from b/.
48 # 2) a's new children(b/ is old) inherit +x from a/.
49 test_xflag_inheritance2()
52 $XFS_IO_PROG -c "chattr +x" a
59 _check_xflag a/b/c/e 0
66 # If a/ is -x and b/ is +x, check that:
67 # 1) b's new children inherit +x from b/.
68 # 2) a's new children(b/ is old) inherit -x from a/.
69 test_xflag_inheritance3()
72 $XFS_IO_PROG -c "chattr +x" a/b
79 _check_xflag a/b/c/e 1
86 # If a/, c/ are +x and b/ is -x, check that:
87 # 1) c's new children inherit +x from c/.
88 # 2) b's new children(c/ is old) inherit -x from b/.
89 test_xflag_inheritance4()
92 $XFS_IO_PROG -c "chattr +x" a
94 $XFS_IO_PROG -c "chattr -x" a/b
95 mkdir -p a/b/c/d a/b/e
96 touch a/b/c/d/f a/b/e/g
101 _check_xflag a/b/c/d 1
102 _check_xflag a/b/c/d/f 1
104 _check_xflag a/b/e/g 0
109 # If a/ is +x and b/ is -x, check that:
110 # 1) new b/c and b/g inherit -x from b/ by cp.
111 # 2) new a/e inherits +x from a/ by cp.
112 # 3) new b/d preserves +x from a/ by mv.
113 # 4) new a/f and a/h preserve -x from b/ by mv.
114 test_xflag_inheritance5()
117 $XFS_IO_PROG -c "chattr +x" a
118 mkdir -p a/c a/d b/e b/f
142 _scratch_mount "$option"
144 # Make sure the root dir doesn't have FS_XFLAG_DAX set before we start.
145 $XFS_IO_PROG -c "chattr -x" $SCRATCH_MNT &>> $seqres.full
149 for i in $(seq 1 5); do
150 test_xflag_inheritance${i}
159 _scratch_mkfs >> $seqres.full 2>&1
161 # Mount without dax option
162 export MOUNT_OPTIONS=""
165 # Mount with 'dax' or 'dax=always' option if fs supports it.
166 _check_scratch_dax_mountopt "dax" && do_xflag_tests "-o dax"
168 # Mount with 'dax=inode' and 'dax=never' options if fs supports them.
169 if _check_scratch_dax_mountopt "dax=always"; then
170 for dax_option in "dax=inode" "dax=never"; do
171 do_xflag_tests "-o $dax_option"
179 echo "Silence is golden"