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 _begin_fstest auto quick metadata log
14 # Override the default cleanup function.
22 # Import common functions.
26 # real QA test starts here
29 _require_dm_target flakey
31 _scratch_mkfs >>$seqres.full 2>&1
32 _require_metadata_journaling $SCRATCH_DEV
36 # Create our test directories and the file we will later check if it has
38 mkdir -p $SCRATCH_MNT/a/b
40 touch $SCRATCH_MNT/a/b/foo
42 # Make sure everything is durably persisted.
45 # Now move our test file into a new parent directory.
46 mv $SCRATCH_MNT/a/b/foo $SCRATCH_MNT/c/
48 # Create a new file inside the parent directory of the directory where our test
49 # file foo was previously at. This is just to ensure the fsync we do next
50 # against that parent directory actually does something and it's not a noop.
51 touch $SCRATCH_MNT/a/bar
52 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/a
54 echo "Filesystem content before power failure:"
55 ls -R $SCRATCH_MNT/a $SCRATCH_MNT/c | _filter_scratch
57 # Simulate a power failure / crash and remount the filesystem, so that the
58 # journal/log is replayed.
59 _flakey_drop_and_remount
61 # We expect our file foo to exist, have an entry in the new parent
62 # directory (c/) and not have anymore an entry in the old parent directory
64 # The new file named bar should also exist.
65 echo "Filesystem content after power failure:"
66 # Must match what we had before the power failure.
67 ls -R $SCRATCH_MNT/a $SCRATCH_MNT/c | _filter_scratch