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
34 _require_dm_target flakey
38 _scratch_mkfs >>$seqres.full 2>&1
39 _require_metadata_journaling $SCRATCH_DEV
43 # Create our test directories and the file we will later check if it has
45 mkdir -p $SCRATCH_MNT/a/b
47 touch $SCRATCH_MNT/a/b/foo
49 # Make sure everything is durably persisted.
52 # Now move our test file into a new parent directory.
53 mv $SCRATCH_MNT/a/b/foo $SCRATCH_MNT/c/
55 # Create a new file inside the parent directory of the directory where our test
56 # file foo was previously at. This is just to ensure the fsync we do next
57 # against that parent directory actually does something and it's not a noop.
58 touch $SCRATCH_MNT/a/bar
59 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/a
61 echo "Filesystem content before power failure:"
62 ls -R $SCRATCH_MNT/a $SCRATCH_MNT/c | _filter_scratch
64 # Simulate a power failure / crash and remount the filesystem, so that the
65 # journal/log is replayed.
66 _flakey_drop_and_remount
68 # We expect our file foo to exist, have an entry in the new parent
69 # directory (c/) and not have anymore an entry in the old parent directory
71 # The new file named bar should also exist.
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/c | _filter_scratch