blob: cb158ba56d3bbceff9aa31906bc6a7a485530818 (
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
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2018 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test No. 501
#
# Test that if we do a buffered write to a file, fsync it, clone a range from
# another file into our file that overlaps the previously written range, fsync
# the file again and then power fail, after we mount again the filesystem, no
# file data was lost or corrupted.
#
. ./common/preamble
_begin_fstest auto quick clone log
# Override the default cleanup function.
_cleanup()
{
_cleanup_flakey
cd /
rm -f $tmp.*
}
# Import common functions.
. ./common/filter
. ./common/reflink
. ./common/dmflakey
# real QA test starts here
_supported_fs generic
_require_scratch_reflink
_require_dm_target flakey
_scratch_mkfs >>$seqres.full 2>&1
_require_metadata_journaling $SCRATCH_DEV
_init_flakey
_mount_flakey
_require_congruent_file_oplen $SCRATCH_MNT 2097152
# Use file sizes and offsets/lengths for the clone operation that are multiples
# of 64Kb, so that the test works on machine with any page size.
$XFS_IO_PROG -f -s -c "pwrite -S 0x18 0 2M" $SCRATCH_MNT/foo >>$seqres.full
$XFS_IO_PROG -f -s -c "pwrite -S 0x20 0 20M" $SCRATCH_MNT/bar >>$seqres.full
# We clone from file foo into a range of file bar that overlaps the existing
# extent at file bar. The clone operation must also extend the size of file bar.
# Note: in order to trigger the original bug on btrfs, the destination file size
# must be at least 16Mb and the destination file must have been fsynced before.
$XFS_IO_PROG -c "reflink ${SCRATCH_MNT}/foo 0 19M 2M" \
-c "fsync" \
$SCRATCH_MNT/bar >>$seqres.full
echo "File bar digest before power failure:"
md5sum $SCRATCH_MNT/bar | _filter_scratch
# Simulate a power failure and mount the filesystem to check that no file data
# was lost or corrupted.
_flakey_drop_and_remount
echo "File bar digest after power failure:"
md5sum $SCRATCH_MNT/bar | _filter_scratch
_unmount_flakey
_cleanup_flakey
status=0
exit
|