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) 2021 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# Miscellaneous complex sequences of operations function as expected. 28# 29# STRATEGY: 30# 1. Create a pool with a two-way mirror. 31# 2. Start trimming, fault, export, import, online and verify along 32# the way that the trim was cancelled and not restarted. 33# 34 35DISK1="$(echo $DISKS | cut -d' ' -f1)" 36DISK2="$(echo $DISKS | cut -d' ' -f2)" 37 38log_must zpool create -f $TESTPOOL mirror $DISK1 $DISK2 39 40log_must zpool trim -r 128M $TESTPOOL $DISK1 41progress="$(trim_progress $TESTPOOL $DISK1)" 42[[ -z "$progress" ]] && log_fail "Trimming did not start" 43 44log_must zpool offline -f $TESTPOOL $DISK1 45log_must check_vdev_state $TESTPOOL $DISK1 "FAULTED" 46log_must eval "zpool status -t $TESTPOOL | grep $DISK1 | grep untrimmed" 47 48log_must zpool export $TESTPOOL 49log_must zpool import $TESTPOOL 50 51# Note: the expected state here is unsupported since the faulted device 52# cannot be checked to determine if it supports TRIM. 53log_must check_vdev_state $TESTPOOL $DISK1 "FAULTED" 54log_must eval "zpool status -t $TESTPOOL | grep $DISK1 | grep unsupported" 55 56log_must zpool online $TESTPOOL $DISK1 57log_must zpool clear $TESTPOOL $DISK1 58log_must check_vdev_state $TESTPOOL $DISK1 "ONLINE" 59log_must eval "zpool status -t $TESTPOOL | grep $DISK1 | grep untrimmed" 60 61log_pass "Trimming behaves as expected at each step of:" \ 62 "trim + fault + export + import + online" 63