generic: Verify the inheritance behavior of FS_XFLAG_DAX flag in various combinations
[xfstests-dev.git] / tests / generic / 321
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Fusion IO. All Rights Reserved.
4 #
5 # FS QA Test No. 321
6 #
7 # Runs various dir fsync tests to cover fsync'ing directory corner cases.
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 status=1        # failure is the default!
15
16 _cleanup()
17 {
18         _cleanup_flakey
19 }
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 # get standard environment, filters and checks
23 . ./common/rc
24 . ./common/filter
25 . ./common/dmflakey
26
27 # real QA test starts here
28 _supported_fs generic
29 _supported_os Linux
30 _require_scratch_nocheck
31 _require_dm_target flakey
32
33 rm -f $seqres.full
34
35 _clean_working_dir()
36 {
37         _mount_flakey
38         rm -rf $SCRATCH_MNT/foo $SCRATCH_MNT/bar
39         _unmount_flakey
40 }
41
42 # Btrfs wasn't making sure the directory survived fsync
43 _directory_test()
44 {
45         echo "fsync new directory"
46         _mount_flakey
47         mkdir $SCRATCH_MNT/bar
48         $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
49
50         _flakey_drop_and_remount
51
52         _ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }'
53         _unmount_flakey
54         _check_scratch_fs $FLAKEY_DEV
55         [ $? -ne 0 ] && _fatal "fsck failed"
56 }
57
58 # Btrfs was losing a rename into a new directory
59 _rename_test()
60 {
61         echo "rename fsync test"
62         _mount_flakey
63         touch $SCRATCH_MNT/foo
64         mkdir $SCRATCH_MNT/bar
65         $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo
66         mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar/foo
67         $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
68         $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar/foo
69
70         _flakey_drop_and_remount\
71
72         _ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }'
73         _ls_l $SCRATCH_MNT/bar | tail -n +2 | awk '{ print $1, $9 }'
74         _unmount_flakey
75         _check_scratch_fs $FLAKEY_DEV
76         [ $? -ne 0 ] && _fatal "fsck failed"
77 }
78
79 # Btrfs was failing to replay a log when we had a inode with a smaller inode
80 # number that is renamed into a directory with a higher inode number
81 _replay_rename_test()
82 {
83         echo "replay rename fsync test"
84         _mount_flakey
85         touch $SCRATCH_MNT/foo
86         mkdir $SCRATCH_MNT/bar
87         $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo
88         mv $SCRATCH_MNT/foo $SCRATCH_MNT/bar/foo
89         $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar
90
91         # This is to force btrfs to relog the entire inode including the ref so
92         # we are sure to try and replay the ref along with the dir_index item
93         setfattr -n user.foo -v blah $SCRATCH_MNT/bar/foo >> $seqres.full 2>&1
94
95         $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/bar/foo
96
97         _flakey_drop_and_remount
98
99         _ls_l $SCRATCH_MNT | tail -n +2 | awk '{ print $1, $9 }'
100         _ls_l $SCRATCH_MNT/bar | tail -n +2 | awk '{ print $1, $9 }'
101         _unmount_flakey
102 }
103
104 _scratch_mkfs >> $seqres.full 2>&1
105 _require_metadata_journaling $SCRATCH_DEV
106
107 # Create a basic flakey device that will never error out
108 _init_flakey
109
110 _directory_test
111 _clean_working_dir
112 _rename_test
113 _clean_working_dir
114 _replay_rename_test
115
116 status=0
117 exit