2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Red Hat, Inc. All Rights Reserved.
7 # Check that we cannot copy_file_range() to a swapfile
9 # This is a regression test for kernel commit:
10 # 96e6e8f4a68d ("vfs: add missing checks to copy_file_range")
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 7 15
27 # get standard environment, filters and checks
31 # real QA test starts here
38 _require_xfs_io_command "copy_range"
39 _require_scratch_swapfile
41 _scratch_mkfs 2>&1 >> $seqres.full
46 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $SCRATCH_MNT/file >> $seqres.full 2>&1
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