generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 480
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FSQA Test No. 480
6 #
7 # Test that if we have a file with two hard links in the same parent directory,
8 # then remove of the links, create a new file in the same parent directory and
9 # with the name of the link removed, fsync the new file and have a power loss,
10 # mounting the filesystem succeeds.
11 #
12 . ./common/preamble
13 _begin_fstest auto quick metadata log
14
15 # Override the default cleanup function.
16 _cleanup()
17 {
18         _cleanup_flakey
19         cd /
20         rm -f $tmp.*
21 }
22
23 # Import common functions.
24 . ./common/filter
25 . ./common/dmflakey
26
27 # real QA test starts here
28 _supported_fs generic
29 _require_scratch
30 _require_hardlinks
31 _require_dm_target flakey
32
33 _scratch_mkfs >>$seqres.full 2>&1
34 _require_metadata_journaling $SCRATCH_DEV
35 _init_flakey
36 _mount_flakey
37
38 mkdir $SCRATCH_MNT/testdir
39 touch $SCRATCH_MNT/testdir/foo
40 ln $SCRATCH_MNT/testdir/foo $SCRATCH_MNT/testdir/bar
41
42 # Make sure everything done so far is durably persisted.
43 sync
44
45 # Now remove of the links of our file and create a new file with the same name
46 # and in the same parent directory, and finally fsync this new file.
47 unlink $SCRATCH_MNT/testdir/bar
48 touch $SCRATCH_MNT/testdir/bar
49 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/bar
50
51 # Simulate a power failure and mount the filesystem to check that replaying the
52 # the fsync log/journal succeeds, that is the mount operation does not fail.
53 _flakey_drop_and_remount
54
55 _unmount_flakey
56 _cleanup_flakey
57
58 echo "Silence is golden"
59 status=0
60 exit