summaryrefslogtreecommitdiff
path: root/tests/generic/498
blob: 5ba213999ba63667440cfa423618cd707d1d649b (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test No. 498
#
# Test that if we create a new hard link for a file which was previously
# fsync'ed, fsync a parent directory of the new hard link and power fail,
# the parent directory exists after mounting the filesystem again.
#
. ./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
_init_flakey
_mount_flakey

mkdir $SCRATCH_MNT/A
mkdir $SCRATCH_MNT/B
mkdir $SCRATCH_MNT/A/C
touch $SCRATCH_MNT/B/foo
$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/B/foo
# It is important the new hard link is located in a hierarchy of new directories
# (not yet persisted).
ln $SCRATCH_MNT/B/foo $SCRATCH_MNT/A/C/foo
$XFS_IO_PROG -c "fsync" $SCRATCH_MNT/A

# Simulate a power failure and mount the filesystem to check that what we
# explicitly fsync'ed exists.
_flakey_drop_and_remount

[ -d $SCRATCH_MNT/A ] || echo "directory A missing"
[ -f $SCRATCH_MNT/B/foo ] || echo "file B/foo is missing"

_unmount_flakey

echo "Silence is golden"
status=0
exit