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