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 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
30 _require_scratch_swapfile
31 _require_xfs_io_command "fpunch"
33 echo "Format and mount"
34 _scratch_mkfs > $seqres.full 2>&1
35 _scratch_mount >> $seqres.full 2>&1
37 testdir="$SCRATCH_MNT/test-$seq"
43 echo "Initialize file"
44 _format_swapfile "$testdir/file1" $((blocks * blksz))
45 swapon "$testdir/file1"
47 echo "Try to truncate"
48 $XFS_IO_PROG -c "truncate $blksz" "$testdir/file1"
50 echo "Try to punch hole"
51 $XFS_IO_PROG -c "fpunch $blksz $((2 * blksz))" "$testdir/file1"
54 swapoff "$testdir/file1"