4 # Test that if we have a file F1 with two links, one in a directory A and the
5 # other in directory B, if we remove the link in directory B, move some other
6 # file F2 from directory B into directory C, fsync inode F1, power fail and
7 # remount the filesystem, file F2 exists and is located only in directory C.
9 #-----------------------------------------------------------------------
11 # Copyright (C) 2016 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
43 # get standard environment, filters and checks
48 # real QA test starts here
52 _require_dm_target flakey
56 _scratch_mkfs >>$seqres.full 2>&1
57 _require_metadata_journaling $SCRATCH_DEV
61 # Create our test directories and the file we will later check if it has
62 # disappeared (file bar).
66 touch $SCRATCH_MNT/a/foo
67 ln $SCRATCH_MNT/a/foo $SCRATCH_MNT/b/foo_link
68 touch $SCRATCH_MNT/b/bar
70 # Make sure everything is durably persisted.
73 # Now delete one of the hard links of file foo and move file bar into c/
74 unlink $SCRATCH_MNT/b/foo_link
75 mv $SCRATCH_MNT/b/bar $SCRATCH_MNT/c/
78 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/a/foo
80 echo "Filesystem content before power failure:"
81 ls -R $SCRATCH_MNT/a $SCRATCH_MNT/b $SCRATCH_MNT/c | _filter_scratch
83 # Simulate a power failure / crash and remount the filesystem, so that the
84 # journal/log is replayed.
85 _flakey_drop_and_remount
87 # We expect that after the journal/log was replayed, we no longer have the link
88 # foo_link and file bar was moved from directory b/ to directory c/.
89 echo "Filesystem content after power failure:"
90 # Must match what we had before the power failure.
91 ls -R $SCRATCH_MNT/a $SCRATCH_MNT/b $SCRATCH_MNT/c | _filter_scratch