]>
Commit | Line | Data |
---|---|---|
1b939560 BB |
1 | #!/bin/ksh -p |
2 | # | |
3 | # CDDL HEADER START | |
4 | # | |
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 | |
8 | # 1.0 of the CDDL. | |
9 | # | |
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. | |
13 | # | |
14 | # CDDL HEADER END | |
15 | # | |
16 | ||
17 | # | |
18 | # Copyright (c) 2019 by Tim Chase. All rights reserved. | |
19 | # Copyright (c) 2019 Lawrence Livermore National Security, LLC. | |
20 | # | |
21 | ||
22 | . $STF_SUITE/include/libtest.shlib | |
23 | . $STF_SUITE/tests/functional/trim/trim.kshlib | |
24 | . $STF_SUITE/tests/functional/trim/trim.cfg | |
25 | ||
26 | # | |
27 | # DESCRIPTION: | |
28 | # Verify automatic trim and manual trim coexist correctly. | |
29 | # | |
30 | # STRATEGY: | |
31 | # 1. Create a pool on sparse file vdevs to trim. | |
32 | # 2. Set autotrim=on to enable asynchronous pool trimming. | |
33 | # 3. Generate some interesting pool data which can be trimmed. | |
34 | # 4. While generating data issue manual trims. | |
35 | # 4. Verify trim IOs of the expected type were issued for the pool. | |
36 | # 5. Verify data integrity of the pool after trim. | |
37 | # 6. Repeat test for striped, mirrored, and RAIDZ pools. | |
38 | ||
39 | verify_runnable "global" | |
40 | ||
41 | log_assert "Set 'autotrim=on', run 'zpool trim' and verify pool data integrity" | |
42 | ||
43 | function cleanup | |
44 | { | |
45 | if poolexists $TESTPOOL; then | |
46 | destroy_pool $TESTPOOL | |
47 | fi | |
48 | ||
49 | log_must rm -f $TRIM_VDEVS | |
50 | ||
2476f103 RM |
51 | log_must set_tunable64 TRIM_EXTENT_BYTES_MIN $trim_extent_bytes_min |
52 | log_must set_tunable64 TRIM_TXG_BATCH $trim_txg_batch | |
1b939560 BB |
53 | } |
54 | log_onexit cleanup | |
55 | ||
56 | # Minimum trim size is decreased to verify all trim sizes. | |
2476f103 RM |
57 | typeset trim_extent_bytes_min=$(get_tunable TRIM_EXTENT_BYTES_MIN) |
58 | log_must set_tunable64 TRIM_EXTENT_BYTES_MIN 4096 | |
1b939560 | 59 | |
2476f103 RM |
60 | # Reduced TRIM_TXG_BATCH to make trimming more frequent. |
61 | typeset trim_txg_batch=$(get_tunable TRIM_TXG_BATCH) | |
62 | log_must set_tunable64 TRIM_TXG_BATCH 8 | |
1b939560 BB |
63 | |
64 | for type in "" "mirror" "raidz" "raidz2" "raidz3"; do | |
65 | log_must truncate -s 1G $TRIM_VDEVS | |
66 | ||
67 | log_must zpool create -f $TESTPOOL $type $TRIM_VDEVS | |
68 | log_must zpool set autotrim=on $TESTPOOL | |
69 | ||
70 | # Add and remove data from the pool in a random fashion in order | |
71 | # to generate a variety of interesting ranges to be auto trimmed. | |
72 | for n in {0..10}; do | |
73 | dir="/$TESTPOOL/autotrim-$((RANDOM % 5))" | |
74 | filesize=$((4096 + ((RANDOM * 691) % 131072) )) | |
75 | log_must rm -rf $dir | |
76 | log_must fill_fs $dir 10 10 $filesize 1 R | |
77 | zpool sync | |
78 | ||
79 | if [[ $((n % 4)) -eq 0 ]]; then | |
2288d419 | 80 | log_must timeout 120 zpool trim -w $TESTPOOL |
1b939560 BB |
81 | fi |
82 | done | |
83 | log_must du -hs /$TESTPOOL | |
84 | ||
85 | verify_trim_io $TESTPOOL "ind" 10 | |
86 | verify_pool $TESTPOOL | |
87 | ||
88 | log_must zpool destroy $TESTPOOL | |
89 | log_must rm -f $TRIM_VDEVS | |
90 | done | |
91 | ||
92 | log_pass "Automatic trim and manual trim coexistence successfully validated" |