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/cli_root/zpool_trim/zpool_trim.kshlib
27 # Trimming automatically resumes across import/export.
30 # 1. Create a one-disk pool.
31 # 2. Start trimming and verify that trimming is active.
34 # 5. Verify that trimming resumes and progress does not regress.
35 # 6. Suspend trimming.
36 # 7. Repeat steps 3-4.
37 # 8. Verify that progress does not regress but trimming is still suspended.
42 if poolexists $TESTPOOL; then
43 destroy_pool $TESTPOOL
46 if [[ -d "$TESTDIR" ]]; then
51 LARGEFILE="$TESTDIR/largefile"
53 log_must mkdir "$TESTDIR"
54 log_must truncate -s 10G "$LARGEFILE"
55 log_must zpool create -f $TESTPOOL $LARGEFILE
57 log_must zpool trim -r 256M $TESTPOOL
60 progress="$(trim_progress $TESTPOOL $LARGEFILE)"
61 [[ -z "$progress" ]] && log_fail "Trimming did not start"
63 log_must zpool export $TESTPOOL
64 log_must zpool import -d $TESTDIR $TESTPOOL
66 new_progress="$(trim_progress $TESTPOOL $LARGEFILE)"
67 [[ -z "$new_progress" ]] && log_fail "Trimming did not restart after import"
69 [[ "$progress" -le "$new_progress" ]] || \
70 log_fail "Trimming lost progress after import"
71 log_mustnot eval "trim_prog_line $TESTPOOL $LARGEFILE | grep suspended"
73 log_must zpool trim -s $TESTPOOL $LARGEFILE
74 action_date="$(trim_prog_line $TESTPOOL $LARGEFILE | \
75 sed 's/.*ed at \(.*\)).*/\1/g')"
76 log_must zpool export $TESTPOOL
77 log_must zpool import -d $TESTDIR $TESTPOOL
78 new_action_date=$(trim_prog_line $TESTPOOL $LARGEFILE | \
79 sed 's/.*ed at \(.*\)).*/\1/g')
80 [[ "$action_date" != "$new_action_date" ]] && \
81 log_fail "Trimming action date did not persist across export/import"
83 [[ "$new_progress" -le "$(trim_progress $TESTPOOL $LARGEFILE)" ]] || \
84 log_fail "Trimming lost progress after import"
86 log_must eval "trim_prog_line $TESTPOOL $LARGEFILE | grep suspended"
88 log_pass "Trimming retains state as expected across export/import"