2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Facebook. All Rights Reserved.
7 # Test truncation/hole punching of an active swapfile.
10 _begin_fstest auto quick swap punch
15 _require_scratch_swapfile
16 _require_xfs_io_command "fpunch"
18 echo "Format and mount"
19 _scratch_mkfs > $seqres.full 2>&1
20 _scratch_mount >> $seqres.full 2>&1
22 testdir="$SCRATCH_MNT/test-$seq"
28 echo "Initialize file"
29 _format_swapfile "$testdir/file1" $((blocks * blksz))
30 swapon "$testdir/file1"
32 echo "Try to truncate"
33 $XFS_IO_PROG -c "truncate $blksz" "$testdir/file1"
35 echo "Try to punch hole"
36 $XFS_IO_PROG -c "fpunch $blksz $((2 * blksz))" "$testdir/file1"
39 swapoff "$testdir/file1"