4 # Test that if we move one file between directories, fsync the parent directory
5 # of the old directory, power fail and remount the filesystem, the file is not
6 # lost and it's located at the destination directory.
8 #-----------------------------------------------------------------------
10 # Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved.
11 # Author: Filipe Manana <fdmanana@suse.com>
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment, filters and checks
47 # real QA test starts here
51 _require_dm_target flakey
52 _require_metadata_journaling $SCRATCH_DEV
56 _scratch_mkfs >>$seqres.full 2>&1
60 # Create our test directories and the file we will later check if it has
62 mkdir -p $SCRATCH_MNT/a/b
64 touch $SCRATCH_MNT/a/b/foo
66 # Make sure everything is durably persisted.
69 # Now move our test file into a new parent directory.
70 mv $SCRATCH_MNT/a/b/foo $SCRATCH_MNT/c/
72 # Create a new file inside the parent directory of the directory where our test
73 # file foo was previously at. This is just to ensure the fsync we do next
74 # against that parent directory actually does something and it's not a noop.
75 touch $SCRATCH_MNT/a/bar
76 $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/a
78 echo "Filesystem content before power failure:"
79 ls -R $SCRATCH_MNT/a $SCRATCH_MNT/c | _filter_scratch
81 # Simulate a power failure / crash and remount the filesystem, so that the
82 # journal/log is replayed.
83 _flakey_drop_and_remount
85 # We expect our file foo to exist, have an entry in the new parent
86 # directory (c/) and not have anymore an entry in the old parent directory
88 # The new file named bar should also exist.
89 echo "Filesystem content after power failure:"
90 # Must match what we had before the power failure.
91 ls -R $SCRATCH_MNT/a $SCRATCH_MNT/c | _filter_scratch