generic: test deadlock on O_DIRECT|O_DSYNC
[xfstests-dev.git] / tests / generic / 348
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. 348
6 #
7 # Test creating a symlink, fsync its parent directory, power fail and mount
8 # again the filesystem. After these steps the symlink should exist and its
9 # content must match what we specified when we created it (must not be empty
10 # or point to something else).
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_symlinks
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 mkdir $SCRATCH_MNT/testdir1
46 # Make sure it's durably persisted.
47 sync
48
49 # Create our symlinks and fsync their parent directories.
50 # We test both the case where the parent directory is new (not yet durably
51 # persisted) and where the parent existed long time before.
52 ln -s $SCRATCH_MNT/foo1 $SCRATCH_MNT/testdir1/bar1
53 $XFS_IO_PROG -c fsync $SCRATCH_MNT/testdir1
54 mkdir $SCRATCH_MNT/testdir2
55 ln -s $SCRATCH_MNT/foo2 $SCRATCH_MNT/testdir2/bar2
56 $XFS_IO_PROG -c fsync $SCRATCH_MNT/testdir2
57
58 # After a power failure and mounting again the filesystem, we expect to see the
59 # symlinks and we expect them to point to foo1 and foo2.
60 _flakey_drop_and_remount
61
62 echo "Symlink contents after log replay:"
63 readlink $SCRATCH_MNT/testdir1/bar1 | _filter_scratch
64 readlink $SCRATCH_MNT/testdir2/bar2 | _filter_scratch
65
66 _unmount_flakey
67 status=0
68 exit