5 # This file and its contents are supplied under the terms of the
6 # Common Development and Distribution License ("CDDL"), version 1.0.
7 # You may only use this file in accordance with the terms of version
10 # A full copy of the text of the CDDL should have accompanied this
11 # source. A copy of the CDDL is also available via the Internet at
12 # http://www.illumos.org/license/CDDL.
18 # Copyright (c) 2019 by Tim Chase. All rights reserved.
19 # Copyright (c) 2019 Lawrence Livermore National Security, LLC.
22 . $STF_SUITE/include/libtest.shlib
23 . $STF_SUITE/tests/functional/trim/trim.kshlib
24 . $STF_SUITE/tests/functional/trim/trim.cfg
28 # Verify manual trim pool data integrity.
31 # 1. Create a pool on sparse file vdevs to trim.
32 # 2. Generate some interesting pool data which can be trimmed.
33 # 3. Manually trim the pool.
34 # 4. Verify trim IOs of the expected type were issued for the pool.
35 # 5. Verify data integrity of the pool after trim.
36 # 6. Repeat test for striped, mirrored, and RAIDZ pools.
38 verify_runnable "global"
40 log_assert "Run 'zpool trim' and verify pool data integrity"
44 if poolexists $TESTPOOL; then
45 destroy_pool $TESTPOOL
48 log_must rm -f $TRIM_VDEVS
50 log_must set_tunable64 TRIM_EXTENT_BYTES_MIN $trim_extent_bytes_min
51 log_must set_tunable64 TRIM_TXG_BATCH $trim_txg_batch
55 # Minimum trim size is decreased to verify all trim sizes.
56 typeset trim_extent_bytes_min=$(get_tunable TRIM_EXTENT_BYTES_MIN)
57 log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 4096
59 # Reduced TRIM_TXG_BATCH to make trimming more frequent.
60 typeset trim_txg_batch=$(get_tunable TRIM_TXG_BATCH)
61 log_must set_tunable64 TRIM_TXG_BATCH 8
63 for type in "" "mirror" "raidz" "raidz2" "raidz3"; do
64 log_must truncate -s 1G $TRIM_VDEVS
66 log_must zpool create -f $TESTPOOL $type $TRIM_VDEVS
68 # Add and remove data from the pool in a random fashion in order
69 # to generate a variety of interesting ranges to be manually trimmed.
71 dir="/$TESTPOOL/trim-$((RANDOM % 5))"
72 filesize=$((4096 + ((RANDOM * 691) % 131072) ))
74 log_must fill_fs $dir 10 10 $filesize 1 R
77 log_must du -hs /$TESTPOOL
79 log_must timeout 120 zpool trim -w $TESTPOOL
81 verify_trim_io $TESTPOOL "ind" 10
84 log_must zpool destroy $TESTPOOL
85 log_must rm -f $TRIM_VDEVS
88 log_pass "Manual trim successfully validated"