generic: test MADV_POPULATE_READ with IO errors
[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 . ./common/preamble
13 _begin_fstest auto quick metadata
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_symlinks
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/testdir1
39 # Make sure it's durably persisted.
40 sync
41
42 # Create our symlinks and fsync their parent directories.
43 # We test both the case where the parent directory is new (not yet durably
44 # persisted) and where the parent existed long time before.
45 ln -s $SCRATCH_MNT/foo1 $SCRATCH_MNT/testdir1/bar1
46 $XFS_IO_PROG -c fsync $SCRATCH_MNT/testdir1
47 mkdir $SCRATCH_MNT/testdir2
48 ln -s $SCRATCH_MNT/foo2 $SCRATCH_MNT/testdir2/bar2
49 $XFS_IO_PROG -c fsync $SCRATCH_MNT/testdir2
50
51 # After a power failure and mounting again the filesystem, we expect to see the
52 # symlinks and we expect them to point to foo1 and foo2.
53 _flakey_drop_and_remount
54
55 echo "Symlink contents after log replay:"
56 readlink $SCRATCH_MNT/testdir1/bar1 | _filter_scratch
57 readlink $SCRATCH_MNT/testdir2/bar2 | _filter_scratch
58
59 _unmount_flakey
60 status=0
61 exit