4 # Test that if we remove one hard link from an inode, evict the inode, fsync the
5 # inode, power fail and then mount the filesystem, the hard link we removed does
6 # not exists anymore and the filesystem metadata is in a consistent state.
8 #-----------------------------------------------------------------------
10 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
11 # Author: Filipe Manana <fdmanana@suse.com>
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
46 # real QA test starts here
50 _require_dm_target flakey
54 _scratch_mkfs >>$seqres.full 2>&1
55 _require_metadata_journaling $SCRATCH_DEV
59 # Create our test file with 2 hard links.
60 mkdir $SCRATCH_MNT/testdir
61 touch $SCRATCH_MNT/testdir/foo
62 ln $SCRATCH_MNT/testdir/foo $SCRATCH_MNT/testdir/bar
64 # Make sure everything done so far is durably persisted.
67 # Now remove one of the links, trigger inode eviction and then fsync our
69 unlink $SCRATCH_MNT/testdir/bar
70 echo 2 > /proc/sys/vm/drop_caches
71 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/foo
73 _flakey_drop_and_remount
75 # Now verify our directory entries.
76 echo "Entries in testdir:"
77 ls -1 $SCRATCH_MNT/testdir
79 # If we remove our inode, its parent should become empty and therefore we should
80 # be able to remove the parent.
81 rm -f $SCRATCH_MNT/testdir/*
82 rmdir $SCRATCH_MNT/testdir
86 # The fstests framework will call fsck against our filesystem which will verify
87 # that all metadata is in a consistent state.