blob: b5589b8139d17a447d74c8028371372cc0900cee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test No. 502
#
# Test that if we have a file with 2 (or more) hard links in the same parent
# directory, rename of the hard links, rename one of the other hard links to
# the old name of the hard link we renamed before, create a new file in the
# same parent directory with the old name of second hard link we renamed, fsync
# fsync this new file and power fail, we will be able to mount again the
# filesystem and the new file and all hard links exist.
#
. ./common/preamble
_begin_fstest auto quick log
# Override the default cleanup function.
_cleanup()
{
_cleanup_flakey
cd /
rm -f $tmp.*
}
# Import common functions.
. ./common/filter
. ./common/dmflakey
# real QA test starts here
_supported_fs generic
_require_scratch
_require_hardlinks
_require_dm_target flakey
_scratch_mkfs >>$seqres.full 2>&1
_require_metadata_journaling $SCRATCH_DEV
if [ $FSTYP = "f2fs" ]; then
export MOUNT_OPTIONS="-o fsync_mode=strict $MOUNT_OPTIONS"
fi
_init_flakey
_mount_flakey
# Create our test file with 2 hard links in the same parent directory.
mkdir $SCRATCH_MNT/testdir
touch $SCRATCH_MNT/testdir/foo
ln $SCRATCH_MNT/testdir/foo $SCRATCH_MNT/testdir/bar
# Make sure everything done so far is durably persisted.
sync
# Now rename the first hard link (foo) to a new name and rename the second hard
# link (bar) to the old name of the first hard link (foo).
mv $SCRATCH_MNT/testdir/foo $SCRATCH_MNT/testdir/qwerty
mv $SCRATCH_MNT/testdir/bar $SCRATCH_MNT/testdir/foo
# Create a new file, in the same parent directory, with the old name of the
# second hard link (bar) and fsync this new file.
touch $SCRATCH_MNT/testdir/bar
$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/testdir/bar
echo "Contents of test directory before the power failure:"
ls -R $SCRATCH_MNT/testdir | _filter_scratch
# Simulate a power failure and mount the filesystem to check that we are able to
# mount it and we have the same files, with the same hard links, that we had
# before the power failure and in the same order.
_flakey_drop_and_remount
echo "Contents of test directory after the power failure:"
ls -R $SCRATCH_MNT/testdir | _filter_scratch
_unmount_flakey
_cleanup_flakey
status=0
exit
|