2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
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
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
30 # real QA test starts here
35 _require_dm_target flakey
39 _scratch_mkfs >>$seqres.full 2>&1
40 _require_metadata_journaling $SCRATCH_DEV
44 # Create our test directory and files.
45 mkdir $SCRATCH_MNT/testdir
46 touch $SCRATCH_MNT/testdir/foo
47 touch $SCRATCH_MNT/testdir/bar
49 # Make sure everything done so far is durably persisted.
52 # Create one hard link for file foo and another one for file bar. After that
53 # fsync only the file bar.
54 ln $SCRATCH_MNT/testdir/bar $SCRATCH_MNT/testdir/bar_link
55 ln $SCRATCH_MNT/testdir/foo $SCRATCH_MNT/testdir/foo_link
56 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/bar
58 _flakey_drop_and_remount
60 # Now verify both our files have a link count of 2.
61 echo "Link count for file foo: $(stat -c %h $SCRATCH_MNT/testdir/foo)"
62 echo "Link count for file bar: $(stat -c %h $SCRATCH_MNT/testdir/bar)"
64 # We should be able to remove all the links of our files in testdir, and after
65 # that the parent directory should become empty and therefore possible to
67 rm -f $SCRATCH_MNT/testdir/*
68 rmdir $SCRATCH_MNT/testdir
72 # The fstests framework will call fsck against our filesystem which will verify
73 # that all metadata is in a consistent state.