summaryrefslogtreecommitdiff
path: root/tests/generic/570
blob: 2143c742c4e8840cbe4f50848794f13680b74c93 (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
#! /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. 570
#
# Check that we can't modify a block device that's an active swap device.

. ./common/preamble
_begin_fstest auto quick rw swap

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

# Import common functions.
. ./common/filter

# real QA test starts here
_supported_fs generic
_require_test_program swapon
_require_scratch_nocheck
_require_block_device $SCRATCH_DEV
_require_odirect
# We cannot create swap on a zoned device because it can cause random write IOs
_require_non_zoned_device "$SCRATCH_DEV"
test -e /dev/snapshot && _notrun "userspace hibernation to swap is enabled"

$MKSWAP_PROG "$SCRATCH_DEV" >> $seqres.full

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

swapon $SCRATCH_DEV 2>&1 | _filter_scratch

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

# success, all done
status=0
exit