2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
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.
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
27 # get standard environment, filters and checks
32 # real QA test starts here
37 _require_dm_target flakey
41 _scratch_mkfs >>$seqres.full 2>&1
42 _require_metadata_journaling $SCRATCH_DEV
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
52 # Make sure everything done so far is durably persisted.
55 # Now we remove one of our file's hardlinks in the directory testdir.
56 unlink $SCRATCH_MNT/testdir/foo3
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
62 _flakey_drop_and_remount
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
70 rm -f $SCRATCH_MNT/testdir/*
71 rmdir $SCRATCH_MNT/testdir