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# Cancelling and suspending trim doesn't work if not all specified vdevs
28*084fd14fSBrian Behlendorf# are being trimmed.
29*084fd14fSBrian Behlendorf#
30*084fd14fSBrian Behlendorf# STRATEGY:
31*084fd14fSBrian Behlendorf# 1. Create a three-disk pool.
32*084fd14fSBrian Behlendorf# 2. Start trimming and verify that trimming is active.
33*084fd14fSBrian Behlendorf# 3. Try to cancel and suspend trimming on the non-trimming disks.
34*084fd14fSBrian Behlendorf# 4. Try to re-trim the currently trimming disk.
35*084fd14fSBrian Behlendorf#
36*084fd14fSBrian Behlendorf
37*084fd14fSBrian BehlendorfDISK1=${DISKS%% *}
38*084fd14fSBrian BehlendorfDISK2="$(echo $DISKS | cut -d' ' -f2)"
39*084fd14fSBrian BehlendorfDISK3="$(echo $DISKS | cut -d' ' -f3)"
40*084fd14fSBrian Behlendorf
41*084fd14fSBrian Behlendorflog_must zpool list -v
42*084fd14fSBrian Behlendorflog_must zpool create -f $TESTPOOL $DISK1 $DISK2 $DISK3
43*084fd14fSBrian Behlendorflog_must zpool trim -r 128M $TESTPOOL $DISK1
44*084fd14fSBrian Behlendorf
45*084fd14fSBrian Behlendorf[[ -z "$(trim_progress $TESTPOOL $DISK1)" ]] && \
46*084fd14fSBrian Behlendorf    log_fail "Trim did not start"
47*084fd14fSBrian Behlendorf
48*084fd14fSBrian Behlendorflog_mustnot zpool trim -c $TESTPOOL $DISK2
49*084fd14fSBrian Behlendorflog_mustnot zpool trim -c $TESTPOOL $DISK2 $DISK3
50*084fd14fSBrian Behlendorf
51*084fd14fSBrian Behlendorflog_mustnot zpool trim -s $TESTPOOL $DISK2
52*084fd14fSBrian Behlendorflog_mustnot zpool trim -s $TESTPOOL $DISK2 $DISK3
53*084fd14fSBrian Behlendorf
54*084fd14fSBrian Behlendorflog_mustnot zpool trim $TESTPOOL $DISK1
55*084fd14fSBrian Behlendorf
56*084fd14fSBrian Behlendorflog_pass "Nonsensical trim operations fail"
57