generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 569
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-newer
3 # Copyright (c) 2019, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 569
6 #
7 # Check that we can't modify a file that's an active swap file.
8
9 . ./common/preamble
10 _begin_fstest auto quick rw swap prealloc
11
12 # Override the default cleanup function.
13 _cleanup()
14 {
15         cd /
16         swapoff $testfile
17         rm -rf $tmp.* $testfile
18 }
19
20 # Import common functions.
21 . ./common/filter
22
23 # real QA test starts here
24 _supported_fs generic
25 _require_xfs_io_command "falloc"
26 _require_test_program swapon
27 _require_scratch_swapfile
28 _require_odirect
29
30 _scratch_mkfs > $seqres.full 2>&1
31 _scratch_mount >> $seqres.full 2>&1
32
33 testfile=$SCRATCH_MNT/$seq.swap
34
35 _format_swapfile $testfile 20m > /dev/null
36
37 # Can you modify the swapfile via previously open file descriptors?
38 for verb in 1 2 3 4; do
39         echo "verb $verb"
40         "$here/src/swapon" -v $verb $testfile
41         swapoff $testfile
42 done
43
44 # Now try writing with a new file descriptor.
45 swapon $testfile 2>&1 | _filter_scratch
46
47 # Can we write to it?
48 $XFS_IO_PROG -c 'pwrite -S 0x59 64k 64k' $testfile 2>&1 | _filter_xfs_io_error
49 $XFS_IO_PROG -d -c 'pwrite -S 0x60 64k 64k' $testfile 2>&1 | _filter_xfs_io_error
50 $XFS_IO_PROG -c 'mmap -rw 64k 64k' -c 'mwrite -S 0x61 64k 64k' $testfile
51
52 # Can we change the file size?
53 $XFS_IO_PROG -c 'truncate 18m' $testfile
54
55 # Can you fallocate the file?
56 $XFS_IO_PROG -c 'falloc 0 32m' $testfile
57
58 # We test that you can't reflink, dedupe, or copy_file_range into a swapfile
59 # in other tests.
60
61 # success, all done
62 status=0
63 exit