summaryrefslogtreecommitdiff
path: root/tests/xfs/789
blob: b966c651193a7e1763b811beb3ae191741c53232 (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2022 Oracle.  All Rights Reserved.
#
# FS QA Test No. 789
#
# Simple tests of the old xfs swapext ioctl

. ./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

# real QA test starts here
_supported_fs xfs
_require_xfs_io_command swapext '-v exchrange'
_require_test

# We can't do any reasonable swapping if the files we're going to create are
# realtime files, the rt extent size is greater than 1 block, and we can't use
# atomic extent swapping to make sure that partially written extents are fully
# swapped.
file_blksz=$(_get_file_block_size $TEST_DIR)
fs_blksz=$(_get_block_size $TEST_DIR)
if (( $file_blksz != $fs_blksz )); then
	_xfs_has_feature $TEST_DIR reflink || \
		_notrun "test requires atomic extent swapping for rextsize=$((file_blksz / fs_blksz))"
fi

dir=$TEST_DIR/test-$seq
mkdir -p $dir

$XFS_IO_PROG -f -c 'pwrite -S 0x58 0 256k -b 1m' $dir/a >> $seqres.full
$XFS_IO_PROG -f -c 'pwrite -S 0x59 0 256k -b 1m' $dir/b >> $seqres.full
$XFS_IO_PROG -f -c 'pwrite -S 0x60 0 256k -b 1m' $dir/c >> $seqres.full
$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 128k -b 1m' $dir/d >> $seqres.full
md5sum $dir/a $dir/b $dir/c $dir/d | _filter_test_dir

# Swap two files that are the same length
echo swap
$XFS_IO_PROG -c "swapext $dir/b" $dir/a
md5sum $dir/a $dir/b | _filter_test_dir

# Try to swap two files that are not the same length
echo fail swap
$XFS_IO_PROG -c "swapext $dir/c" $dir/d
md5sum $dir/c $dir/d | _filter_test_dir

# success, all done
status=0
exit