summaryrefslogtreecommitdiff
path: root/tests/generic/441
blob: 85f29a3a8a747d5ca8f03e94d6a47b74b1f5100f (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2017, Jeff Layton <jlayton@redhat.com>
#
# FS QA Test No. 441
#
# Open a file several times, write to it, fsync on all fds and make sure that
# they all return 0. Change the device to start throwing errors. Write again
# on all fds and fsync on all fds. Ensure that we get errors on all of them.
# Then fsync on all one last time and verify that all return 0.
#
. ./common/preamble
_begin_fstest auto quick eio

# Override the default cleanup function.
_cleanup()
{
	cd /
	rm -rf $tmp.* $testdir
	_dmerror_cleanup
}

# Import common functions.
. ./common/filter
. ./common/dmerror

# real QA test starts here
_require_scratch

# Generally, we want to avoid journal errors on the extended testcase. Only
# unset the -s flag if we have a logdev
sflag='-s'
case $FSTYP in
	btrfs)
		_notrun "btrfs has a specialized test for this"
		;;
	ext3|ext4|xfs|bcachefs)
		# Do the more thorough test if we have a logdev
		_has_logdev && sflag=''
		;;
	*)
		;;
esac

_require_dm_target error
_require_test_program fsync-err
_require_test_program dmerror

# Disable the scratch rt device to avoid test failures relating to the rt
# bitmap consuming all the free space in our small data device.
unset SCRATCH_RTDEV

echo "Format and mount"
_scratch_mkfs > $seqres.full 2>&1
_dmerror_init no_log
_dmerror_mount

_require_fs_space $SCRATCH_MNT 65536

testfile=$SCRATCH_MNT/fsync-err-test

echo "$here/src/fsync-err $sflag -d $here/src/dmerror $testfile" >> $seqres.full
$here/src/fsync-err $sflag -d $here/src/dmerror $testfile

# success, all done
_dmerror_load_working_table
_dmerror_unmount
_dmerror_cleanup

# fs may be corrupt after this -- attempt to repair it
_repair_scratch_fs >> $seqres.full

status=0
exit