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# Verify 'zpool trim -d' secure trim. 28# 29# STRATEGY: 30# 1. Create a pool on a single file vdev. 31# 2. Run 'zpool trim -d' to securely TRIM allocated space maps. 32# 3. Verify it fails when using a file vdev. 33# 34# NOTE: Currently secure discard cannot be verified using file vdevs, 35# loopback, or scsi_debug devices. None of which support the feature. 36# It can only be tested using real SSDs which provide support. 37# 38 39function cleanup 40{ 41 if poolexists $TESTPOOL; then 42 destroy_pool $TESTPOOL 43 fi 44 45 if [[ -d "$TESTDIR" ]]; then 46 rm -rf "$TESTDIR" 47 fi 48} 49log_onexit cleanup 50 51LARGESIZE=$((MINVDEVSIZE * 4)) 52LARGEFILE="$TESTDIR/largefile" 53 54log_must mkdir "$TESTDIR" 55log_must truncate -s $LARGESIZE "$LARGEFILE" 56log_must zpool create $TESTPOOL "$LARGEFILE" 57log_mustnot zpool trim -d $TESTPOOL 58 59log_pass "Manual 'zpool trim -d' failed as expected for file vdevs" 60