generic: test deadlock on O_DIRECT|O_DSYNC
[xfstests-dev.git] / tests / generic / 343
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FSQA Test No. 343
6 #
7 # Test that if we create a hard link for a file F in some directory A, then move
8 # some directory or file B from its parent directory C into directory A, fsync
9 # file F, power fail and mount the filesystem, the directory/file B is located
10 # only at directory A and both links for file F exist.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
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         _cleanup_flakey
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/dmflakey
30
31 # real QA test starts here
32 _supported_fs generic
33 _supported_os Linux
34 _require_scratch
35 _require_hardlinks
36 _require_dm_target flakey
37
38 rm -f $seqres.full
39
40 _scratch_mkfs >>$seqres.full 2>&1
41 _require_metadata_journaling $SCRATCH_DEV
42 _init_flakey
43 _mount_flakey
44
45 # Create our test directories and files.
46 mkdir $SCRATCH_MNT/x
47 mkdir $SCRATCH_MNT/y
48 touch $SCRATCH_MNT/x/foo
49 mkdir $SCRATCH_MNT/y/z
50 touch $SCRATCH_MNT/y/foo2
51
52 # Make sure everything is durably persisted.
53 sync
54
55 # Now add a link to foo at directory x, move directory z and file foo2 from
56 # directory y to directory x and fsync foo's inode. We expect that after a
57 # log replay we see the new link for foo's inode and that z and foo2 are only
58 # located at directory x.
59 ln $SCRATCH_MNT/x/foo $SCRATCH_MNT/x/bar
60 mv $SCRATCH_MNT/y/z $SCRATCH_MNT/x/z
61 mv $SCRATCH_MNT/y/foo2 $SCRATCH_MNT/x/foo2
62 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/x/bar
63 _flakey_drop_and_remount
64
65 echo "Filesystem contents after log replay:"
66 ls -R $SCRATCH_MNT/x $SCRATCH_MNT/y | _filter_scratch
67
68 _unmount_flakey
69 status=0
70 exit