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 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
28 # get standard environment, filters and checks
32 # remove previous $seqres.full before test
38 _require_xfs_io_command "lsattr" "-v"
40 # Make sure we can call FSGETXATTR on a directory...
41 output="$($XFS_IO_PROG -c "lsattr -v" $TEST_DIR 2>&1)"
42 echo "$output" | grep -q "Inappropriate ioctl for device" && \
43 _notrun "$FSTYP: FSGETXATTR not supported on directories."
45 # If a/ is +x, check that a's new children
47 test_xflag_inheritance1()
50 $XFS_IO_PROG -c "chattr +x" a
57 _check_xflag a/b/c/d 1
62 # If a/ is +x and b/ is -x, check that:
63 # 1) b's new children inherit -x from b/.
64 # 2) a's new children(b/ is old) inherit +x from a/.
65 test_xflag_inheritance2()
68 $XFS_IO_PROG -c "chattr +x" a
75 _check_xflag a/b/c/e 0
82 # If a/ is -x and b/ is +x, check that:
83 # 1) b's new children inherit +x from b/.
84 # 2) a's new children(b/ is old) inherit -x from a/.
85 test_xflag_inheritance3()
88 $XFS_IO_PROG -c "chattr +x" a/b
95 _check_xflag a/b/c/e 1
102 # If a/, c/ are +x and b/ is -x, check that:
103 # 1) c's new children inherit +x from c/.
104 # 2) b's new children(c/ is old) inherit -x from b/.
105 test_xflag_inheritance4()
108 $XFS_IO_PROG -c "chattr +x" a
110 $XFS_IO_PROG -c "chattr -x" a/b
111 mkdir -p a/b/c/d a/b/e
112 touch a/b/c/d/f a/b/e/g
117 _check_xflag a/b/c/d 1
118 _check_xflag a/b/c/d/f 1
120 _check_xflag a/b/e/g 0
125 # If a/ is +x and b/ is -x, check that:
126 # 1) new b/c and b/g inherit -x from b/ by cp.
127 # 2) new a/e inherits +x from a/ by cp.
128 # 3) new b/d preserves +x from a/ by mv.
129 # 4) new a/f and a/h preserve -x from b/ by mv.
130 test_xflag_inheritance5()
133 $XFS_IO_PROG -c "chattr +x" a
134 mkdir -p a/c a/d b/e b/f
158 _scratch_mount "$option"
160 # Make sure the root dir doesn't have FS_XFLAG_DAX set before we start.
161 $XFS_IO_PROG -c "chattr -x" $SCRATCH_MNT &>> $seqres.full
165 for i in $(seq 1 5); do
166 test_xflag_inheritance${i}
175 _scratch_mkfs >> $seqres.full 2>&1
177 # Mount without dax option
178 export MOUNT_OPTIONS=""
181 # Mount with 'dax' or 'dax=always' option if fs supports it.
182 _check_scratch_dax_mountopt "dax" && do_xflag_tests "-o dax"
184 # Mount with 'dax=inode' and 'dax=never' options if fs supports them.
185 if _check_scratch_dax_mountopt "dax=always"; then
186 for dax_option in "dax=inode" "dax=never"; do
187 do_xflag_tests "-o $dax_option"
195 echo "Silence is golden"