summaryrefslogtreecommitdiff
path: root/tests/generic/629
blob: dbd7ada84b642c9c1978c4586008e481dbbf27ab (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
79
80
81
82
83
84
85
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2021 Oracle.  All Rights Reserved.
#
# FS QA Test No. 629
#
# Make sure that copy_file_range forces the log out if we open the file with
# O_SYNC or set FS_XFLAG_SYNC on the file.  We test that it actually forced the
# log by using dm-error to shut down the fs without flushing the log and then
# remounting to check file contents.  This is a regression test for commit
# 5ffce3cc22a0 ("xfs: force the log after remapping a synchronous-writes file")

. ./common/preamble
_begin_fstest auto quick rw copy_range eio

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

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

# real QA test starts here
_supported_fs generic
_require_scratch
_require_dm_target error
_require_xfs_io_command "chattr" "s"
_require_xfs_io_command "copy_range"

# Format filesystem and set up quota limits
_scratch_mkfs > $seqres.full
_require_metadata_journaling $SCRATCH_DEV
_dmerror_init
_dmerror_mount

# Test that O_SYNC actually results in file data being written even if the
# fs immediately dies
echo "test o_sync write"
$XFS_IO_PROG -x -f -s -c "pwrite -S 0x58 0 1m -b 1m" $SCRATCH_MNT/0 >> $seqres.full
_dmerror_load_error_table
_dmerror_unmount
_dmerror_load_working_table
_dmerror_mount
md5sum $SCRATCH_MNT/0 | _filter_scratch

# Set up initial files for copy test
$XFS_IO_PROG -f -c 'pwrite -S 0x58 0 1m -b 1m' $SCRATCH_MNT/a >> $seqres.full
touch $SCRATCH_MNT/b
sync

# Test that unaligned copy file range forces dirty data/metadata to disk when
# destination file opened with O_SYNC
echo "test unaligned copy range o_sync"
$XFS_IO_PROG -x -s -c "copy_range -s 13 -d 13 -l 1048550 $SCRATCH_MNT/a" $SCRATCH_MNT/b >> $seqres.full
_dmerror_load_error_table
_dmerror_unmount
_dmerror_load_working_table
_dmerror_mount
md5sum $SCRATCH_MNT/a $SCRATCH_MNT/b | _filter_scratch

# Set up dest file with chattr +S
rm -f $SCRATCH_MNT/b
touch $SCRATCH_MNT/b
chattr +S $SCRATCH_MNT/b
sync

# Test that unaligned copy file range forces dirty data/metadata to disk when
# destination file has the sync iflag set
echo "test unaligned copy range iflag"
$XFS_IO_PROG -x -c "copy_range -s 13 -d 13 -l 1048550 $SCRATCH_MNT/a" $SCRATCH_MNT/b >> $seqres.full
_dmerror_load_error_table
_dmerror_unmount
_dmerror_load_working_table
_dmerror_mount
md5sum $SCRATCH_MNT/a $SCRATCH_MNT/b | _filter_scratch

# success, all done
status=0
exit