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# Trimming state is preserved across zpool split. 28# 29# STRATEGY: 30# 1. Create a pool with a two-way mirror. 31# 2. Start trimming both devices. 32# 3. Split the pool. Ensure trimming continues on the original. 33# 4. Import the new pool. Ensure trimming resumes on it. 34# 35 36DISK1="$(echo $DISKS | cut -d' ' -f1)" 37DISK2="$(echo $DISKS | cut -d' ' -f2)" 38POOL2="${TESTPOOL}_split" 39 40log_must zpool create -f $TESTPOOL mirror $DISK1 $DISK2 41 42log_must zpool trim $TESTPOOL $DISK1 $DISK2 43orig_prog1="$(trim_progress $TESTPOOL $DISK1)" 44orig_prog2="$(trim_progress $TESTPOOL $DISK2)" 45[[ -z "$orig_prog1" ]] && log_fail "Trimming did not start" 46 47log_must zpool split $TESTPOOL $TESTPOOL1 $DISK2 48 49# Ensure trimming continued as expected on the original pool. 50[[ "$(trim_progress $TESTPOOL $DISK1)" -ge "$orig_prog1" ]] || \ 51 log_fail "Trimming lost progress on original pool" 52log_mustnot eval "trim_prog_line $TESTPOOL $DISK1 | grep suspended" 53 54log_must zpool import $TESTPOOL1 55 56[[ "$(trim_progress $TESTPOOL1 $DISK2)" -ge "$orig_prog2" ]] || \ 57 log_fail "Trimming lost progress on split pool" 58log_mustnot eval "trim_prog_line $TESTPOOL1 $DISK1 | grep suspended" 59 60log_pass "Trimming behaves as expected on zpool split" 61