generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 494
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Facebook.  All Rights Reserved.
4 #
5 # FS QA Test 494
6 #
7 # Test truncation/hole punching of an active swapfile.
8 #
9 . ./common/preamble
10 _begin_fstest auto quick swap punch
11
12 . ./common/filter
13
14 _supported_fs generic
15 _require_scratch_swapfile
16 _require_xfs_io_command "fpunch"
17
18 echo "Format and mount"
19 _scratch_mkfs > $seqres.full 2>&1
20 _scratch_mount >> $seqres.full 2>&1
21
22 testdir="$SCRATCH_MNT/test-$seq"
23 mkdir "$testdir"
24
25 blocks=160
26 blksz=65536
27
28 echo "Initialize file"
29 _format_swapfile "$testdir/file1" $((blocks * blksz))
30 swapon "$testdir/file1"
31
32 echo "Try to truncate"
33 $XFS_IO_PROG -c "truncate $blksz" "$testdir/file1"
34
35 echo "Try to punch hole"
36 $XFS_IO_PROG -c "fpunch $blksz $((2 * blksz))" "$testdir/file1"
37
38 echo "Tear it down"
39 swapoff "$testdir/file1"
40
41 status=0
42 exit