aboutsummaryrefslogtreecommitdiffstats
path: root/tests/zfs-tests/include/libtest.shlib
diff options
context:
space:
mode:
authorKa Ho Ng <[email protected]>2021-08-22 23:22:07 +0800
committerBrian Behlendorf <[email protected]>2021-08-30 13:33:32 -0700
commitc3cb57ae47b316122565be37e233bab4c6d1daf9 (patch)
tree452130ebb1d0ce71be00abced3604015d7c29638 /tests/zfs-tests/include/libtest.shlib
parentf3bbeb970e03cfc8e7b2d90702e3f471668b3ef8 (diff)
ZTS: Enable punch-hole tests on FreeBSD
Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Ka Ho Ng <[email protected]> Sponsored-by: The FreeBSD Foundation Closes #12458
Diffstat (limited to 'tests/zfs-tests/include/libtest.shlib')
-rw-r--r--tests/zfs-tests/include/libtest.shlib20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib
index 1dc6881b6..ab0cd5270 100644
--- a/tests/zfs-tests/include/libtest.shlib
+++ b/tests/zfs-tests/include/libtest.shlib
@@ -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.
#
@@ -4194,6 +4195,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