ext4: Add a test for inline_data vs. DAX inode flag
[xfstests-dev.git] / tests / ext4 / 047
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Fujitsu.  All Rights Reserved.
4 #
5 # FS QA Test 047
6 #
7 # This is a regression test for kernel patch:
8 # commit aa2f77920b74 ("ext4: disallow modifying DAX inode flag if inline_data has been set")
9
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # remove previous $seqres.full before test
30 rm -f $seqres.full
31
32 # real QA test starts here
33 _supported_fs ext4
34 _require_scratch_dax_mountopt "dax=always"
35 _require_dax_iflag
36 _require_scratch_ext4_feature "inline_data"
37
38 TESTFILE=$SCRATCH_MNT/testfile
39
40 _scratch_mkfs_ext4 -O inline_data > $seqres.full 2>&1
41
42 _scratch_mount "-o dax=inode" >> $seqres.full 2>&1
43
44 echo "Need to make some inline data..." > $TESTFILE
45
46 # It's fine to disallow modifying DAX inode flag on the file which
47 # has inline_data flag.
48 if $XFS_IO_PROG -c "chattr +x" $TESTFILE >> $seqres.full 2>&1; then
49         _scratch_cycle_mount "dax=inode"
50         echo 'Append data' >> $TESTFILE
51 fi
52
53 # success, all done
54 echo "Silence is golden"
55 status=0
56 exit