2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
7 # Test that if we have a file F1 with two links, one in a directory A and the
8 # other in directory B, if we remove the link in directory B, move some other
9 # file F2 from directory B into directory C, fsync inode F1, power fail and
10 # remount the filesystem, file F2 exists and is located only in directory C.
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
26 # get standard environment, filters and checks
31 # 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 directories and the file we will later check if it has
45 # disappeared (file bar).
49 touch $SCRATCH_MNT/a/foo
50 ln $SCRATCH_MNT/a/foo $SCRATCH_MNT/b/foo_link
51 touch $SCRATCH_MNT/b/bar
53 # Make sure everything is durably persisted.
56 # Now delete one of the hard links of file foo and move file bar into c/
57 unlink $SCRATCH_MNT/b/foo_link
58 mv $SCRATCH_MNT/b/bar $SCRATCH_MNT/c/
61 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/a/foo
63 echo "Filesystem content before power failure:"
64 ls -R $SCRATCH_MNT/a $SCRATCH_MNT/b $SCRATCH_MNT/c | _filter_scratch
66 # Simulate a power failure / crash and remount the filesystem, so that the
67 # journal/log is replayed.
68 _flakey_drop_and_remount
70 # We expect that after the journal/log was replayed, we no longer have the link
71 # foo_link and file bar was moved from directory b/ to directory c/.
72 echo "Filesystem content after power failure:"
73 # Must match what we had before the power failure.
74 ls -R $SCRATCH_MNT/a $SCRATCH_MNT/b $SCRATCH_MNT/c | _filter_scratch