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