1*084fd14fSBrian Behlendorf#!/bin/ksh -p 2*084fd14fSBrian Behlendorf# 3*084fd14fSBrian Behlendorf# CDDL HEADER START 4*084fd14fSBrian Behlendorf# 5*084fd14fSBrian Behlendorf# This file and its contents are supplied under the terms of the 6*084fd14fSBrian Behlendorf# Common Development and Distribution License ("CDDL"), version 1.0. 7*084fd14fSBrian Behlendorf# You may only use this file in accordance with the terms of version 8*084fd14fSBrian Behlendorf# 1.0 of the CDDL. 9*084fd14fSBrian Behlendorf# 10*084fd14fSBrian Behlendorf# A full copy of the text of the CDDL should have accompanied this 11*084fd14fSBrian Behlendorf# source. A copy of the CDDL is also available via the Internet at 12*084fd14fSBrian Behlendorf# http://www.illumos.org/license/CDDL. 13*084fd14fSBrian Behlendorf# 14*084fd14fSBrian Behlendorf# CDDL HEADER END 15*084fd14fSBrian Behlendorf# 16*084fd14fSBrian Behlendorf 17*084fd14fSBrian Behlendorf# 18*084fd14fSBrian Behlendorf# Copyright (c) 2019 by Tim Chase. All rights reserved. 19*084fd14fSBrian Behlendorf# Copyright (c) 2019 Lawrence Livermore National Security, LLC. 20*084fd14fSBrian Behlendorf# 21*084fd14fSBrian Behlendorf 22*084fd14fSBrian Behlendorf. $STF_SUITE/include/libtest.shlib 23*084fd14fSBrian Behlendorf. $STF_SUITE/tests/functional/cli_root/zpool_trim/zpool_trim.kshlib 24*084fd14fSBrian Behlendorf 25*084fd14fSBrian Behlendorf# 26*084fd14fSBrian Behlendorf# DESCRIPTION: 27*084fd14fSBrian Behlendorf# Miscellaneous complex sequences of operations function as expected. 28*084fd14fSBrian Behlendorf# 29*084fd14fSBrian Behlendorf# STRATEGY: 30*084fd14fSBrian Behlendorf# 1. Create a pool with a two-way mirror. 31*084fd14fSBrian Behlendorf# 2. Start trimming, offline, export, import, online and verify that 32*084fd14fSBrian Behlendorf# trimming state is preserved / trimming behaves as expected 33*084fd14fSBrian Behlendorf# at each step. 34*084fd14fSBrian Behlendorf# 35*084fd14fSBrian Behlendorf 36*084fd14fSBrian BehlendorfDISK1="$(echo $DISKS | cut -d' ' -f1)" 37*084fd14fSBrian BehlendorfDISK2="$(echo $DISKS | cut -d' ' -f2)" 38*084fd14fSBrian Behlendorf 39*084fd14fSBrian Behlendorflog_must zpool create -f $TESTPOOL mirror $DISK1 $DISK2 40*084fd14fSBrian Behlendorf 41*084fd14fSBrian Behlendorflog_must zpool trim -r 128M $TESTPOOL $DISK1 42*084fd14fSBrian Behlendorflog_must zpool offline $TESTPOOL $DISK1 43*084fd14fSBrian Behlendorfprogress="$(trim_progress $TESTPOOL $DISK1)" 44*084fd14fSBrian Behlendorf[[ -z "$progress" ]] && log_fail "Trimming did not start" 45*084fd14fSBrian Behlendorflog_mustnot eval "trim_prog_line $TESTPOOL $DISK1 | grep suspended" 46*084fd14fSBrian Behlendorf 47*084fd14fSBrian Behlendorflog_must zpool export $TESTPOOL 48*084fd14fSBrian Behlendorflog_must zpool import $TESTPOOL 49*084fd14fSBrian Behlendorf 50*084fd14fSBrian Behlendorfnew_progress="$(trim_progress $TESTPOOL $DISK1)" 51*084fd14fSBrian Behlendorf[[ -z "$new_progress" ]] && log_fail "Trimming did not start after import" 52*084fd14fSBrian Behlendorf[[ "$new_progress" -ge "$progress" ]] || \ 53*084fd14fSBrian Behlendorf log_fail "Trimming lost progress after import" 54*084fd14fSBrian Behlendorflog_mustnot eval "trim_prog_line $TESTPOOL $DISK1 | grep suspended" 55*084fd14fSBrian Behlendorf 56*084fd14fSBrian Behlendorflog_must zpool online $TESTPOOL $DISK1 57*084fd14fSBrian Behlendorfnew_progress="$(trim_progress $TESTPOOL $DISK1)" 58*084fd14fSBrian Behlendorf[[ "$new_progress" -ge "$progress" ]] || \ 59*084fd14fSBrian Behlendorf log_fail "Trimming lost progress after online" 60*084fd14fSBrian Behlendorf 61*084fd14fSBrian Behlendorflog_pass "Trimming behaves as expected at each step of:" \ 62*084fd14fSBrian Behlendorf "trim + offline + export + import + online" 63