2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
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.
12 _begin_fstest auto quick metadata log
14 # Override the default cleanup function.
21 # Import common functions.
25 # real QA test starts here
29 _require_dm_target flakey
31 _scratch_mkfs >>$seqres.full 2>&1
32 _require_metadata_journaling $SCRATCH_DEV
36 # Create our test file with 2 hard links.
37 mkdir $SCRATCH_MNT/testdir
38 touch $SCRATCH_MNT/testdir/foo
39 ln $SCRATCH_MNT/testdir/foo $SCRATCH_MNT/testdir/bar
41 # Make sure everything done so far is durably persisted.
44 # Now remove one of the links, trigger inode eviction and then fsync our
46 unlink $SCRATCH_MNT/testdir/bar
47 echo 2 > /proc/sys/vm/drop_caches
48 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/foo
50 _flakey_drop_and_remount
52 # Now verify our directory entries.
53 echo "Entries in testdir:"
54 ls -1 $SCRATCH_MNT/testdir
56 # If we remove our inode, its parent should become empty and therefore we should
57 # be able to remove the parent.
58 rm -f $SCRATCH_MNT/testdir/*
59 rmdir $SCRATCH_MNT/testdir
63 # The fstests framework will call fsck against our filesystem which will verify
64 # that all metadata is in a consistent state.