summaryrefslogtreecommitdiff
path: root/tests/generic/350
blob: d8b2f272b7e1f7e223408f301c9d32248a872488 (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
43
44
45
46
47
48
49
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2016 Oracle, Inc.  All Rights Reserved.
#
# FS QA Test No. 350
#
# Test fallocate(PUNCH_HOLE) on a block device, which should be able to
# zero-TRIM (or equivalent) the range.
#
. ./common/preamble
_begin_fstest blockdev rw punch

_register_cleanup "_cleanup" BUS

# Import common functions.
. ./common/filter
. ./common/scsi_debug

# real QA test starts here
_require_scsi_debug
_require_xfs_io_command "fpunch"

echo "Create and format"
dev=$(_get_scsi_debug_dev 512 512 0 4 "lbpws=1 lbpws10=1")
_pwrite_byte 0x62 0 4m $dev >> $seqres.full

echo "Zero punch"
$XFS_IO_PROG -c "fpunch 512k 1m" $dev

echo "Punch range past EOD"
$XFS_IO_PROG -c "fpunch 3m 4m" $dev

echo "Check contents"
md5sum $dev | sed -e "s|$dev|SCSI_DEBUG_DEV|g"

echo "Punch to MAX_LFS_FILESIZE"
# zod = MAX_LFS_FILESIZE
zod=$(_get_max_lfs_filesize)
$XFS_IO_PROG -c "fpunch 0 $zod" $dev

echo "Check contents"
md5sum $dev | sed -e "s|$dev|SCSI_DEBUG_DEV|g"

echo "Destroy device"
_put_scsi_debug_dev

# success, all done
status=0
exit