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']
tags = ['functional', 'events']
[tests/functional/fallocate:Linux]
-tests = ['fallocate_prealloc', 'fallocate_punch-hole']
+tests = ['fallocate_prealloc']
tags = ['functional', 'fallocate']
[tests/functional/fault:Linux]
#
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
'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'],
# 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.
#
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
#
# 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
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)
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