summaryrefslogtreecommitdiff
path: root/tests/generic/494
blob: b41c938d14f47b0781b7134aabfef8811ebc78c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Facebook.  All Rights Reserved.
#
# FS QA Test 494
#
# Test truncation/hole punching of an active swapfile.
#
. ./common/preamble
_begin_fstest auto quick swap punch

. ./common/filter

_supported_fs generic
_require_scratch_swapfile
_require_xfs_io_command "fpunch"

echo "Format and mount"
_scratch_mkfs > $seqres.full 2>&1
_scratch_mount >> $seqres.full 2>&1

testdir="$SCRATCH_MNT/test-$seq"
mkdir "$testdir"

blocks=160
blksz=65536

echo "Initialize file"
_format_swapfile "$testdir/file1" $((blocks * blksz)) > /dev/null
swapon "$testdir/file1"

echo "Try to truncate"
$XFS_IO_PROG -c "truncate $blksz" "$testdir/file1"

echo "Try to punch hole"
$XFS_IO_PROG -c "fpunch $blksz $((2 * blksz))" "$testdir/file1"

echo "Tear it down"
swapoff "$testdir/file1"

status=0
exit