tests: remove udf/101
[xfstests-dev.git] / tests / generic / 341
1 #! /bin/bash
2 # FSQA Test No. 341
3 #
4 # Test that if we rename a directory, create a new file or directory that has
5 # the old name of our former directory and is a child of the same parent
6 # directory, fsync the new inode, power fail and mount the filesystem, we see
7 # our first directory with the new name and no files under it were lost.
8 #
9 #-----------------------------------------------------------------------
10 #
11 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
12 # Author: Filipe Manana <fdmanana@suse.com>
13 #
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
17 #
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
26 #-----------------------------------------------------------------------
27 #
28
29 seq=`basename $0`
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38         _cleanup_flakey
39         cd /
40         rm -f $tmp.*
41 }
42
43 # get standard environment, filters and checks
44 . ./common/rc
45 . ./common/filter
46 . ./common/dmflakey
47
48 # real QA test starts here
49 _supported_fs generic
50 _supported_os Linux
51 _require_scratch
52 _require_dm_target flakey
53 _require_metadata_journaling $SCRATCH_DEV
54
55 rm -f $seqres.full
56
57 _scratch_mkfs >>$seqres.full 2>&1
58 _init_flakey
59 _mount_flakey
60
61 mkdir -p $SCRATCH_MNT/a/x
62 $XFS_IO_PROG -f -c "pwrite -S 0xaf 0 32K" $SCRATCH_MNT/a/x/foo | _filter_xfs_io
63 $XFS_IO_PROG -f -c "pwrite -S 0xba 0 32K" $SCRATCH_MNT/a/x/bar | _filter_xfs_io
64 # Make sure everything done so far is durably persisted.
65 sync
66
67 echo "File digests before power failure:"
68 md5sum $SCRATCH_MNT/a/x/foo | _filter_scratch
69 md5sum $SCRATCH_MNT/a/x/bar | _filter_scratch
70
71 # Now rename directory x to y and create a new directory that is also named x.
72 # Then fsync the new directory. After a power failure, we must see directories
73 # y and x and directory y has the same files (and with the same content) it had
74 # before the power failure.
75 mv $SCRATCH_MNT/a/x $SCRATCH_MNT/a/y
76 mkdir $SCRATCH_MNT/a/x
77 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/a/x
78
79 # Simulate a power failure and mount again the filesystem to trigger replay of
80 # its journal/log.
81 _flakey_drop_and_remount
82
83 echo "Directory a/ contents after log replay:"
84 ls -R $SCRATCH_MNT/a | _filter_scratch
85
86 echo "File digests after log replay:"
87 # Must match what we got before the power failure.
88 md5sum $SCRATCH_MNT/a/y/foo | _filter_scratch
89 md5sum $SCRATCH_MNT/a/y/bar | _filter_scratch
90
91 _unmount_flakey
92 status=0
93 exit