summaryrefslogtreecommitdiff
path: root/tests/xfs/790
blob: db6ce741d71a9d46db371be0f9b5ce3841a76fa8 (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2022 Oracle.  All Rights Reserved.
#
# FS QA Test No. 790
#
# Make sure an atomic swapext actually runs to completion even if we shut
# down the filesystem midway through.

. ./common/preamble
_begin_fstest auto quick fiexchange swapext

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

# Import common functions.
. ./common/filter
. ./common/reflink
. ./common/inject

# real QA test starts here
_supported_fs xfs
_require_xfs_io_command swapext '-v exchrange -a'
_require_test_program "punch-alternating"
_require_xfs_io_command startupdate
_require_xfs_io_error_injection "bmap_finish_one"
_require_test

filesnap() {
	echo "$1"
	md5sum $dir/a $dir/b $dir/c | _filter_test_dir
}

dir=$TEST_DIR/test-$seq
mkdir -p $dir
blksz=65536
nrblks=137

# Create two files to swap, and try to fragment the first file.
rm -f $dir/a
_pwrite_byte 0x58 0 $((blksz * nrblks)) $dir/a >> $seqres.full
$here/src/punch-alternating $dir/a
_pwrite_byte 0x59 0 $((blksz * nrblks)) $dir/b >> $seqres.full
_pwrite_byte 0x59 0 $((blksz * nrblks)) $dir/c >> $seqres.full
_pwrite_byte 0x58 0 $((blksz * nrblks)) $dir/a >> $seqres.full
sync

# Inject a bmap error and trigger it via swapext.
filesnap "before commit"
$XFS_IO_PROG -x -c 'inject bmap_finish_one' -c "swapext $dir/b" $dir/a

# Check the file afterwards.
_test_cycle_mount
filesnap "after commit"

# success, all done
status=0
exit