blob: 6b83a1eede8ede3bf13eaa378698d706d9a12323 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#!/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/cli_root/zpool_trim/zpool_trim.kshlib
#
# DESCRIPTION:
# Verify 'zpool trim -r <rate>' rate limiting.
#
# STRATEGY:
# 1. Create a pool on a single disk.
# 2. Manually TRIM the pool with rate limiting.
# 3. Verify the TRIM can be suspended.
# 4. Restart the TRIM and verify the rate is preserved.
#
# NOTE: The tolerances and delays used in the test below are intentionally
# set be to fairly large since we are capping the maximum trim rate. The
# actual trim rate can be lower. The critical thing is that the trim rate
# is limited, the rate is preserved when resuming, and it can be changed.
#
function cleanup
{
if poolexists $TESTPOOL; then
destroy_pool $TESTPOOL
fi
if [[ -d "$TESTDIR" ]]; then
rm -rf "$TESTDIR"
fi
}
log_onexit cleanup
LARGEFILE="$TESTDIR/largefile"
log_must mkdir "$TESTDIR"
log_must truncate -s 10G "$LARGEFILE"
log_must zpool create -f $TESTPOOL "$LARGEFILE"
# Start trimming at 200M/s for 5 seconds (approximately 10% of the pool)
log_must zpool trim -r 200M $TESTPOOL
log_must sleep 4
progress=$(trim_progress $TESTPOOL $LARGEFILE)
log_must zpool trim -s $TESTPOOL
log_must eval "trim_prog_line $TESTPOOL $LARGEFILE | grep suspended"
log_must within_tolerance 10 $progress 5
# Resuming trimming at 200M/s for 5 seconds (approximately 20% of the pool)
log_must zpool trim $TESTPOOL
log_must sleep 4
progress=$(trim_progress $TESTPOOL $LARGEFILE)
log_must zpool trim -s $TESTPOOL
log_must eval "trim_prog_line $TESTPOOL $LARGEFILE | grep suspended"
log_must within_tolerance 20 $progress 10
# Increase trimming to 600M/s for 5 seconds (approximately 50% of the pool)
log_must zpool trim -r 600M $TESTPOOL
log_must sleep 4
progress=$(trim_progress $TESTPOOL $LARGEFILE)
log_must zpool trim -s $TESTPOOL
log_must eval "trim_prog_line $TESTPOOL $LARGEFILE | grep suspended"
log_must within_tolerance 50 $progress 15
# Set maximum trim rate for 5 seconds (100% of the pool)
log_must zpool trim -r 1T $TESTPOOL
log_must sleep 4
progress=$(trim_progress $TESTPOOL $LARGEFILE)
log_must eval "trim_prog_line $TESTPOOL $LARGEFILE | grep complete"
log_must within_tolerance 100 $progress 0
log_pass "Manual TRIM rate throttles as expected"
|