4 # Test that if we add hard links (in the same directory) to two files and then
5 # fsync only one of the files, after the fsync log/journal is replayed all the
6 # links exist and the filesystem metadata (directory and file inodes) is in a
9 #-----------------------------------------------------------------------
11 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
12 # Author: Filipe Manana <fdmanana@suse.com>
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 #-----------------------------------------------------------------------
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment, filters and checks
47 # real QA test starts here
51 _require_dm_target flakey
52 _require_metadata_journaling $SCRATCH_DEV
56 _scratch_mkfs >>$seqres.full 2>&1
60 # Create our test directory and files.
61 mkdir $SCRATCH_MNT/testdir
62 touch $SCRATCH_MNT/testdir/foo
63 touch $SCRATCH_MNT/testdir/bar
65 # Make sure everything done so far is durably persisted.
68 # Create one hard link for file foo and another one for file bar. After that
69 # fsync only the file bar.
70 ln $SCRATCH_MNT/testdir/bar $SCRATCH_MNT/testdir/bar_link
71 ln $SCRATCH_MNT/testdir/foo $SCRATCH_MNT/testdir/foo_link
72 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/bar
74 _flakey_drop_and_remount
76 # Now verify both our files have a link count of 2.
77 echo "Link count for file foo: $(stat -c %h $SCRATCH_MNT/testdir/foo)"
78 echo "Link count for file bar: $(stat -c %h $SCRATCH_MNT/testdir/bar)"
80 # We should be able to remove all the links of our files in testdir, and after
81 # that the parent directory should become empty and therefore possible to
83 rm -f $SCRATCH_MNT/testdir/*
84 rmdir $SCRATCH_MNT/testdir
88 # The fstests framework will call fsck against our filesystem which will verify
89 # that all metadata is in a consistent state.