blob: b9efee0d2c2fe3895d09956d31669857bfac3da9 [file] [log] [blame]
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Red Hat, Inc. All Rights Reserved.
#
# FS QA Test No. 554
#
# Check that we cannot copy_file_range() to a swapfile
#
# This is a regression test for kernel commit:
# 96e6e8f4a68d ("vfs: add missing checks to copy_file_range")
#
. ./common/preamble
_begin_fstest auto quick copy_range swap
_register_cleanup "_cleanup" BUS
# Import common functions.
. ./common/filter
# real QA test starts here
_supported_fs generic
_require_scratch
_require_xfs_io_command "copy_range"
_require_scratch_swapfile
_scratch_mkfs >>$seqres.full 2>&1
_scratch_mount
$XFS_IO_PROG -f -c "pwrite -S 0x61 0 128k" $SCRATCH_MNT/file >> $seqres.full 2>&1
echo swap files return ETXTBUSY
_format_swapfile $SCRATCH_MNT/swapfile 16m > /dev/null
_swapon_file $SCRATCH_MNT/swapfile
$XFS_IO_PROG -f -c "copy_range -l 32k $SCRATCH_MNT/file" $SCRATCH_MNT/swapfile
swapoff $SCRATCH_MNT/swapfile
# success, all done
status=0
exit