2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
7 # Test that if we rename a directory, create a new file or directory that has
8 # the old name of our former directory and is a child of the same parent
9 # directory, fsync the new inode, power fail and mount the filesystem, we see
10 # our first directory with the new name and no files under it were lost.
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
35 _require_dm_target flakey
39 _scratch_mkfs >>$seqres.full 2>&1
40 _require_metadata_journaling $SCRATCH_DEV
44 mkdir -p $SCRATCH_MNT/a/x
45 $XFS_IO_PROG -f -c "pwrite -S 0xaf 0 32K" $SCRATCH_MNT/a/x/foo | _filter_xfs_io
46 $XFS_IO_PROG -f -c "pwrite -S 0xba 0 32K" $SCRATCH_MNT/a/x/bar | _filter_xfs_io
47 # Make sure everything done so far is durably persisted.
50 echo "File digests before power failure:"
51 md5sum $SCRATCH_MNT/a/x/foo | _filter_scratch
52 md5sum $SCRATCH_MNT/a/x/bar | _filter_scratch
54 # Now rename directory x to y and create a new directory that is also named x.
55 # Then fsync the new directory. After a power failure, we must see directories
56 # y and x and directory y has the same files (and with the same content) it had
57 # before the power failure.
58 mv $SCRATCH_MNT/a/x $SCRATCH_MNT/a/y
59 mkdir $SCRATCH_MNT/a/x
60 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/a/x
62 # Simulate a power failure and mount again the filesystem to trigger replay of
64 _flakey_drop_and_remount
66 echo "Directory a/ contents after log replay:"
67 ls -R $SCRATCH_MNT/a | _filter_scratch
69 echo "File digests after log replay:"
70 # Must match what we got before the power failure.
71 md5sum $SCRATCH_MNT/a/y/foo | _filter_scratch
72 md5sum $SCRATCH_MNT/a/y/bar | _filter_scratch