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
34 _require_dm_target flakey
38 _scratch_mkfs >>$seqres.full 2>&1
39 _require_metadata_journaling $SCRATCH_DEV
43 mkdir -p $SCRATCH_MNT/a/x
44 $XFS_IO_PROG -f -c "pwrite -S 0xaf 0 32K" $SCRATCH_MNT/a/x/foo | _filter_xfs_io
45 $XFS_IO_PROG -f -c "pwrite -S 0xba 0 32K" $SCRATCH_MNT/a/x/bar | _filter_xfs_io
46 # Make sure everything done so far is durably persisted.
49 echo "File digests before power failure:"
50 md5sum $SCRATCH_MNT/a/x/foo | _filter_scratch
51 md5sum $SCRATCH_MNT/a/x/bar | _filter_scratch
53 # Now rename directory x to y and create a new directory that is also named x.
54 # Then fsync the new directory. After a power failure, we must see directories
55 # y and x and directory y has the same files (and with the same content) it had
56 # before the power failure.
57 mv $SCRATCH_MNT/a/x $SCRATCH_MNT/a/y
58 mkdir $SCRATCH_MNT/a/x
59 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/a/x
61 # Simulate a power failure and mount again the filesystem to trigger replay of
63 _flakey_drop_and_remount
65 echo "Directory a/ contents after log replay:"
66 ls -R $SCRATCH_MNT/a | _filter_scratch
68 echo "File digests after log replay:"
69 # Must match what we got before the power failure.
70 md5sum $SCRATCH_MNT/a/y/foo | _filter_scratch
71 md5sum $SCRATCH_MNT/a/y/bar | _filter_scratch