xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / generic / 106
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. 106
6 #
7 # Test that if we remove one hard link from an inode, evict the inode, fsync the
8 # inode, power fail and then mount the filesystem, the hard link we removed does
9 # not exists anymore and the filesystem metadata is in a consistent state.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         _cleanup_flakey
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/dmflakey
28
29 # real QA test starts here
30 _supported_fs generic
31 _require_scratch
32 _require_hardlinks
33 _require_dm_target flakey
34
35 rm -f $seqres.full
36
37 _scratch_mkfs >>$seqres.full 2>&1
38 _require_metadata_journaling $SCRATCH_DEV
39 _init_flakey
40 _mount_flakey
41
42 # Create our test file with 2 hard links.
43 mkdir $SCRATCH_MNT/testdir
44 touch $SCRATCH_MNT/testdir/foo
45 ln $SCRATCH_MNT/testdir/foo $SCRATCH_MNT/testdir/bar
46
47 # Make sure everything done so far is durably persisted.
48 sync
49
50 # Now remove one of the links, trigger inode eviction and then fsync our
51 # inode.
52 unlink $SCRATCH_MNT/testdir/bar
53 echo 2 > /proc/sys/vm/drop_caches
54 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/foo
55
56 _flakey_drop_and_remount
57
58 # Now verify our directory entries.
59 echo "Entries in testdir:"
60 ls -1 $SCRATCH_MNT/testdir
61
62 # If we remove our inode, its parent should become empty and therefore we should
63 # be able to remove the parent.
64 rm -f $SCRATCH_MNT/testdir/*
65 rmdir $SCRATCH_MNT/testdir
66
67 _unmount_flakey
68
69 # The fstests framework will call fsck against our filesystem which will verify
70 # that all metadata is in a consistent state.
71
72 status=0
73 exit