2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
7 # Test that if we move one file between directories, fsync the parent directory
8 # of the old directory, power fail and remount the filesystem, the file is not
9 # lost and it's located at the destination directory.
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
30 # real QA test starts here
33 _require_dm_target flakey
37 _scratch_mkfs >>$seqres.full 2>&1
38 _require_metadata_journaling $SCRATCH_DEV
42 # Create our test directories and the file we will later check if it has
44 mkdir -p $SCRATCH_MNT/a/b
46 touch $SCRATCH_MNT/a/b/foo
48 # Make sure everything is durably persisted.
51 # Now move our test file into a new parent directory.
52 mv $SCRATCH_MNT/a/b/foo $SCRATCH_MNT/c/
54 # Create a new file inside the parent directory of the directory where our test
55 # file foo was previously at. This is just to ensure the fsync we do next
56 # against that parent directory actually does something and it's not a noop.
57 touch $SCRATCH_MNT/a/bar
58 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/a
60 echo "Filesystem content before power failure:"
61 ls -R $SCRATCH_MNT/a $SCRATCH_MNT/c | _filter_scratch
63 # Simulate a power failure / crash and remount the filesystem, so that the
64 # journal/log is replayed.
65 _flakey_drop_and_remount
67 # We expect our file foo to exist, have an entry in the new parent
68 # directory (c/) and not have anymore an entry in the old parent directory
70 # The new file named bar should also exist.
71 echo "Filesystem content after power failure:"
72 # Must match what we had before the power failure.
73 ls -R $SCRATCH_MNT/a $SCRATCH_MNT/c | _filter_scratch