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 _begin_fstest auto quick copy_range swap
15 _register_cleanup "_cleanup" BUS
17 # Import common functions.
20 # real QA test starts here
24 _require_xfs_io_command "copy_range"
25 _require_scratch_swapfile
27 _scratch_mkfs >>$seqres.full 2>&1
30 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $SCRATCH_MNT/file >> $seqres.full 2>&1
32 echo swap files return ETXTBUSY
33 _format_swapfile $SCRATCH_MNT/swapfile 16m
34 _swapon_file $SCRATCH_MNT/swapfile
36 $XFS_IO_PROG -f -c "copy_range -l 32k $SCRATCH_MNT/file" $SCRATCH_MNT/swapfile
37 swapoff $SCRATCH_MNT/swapfile