overlay: run unionmount testsuite test cases
[xfstests-dev.git] / tests / generic / 107
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FSQA Test No. 107
6 #
7 # Test that when we have a file with multiple hard links belonging to different
8 # parent directories, if we remove one of those links, fsync the file using one
9 # of its other links (that has a parent directory different from the one we
10 # removed a link from), power fail and then replay the fsync log/journal, the
11 # hard link we removed is not available anymore and all the filesystem metadata
12 # is in a consistent state.
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         _cleanup_flakey
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30 . ./common/dmflakey
31
32 # real QA test starts here
33 _supported_fs generic
34 _supported_os Linux
35 _require_scratch
36 _require_hardlinks
37 _require_dm_target flakey
38
39 rm -f $seqres.full
40
41 _scratch_mkfs >>$seqres.full 2>&1
42 _require_metadata_journaling $SCRATCH_DEV
43 _init_flakey
44 _mount_flakey
45
46 # Create our test directory and file.
47 mkdir $SCRATCH_MNT/testdir
48 touch $SCRATCH_MNT/foo
49 ln $SCRATCH_MNT/foo $SCRATCH_MNT/testdir/foo2
50 ln $SCRATCH_MNT/foo $SCRATCH_MNT/testdir/foo3
51
52 # Make sure everything done so far is durably persisted.
53 sync
54
55 # Now we remove one of our file's hardlinks in the directory testdir.
56 unlink $SCRATCH_MNT/testdir/foo3
57
58 # We now fsync our file using the "foo" link, which has a parent that
59 # is not the directory "testdir".
60 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo
61
62 _flakey_drop_and_remount
63
64 # After the journal/log is replayed we expect to not see the "foo3" link anymore
65 # and we should be able to remove all names in the directory "testdir" and then
66 # remove it (no stale directory entries left after the journal/log replay).
67 echo "Entries in testdir:"
68 ls -1 $SCRATCH_MNT/testdir
69
70 rm -f $SCRATCH_MNT/testdir/*
71 rmdir $SCRATCH_MNT/testdir
72
73 _unmount_flakey
74
75 status=0
76 exit