2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
7 # Test that if we move a file from a directory B to a directory A, replace
8 # directory B with directory A, fsync the file and then power fail, after
9 # mounting the filesystem the file has a single parent, named B and there
10 # is no longer any directory with the name A.
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
34 _require_dm_target flakey
38 _scratch_mkfs >>$seqres.full 2>&1
39 _require_metadata_journaling $SCRATCH_DEV
43 # Create our test directories and file.
44 mkdir $SCRATCH_MNT/testdir
45 mkdir $SCRATCH_MNT/testdir/A
46 mkdir $SCRATCH_MNT/testdir/B
47 touch $SCRATCH_MNT/testdir/B/bar
49 # Make sure everything done so far is durably persisted.
52 # Now move our file bar from directory B to directory A and then replace
53 # directory B with directory A, also renaming directory A to B. Finally
55 mv $SCRATCH_MNT/testdir/B/bar $SCRATCH_MNT/testdir/A/bar
56 mv -T $SCRATCH_MNT/testdir/A $SCRATCH_MNT/testdir/B
57 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/B/bar
59 # Simulate a power failure and mount the filesystem. We expect file bar
60 # to exist and have a single parent directory, named B, and that no
61 # directory named A exists.
62 _flakey_drop_and_remount
64 echo "Filesystem content after power failure:"
65 ls -R $SCRATCH_MNT/testdir | _filter_scratch