ZTS: Enable punch-hole tests on FreeBSD
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Signed-off-by: Ka Ho Ng <khng@FreeBSD.org> Sponsored-by: The FreeBSD Foundation Closes #12458
This commit is contained in:
parent
74bba85423
commit
ed064ed596
|
@ -603,6 +603,10 @@ tags = ['functional', 'delegate']
|
|||
tests = ['exec_001_pos', 'exec_002_neg']
|
||||
tags = ['functional', 'exec']
|
||||
|
||||
[tests/functional/fallocate]
|
||||
tests = ['fallocate_punch-hole']
|
||||
tags = ['functional', 'fallocate']
|
||||
|
||||
[tests/functional/features/async_destroy]
|
||||
tests = ['async_destroy_001_pos']
|
||||
tags = ['functional', 'features', 'async_destroy']
|
||||
|
|
|
@ -94,7 +94,7 @@ tests = ['events_001_pos', 'events_002_pos', 'zed_rc_filter', 'zed_fd_spill']
|
|||
tags = ['functional', 'events']
|
||||
|
||||
[tests/functional/fallocate:Linux]
|
||||
tests = ['fallocate_prealloc', 'fallocate_punch-hole']
|
||||
tests = ['fallocate_prealloc']
|
||||
tags = ['functional', 'fallocate']
|
||||
|
||||
[tests/functional/fault:Linux]
|
||||
|
|
|
@ -127,6 +127,13 @@ fio_reason = 'Fio v2.3 or newer required'
|
|||
#
|
||||
trim_reason = 'DISKS must support discard (TRIM/UNMAP)'
|
||||
|
||||
#
|
||||
# Some tests on FreeBSD require the fspacectl(2) system call and the
|
||||
# truncate(1) utility supporting the -d option. The system call was first
|
||||
# introduced in FreeBSD version 1400032.
|
||||
#
|
||||
fspacectl_reason = 'fspacectl(2) and truncate -d support required'
|
||||
|
||||
#
|
||||
# Some tests are not applicable to a platform or need to be updated to operate
|
||||
# in the manor required by the platform. Any tests which are skipped for this
|
||||
|
@ -225,6 +232,7 @@ maybe = {
|
|||
'cli_root/zpool_trim/setup': ['SKIP', trim_reason],
|
||||
'cli_root/zpool_upgrade/zpool_upgrade_004_pos': ['FAIL', '6141'],
|
||||
'delegate/setup': ['SKIP', exec_reason],
|
||||
'fallocate/fallocate_punch-hole': ['SKIP', fspacectl_reason],
|
||||
'history/history_004_pos': ['FAIL', '7026'],
|
||||
'history/history_005_neg': ['FAIL', '6680'],
|
||||
'history/history_006_neg': ['FAIL', '5657'],
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
# Copyright (c) 2017, Lawrence Livermore National Security LLC.
|
||||
# Copyright (c) 2017, Datto Inc. All rights reserved.
|
||||
# Copyright (c) 2017, Open-E Inc. All rights reserved.
|
||||
# Copyright (c) 2021, The FreeBSD Foundation.
|
||||
# Use is subject to license terms.
|
||||
#
|
||||
|
||||
|
@ -4218,6 +4219,25 @@ function get_arcstat # stat
|
|||
esac
|
||||
}
|
||||
|
||||
function punch_hole # offset length file
|
||||
{
|
||||
typeset offset=$1
|
||||
typeset length=$2
|
||||
typeset file=$3
|
||||
|
||||
case $(uname) in
|
||||
FreeBSD)
|
||||
truncate -d -o $offset -l $length "$file"
|
||||
;;
|
||||
Linux)
|
||||
fallocate --punch-hole --offset $offset --length $length "$file"
|
||||
;;
|
||||
*)
|
||||
false
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#
|
||||
# Wait for the specified arcstat to reach non-zero quiescence.
|
||||
# If echo is 1 echo the value after reaching quiescence, otherwise
|
||||
|
|
|
@ -22,13 +22,14 @@
|
|||
|
||||
#
|
||||
# Copyright (c) 2020 by Lawrence Livermore National Security, LLC.
|
||||
# Copyright (c) 2021 by The FreeBSD Foundation.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Test `fallocate --punch-hole`
|
||||
# Test hole-punching functionality
|
||||
#
|
||||
# STRATEGY:
|
||||
# 1. Create a dense file
|
||||
|
@ -37,6 +38,20 @@
|
|||
|
||||
verify_runnable "global"
|
||||
|
||||
#
|
||||
# Prior to __FreeBSD_version 1400032 there are no mechanism to punch hole in a
|
||||
# file on FreeBSD. truncate -d support is required to call fspacectl(2) on
|
||||
# behalf of the script.
|
||||
#
|
||||
if is_freebsd; then
|
||||
if [[ $(uname -K) -lt 1400032 ]]; then
|
||||
log_unsupported "Requires fspacectl(2) support on FreeBSD"
|
||||
fi
|
||||
if truncate -d 2>&1 | grep "illegal option" > /dev/null; then
|
||||
log_unsupported "Requires truncate(1) -d support on FreeBSD"
|
||||
fi
|
||||
fi
|
||||
|
||||
FILE=$TESTDIR/$TESTFILE0
|
||||
BLKSZ=$(get_prop recordsize $TESTPOOL)
|
||||
|
||||
|
@ -74,23 +89,21 @@ log_must file_write -o create -f $FILE -b $BLKSZ -c 8
|
|||
log_must check_disk_size $((131072 * 8))
|
||||
|
||||
# Punch a hole for the first full block.
|
||||
log_must fallocate --punch-hole --offset 0 --length $BLKSZ $FILE
|
||||
log_must punch_hole 0 $BLKSZ $FILE
|
||||
log_must check_disk_size $((131072 * 7))
|
||||
|
||||
# Partially punch a hole in the second block.
|
||||
log_must fallocate --punch-hole --offset $BLKSZ --length $((BLKSZ / 2)) $FILE
|
||||
log_must punch_hole $BLKSZ $((BLKSZ / 2)) $FILE
|
||||
log_must check_disk_size $((131072 * 7))
|
||||
|
||||
# Punch a hole which overlaps the third and forth block.
|
||||
log_must fallocate --punch-hole --offset $(((BLKSZ * 2) + (BLKSZ / 2))) \
|
||||
--length $((BLKSZ)) $FILE
|
||||
log_must punch_hole $(((BLKSZ * 2) + (BLKSZ / 2))) $((BLKSZ)) $FILE
|
||||
log_must check_disk_size $((131072 * 7))
|
||||
|
||||
# Punch a hole from the fifth block past the end of file. The apparent
|
||||
# file size should not change since --keep-size is implied.
|
||||
apparent_size=$(stat_size $FILE)
|
||||
log_must fallocate --punch-hole --offset $((BLKSZ * 4)) \
|
||||
--length $((BLKSZ * 10)) $FILE
|
||||
log_must punch_hole $((BLKSZ * 4)) $((BLKSZ * 10)) $FILE
|
||||
log_must check_disk_size $((131072 * 4))
|
||||
log_must check_apparent_size $apparent_size
|
||||
|
||||
|
|
Loading…
Reference in New Issue