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
36 _require_dm_target flakey
40 _scratch_mkfs >>$seqres.full 2>&1
41 _require_metadata_journaling $SCRATCH_DEV
45 # Create our test directory and file.
46 mkdir $SCRATCH_MNT/testdir
47 touch $SCRATCH_MNT/foo
48 ln $SCRATCH_MNT/foo $SCRATCH_MNT/testdir/foo2
49 ln $SCRATCH_MNT/foo $SCRATCH_MNT/testdir/foo3
51 # Make sure everything done so far is durably persisted.
54 # Now we remove one of our file's hardlinks in the directory testdir.
55 unlink $SCRATCH_MNT/testdir/foo3
57 # We now fsync our file using the "foo" link, which has a parent that
58 # is not the directory "testdir".
59 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foo
61 _flakey_drop_and_remount
63 # After the journal/log is replayed we expect to not see the "foo3" link anymore
64 # and we should be able to remove all names in the directory "testdir" and then
65 # remove it (no stale directory entries left after the journal/log replay).
66 echo "Entries in testdir:"
67 ls -1 $SCRATCH_MNT/testdir
69 rm -f $SCRATCH_MNT/testdir/*
70 rmdir $SCRATCH_MNT/testdir