diff options
author | Matt Macy <mmacy@FreeBSD.org> | 2020-08-24 23:31:26 +0000 |
---|---|---|
committer | Matt Macy <mmacy@FreeBSD.org> | 2020-08-24 23:31:26 +0000 |
commit | eda14cbc264d6969b02f2b1994cef11148e914f1 (patch) | |
tree | 54766ce51e901d5ec66cdce87973bb1e210588e1 /sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/autotrim_integrity.ksh | |
parent | 8d9b400f9d02116e528968fa4e7d3c479e326e2a (diff) | |
parent | 3b0ce0e28db46d0403929aba45c682285e1ac217 (diff) | |
download | src-eda14cbc264d6969b02f2b1994cef11148e914f1.tar.gz src-eda14cbc264d6969b02f2b1994cef11148e914f1.zip |
Initial import from vendor-sys branch of openzfs
Notes
Notes:
svn path=/head/; revision=364740
Diffstat (limited to 'sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/autotrim_integrity.ksh')
-rwxr-xr-x | sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/autotrim_integrity.ksh | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/autotrim_integrity.ksh b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/autotrim_integrity.ksh new file mode 100755 index 000000000000..6af877241d0d --- /dev/null +++ b/sys/contrib/openzfs/tests/zfs-tests/tests/functional/trim/autotrim_integrity.ksh @@ -0,0 +1,87 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# +# CDDL HEADER END +# + +# +# Copyright (c) 2019 by Tim Chase. All rights reserved. +# Copyright (c) 2019 Lawrence Livermore National Security, LLC. +# + +. $STF_SUITE/include/libtest.shlib +. $STF_SUITE/tests/functional/trim/trim.kshlib +. $STF_SUITE/tests/functional/trim/trim.cfg + +# +# DESCRIPTION: +# Verify automatic trim pool data integrity. +# +# STRATEGY: +# 1. Create a pool on sparse file vdevs to trim. +# 2. Set autotrim=on to enable asynchronous pool trimming. +# 3. Generate some interesting pool data which can be trimmed. +# 4. Verify trim IOs of the expected type were issued for the pool. +# 5. Verify data integrity of the pool after trim. +# 6. Repeat test for striped, mirrored, and RAIDZ pools. + +verify_runnable "global" + +log_assert "Set 'autotrim=on' pool property verify pool data integrity" + +function cleanup +{ + if poolexists $TESTPOOL; then + destroy_pool $TESTPOOL + fi + + log_must rm -f $TRIM_VDEVS + + log_must set_tunable64 TRIM_EXTENT_BYTES_MIN $trim_extent_bytes_min + log_must set_tunable64 TRIM_TXG_BATCH $trim_txg_batch +} +log_onexit cleanup + +# Minimum trim size is decreased to verify all trim sizes. +typeset trim_extent_bytes_min=$(get_tunable TRIM_EXTENT_BYTES_MIN) +log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 4096 + +# Reduced TRIM_TXG_BATCH to make trimming more frequent. +typeset trim_txg_batch=$(get_tunable TRIM_TXG_BATCH) +log_must set_tunable64 TRIM_TXG_BATCH 8 + +for type in "" "mirror" "raidz" "raidz2" "raidz3"; do + log_must truncate -s 1G $TRIM_VDEVS + + log_must zpool create -f $TESTPOOL $type $TRIM_VDEVS + log_must zpool set autotrim=on $TESTPOOL + + # Add and remove data from the pool in a random fashion in order + # to generate a variety of interesting ranges to be auto trimmed. + for n in {0..10}; do + dir="/$TESTPOOL/autotrim-$((RANDOM % 5))" + filesize=$((4096 + ((RANDOM * 691) % 131072) )) + log_must rm -rf $dir + log_must fill_fs $dir 10 10 $filesize 1 R + zpool sync + done + log_must du -hs /$TESTPOOL + + verify_trim_io $TESTPOOL "ind" 10 + verify_pool $TESTPOOL + + log_must zpool destroy $TESTPOOL + log_must rm -f $TRIM_VDEVS +done + +log_pass "Automatic trim successfully validated" |