summaryrefslogtreecommitdiff
path: root/tests/generic/569
blob: eeaf3f1637f65f241bd967e001e456d1120c6315 (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0-or-newer
# Copyright (c) 2019, Oracle and/or its affiliates.  All Rights Reserved.
#
# FS QA Test No. 569
#
# Check that we can't modify a file that's an active swap file.

. ./common/preamble
_begin_fstest auto quick rw swap prealloc

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

# Import common functions.
. ./common/filter

# real QA test starts here
_supported_fs generic
_require_xfs_io_command "falloc"
_require_test_program swapon
_require_scratch_swapfile
_require_odirect

_scratch_mkfs > $seqres.full 2>&1
_scratch_mount >> $seqres.full 2>&1

testfile=$SCRATCH_MNT/$seq.swap

_format_swapfile $testfile 20m > /dev/null

# Can you modify the swapfile via previously open file descriptors?
for verb in 1 2 3 4; do
	echo "verb $verb"
	"$here/src/swapon" -v $verb $testfile
	swapoff $testfile
done

# Now try writing with a new file descriptor.
swapon $testfile 2>&1 | _filter_scratch

# Can we write to it?
$XFS_IO_PROG -c 'pwrite -S 0x59 64k 64k' $testfile 2>&1 | _filter_xfs_io_error
$XFS_IO_PROG -d -c 'pwrite -S 0x60 64k 64k' $testfile 2>&1 | _filter_xfs_io_error
$XFS_IO_PROG -c 'mmap -rw 64k 64k' -c 'mwrite -S 0x61 64k 64k' $testfile

# Can we change the file size?
$XFS_IO_PROG -c 'truncate 18m' $testfile

# Can you fallocate the file?
$XFS_IO_PROG -c 'falloc 0 32m' $testfile

# We test that you can't reflink, dedupe, or copy_file_range into a swapfile
# in other tests.

# success, all done
status=0
exit