generic: test deadlock on O_DIRECT|O_DSYNC
[xfstests-dev.git] / tests / generic / 554
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 554
6 #
7 # Check that we cannot copy_file_range() to a swapfile
8 #
9 # This is a regression test for kernel commit:
10 #   96e6e8f4a68d ("vfs: add missing checks to copy_file_range")
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 7 15
20
21 _cleanup()
22 {
23         cd /
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # real QA test starts here
32 _supported_os Linux
33 _supported_fs generic
34
35 rm -f $seqres.full
36
37 _require_scratch
38 _require_xfs_io_command "copy_range"
39 _require_scratch_swapfile
40
41 _scratch_mkfs >>$seqres.full 2>&1
42 _scratch_mount
43
44 rm -f $seqres.full
45
46 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $SCRATCH_MNT/file >> $seqres.full 2>&1
47
48 echo swap files return ETXTBUSY
49 _format_swapfile $SCRATCH_MNT/swapfile 16m
50 swapon $SCRATCH_MNT/swapfile
51 $XFS_IO_PROG -f -c "copy_range -l 32k $SCRATCH_MNT/file" $SCRATCH_MNT/swapfile
52 swapoff $SCRATCH_MNT/swapfile
53
54 # success, all done
55 status=0
56 exit