2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
7 # Test that when a fsync journal/log exists, if we rename a special file (fifo,
8 # symbolic link or device), create a hard link for it with its old name and then
9 # commit the journal/log, if a power loss happens the filesystem will not fail
10 # to replay the journal/log when it is mounted the next time.
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
36 _require_dm_target flakey
44 _scratch_mkfs >>$seqres.full 2>&1
45 _require_metadata_journaling $SCRATCH_DEV
49 mkdir $SCRATCH_MNT/testdir
52 ln -s xxx $SCRATCH_MNT/testdir/foo
55 mkfifo $SCRATCH_MNT/testdir/foo
58 mknod $SCRATCH_MNT/testdir/foo c 0 0
61 _fail "Invalid file type argument: $file_type"
63 # Make sure everything done so far is durably persisted.
66 # Create a file and fsync it just to create a journal/log. This file
67 # must be in the same directory as our special file "foo".
68 touch $SCRATCH_MNT/testdir/f1
69 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/f1
71 # Rename our special file and then create link that has its old name.
72 mv $SCRATCH_MNT/testdir/foo $SCRATCH_MNT/testdir/bar
73 ln $SCRATCH_MNT/testdir/bar $SCRATCH_MNT/testdir/foo
75 # Create a second file and fsync it. This is just to durably persist the
76 # fsync journal/log which is typically modified by the previous rename
77 # and link operations. This file does not need to be placed in the same
78 # directory as our special file.
80 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/f2
82 # Simulate a power failure and mount the filesystem to check that
83 # replaying the fsync log/journal succeeds, that is the mount operation
85 _flakey_drop_and_remount
94 echo "Silence is golden"