xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / generic / 104
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. 104
6 #
7 # Test that if we add hard links (in the same directory) to two files and then
8 # fsync only one of the files, after the fsync log/journal is replayed all the
9 # links exist and the filesystem metadata (directory and file inodes) is in a
10 # consistent state.
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         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28 . ./common/dmflakey
29
30 # real QA test starts here
31 _supported_fs generic
32 _require_scratch
33 _require_hardlinks
34 _require_dm_target flakey
35
36 rm -f $seqres.full
37
38 _scratch_mkfs >>$seqres.full 2>&1
39 _require_metadata_journaling $SCRATCH_DEV
40 _init_flakey
41 _mount_flakey
42
43 # Create our test directory and files.
44 mkdir $SCRATCH_MNT/testdir
45 touch $SCRATCH_MNT/testdir/foo
46 touch $SCRATCH_MNT/testdir/bar
47
48 # Make sure everything done so far is durably persisted.
49 sync
50
51 # Create one hard link for file foo and another one for file bar. After that
52 # fsync only the file bar.
53 ln $SCRATCH_MNT/testdir/bar $SCRATCH_MNT/testdir/bar_link
54 ln $SCRATCH_MNT/testdir/foo $SCRATCH_MNT/testdir/foo_link
55 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/bar
56
57 _flakey_drop_and_remount
58
59 # Now verify both our files have a link count of 2.
60 echo "Link count for file foo: $(stat -c %h $SCRATCH_MNT/testdir/foo)"
61 echo "Link count for file bar: $(stat -c %h $SCRATCH_MNT/testdir/bar)"
62
63 # We should be able to remove all the links of our files in testdir, and after
64 # that the parent directory should become empty and therefore possible to
65 # remove it.
66 rm -f $SCRATCH_MNT/testdir/*
67 rmdir $SCRATCH_MNT/testdir
68
69 _unmount_flakey
70
71 # The fstests framework will call fsck against our filesystem which will verify
72 # that all metadata is in a consistent state.
73
74 status=0
75 exit