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/cli_root/zpool_trim/zpool_trim.kshlib 24 25# 26# DESCRIPTION: 27# Trimming can be performed multiple times 28# 29# STRATEGY: 30# 1. Create a pool with a single disk. 31# 2. Trim the entire pool. 32# 3. Verify trimming is reset (status, offset, and action date). 33# 4. Repeat steps 2 and 3 with the existing pool. 34# 35 36DISK1=${DISKS%% *} 37 38log_must zpool create -f $TESTPOOL $DISK1 39 40typeset action_date="none" 41for n in {1..3}; do 42 log_must zpool trim -r 2G $TESTPOOL 43 log_mustnot eval "trim_prog_line $TESTPOOL $DISK1 | grep complete" 44 45 [[ "$(trim_progress $TESTPOOL $DISK1)" -lt "100" ]] || 46 log_fail "Trimming progress wasn't reset" 47 48 new_action_date="$(trim_prog_line $TESTPOOL $DISK1 | \ 49 sed 's/.*ed at \(.*\)).*/\1/g')" 50 [[ "$action_date" != "$new_action_date" ]] || 51 log_fail "Trimming action date wasn't reset" 52 action_date=$new_action_date 53 54 while [[ "$(trim_progress $TESTPOOL $DISK1)" -lt "100" ]]; do 55 progress="$(trim_progress $TESTPOOL $DISK1)" 56 sleep 0.5 57 [[ "$progress" -le "$(trim_progress $TESTPOOL $DISK1)" ]] || 58 log_fail "Trimming progress regressed" 59 done 60 61 log_must eval "trim_prog_line $TESTPOOL $DISK1 | grep complete" 62 sleep 1 63done 64 65log_pass "Trimming multiple times performs as expected" 66