generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / btrfs / 120
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. 120
6 #
7 # Test that if we delete a snapshot, delete its parent directory, create
8 # another directory with the same name as that parent and then fsync either
9 # the new directory or a file inside the new directory, the fsync succeeds,
10 # the fsync log is replayable and produces a correct result.
11 #
12 . ./common/preamble
13 _begin_fstest auto quick snapshot 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 btrfs
29 _require_scratch
30 _require_dm_target flakey
31
32 populate_testdir()
33 {
34         _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT \
35                 $SCRATCH_MNT/testdir/snap
36         _run_btrfs_util_prog subvolume delete $SCRATCH_MNT/testdir/snap
37         rmdir $SCRATCH_MNT/testdir
38         mkdir $SCRATCH_MNT/testdir
39 }
40
41 _scratch_mkfs >>$seqres.full 2>&1
42 _require_metadata_journaling $SCRATCH_DEV
43 _init_flakey
44 _mount_flakey
45
46 mkdir $SCRATCH_MNT/testdir
47 populate_testdir
48 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir
49 _flakey_drop_and_remount
50
51 echo "Filesystem contents after the first log replay:"
52 ls -R $SCRATCH_MNT | _filter_scratch
53
54 # Now do the same as before but instead of doing an fsync against the directory,
55 # do an fsync against a file inside the directory.
56
57 populate_testdir
58 touch $SCRATCH_MNT/testdir/foobar
59 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/foobar
60 _flakey_drop_and_remount
61
62 echo "Filesystem contents after the second log replay:"
63 ls -R $SCRATCH_MNT | _filter_scratch
64
65 _unmount_flakey
66 status=0
67 exit