1*eda14cbcSMatt Macy#!/bin/ksh -p 2*eda14cbcSMatt Macy# 3*eda14cbcSMatt Macy# CDDL HEADER START 4*eda14cbcSMatt Macy# 5*eda14cbcSMatt Macy# This file and its contents are supplied under the terms of the 6*eda14cbcSMatt Macy# Common Development and Distribution License ("CDDL"), version 1.0. 7*eda14cbcSMatt Macy# You may only use this file in accordance with the terms of version 8*eda14cbcSMatt Macy# 1.0 of the CDDL. 9*eda14cbcSMatt Macy# 10*eda14cbcSMatt Macy# A full copy of the text of the CDDL should have accompanied this 11*eda14cbcSMatt Macy# source. A copy of the CDDL is also available via the Internet at 12*eda14cbcSMatt Macy# http://www.illumos.org/license/CDDL. 13*eda14cbcSMatt Macy# 14*eda14cbcSMatt Macy# CDDL HEADER END 15*eda14cbcSMatt Macy# 16*eda14cbcSMatt Macy 17*eda14cbcSMatt Macy# 18*eda14cbcSMatt Macy# Copyright (c) 2019 by Tim Chase. All rights reserved. 19*eda14cbcSMatt Macy# Copyright (c) 2019 Lawrence Livermore National Security, LLC. 20*eda14cbcSMatt Macy# 21*eda14cbcSMatt Macy 22*eda14cbcSMatt Macy. $STF_SUITE/include/libtest.shlib 23*eda14cbcSMatt Macy 24*eda14cbcSMatt Macyverify_runnable "global" 25*eda14cbcSMatt Macy 26*eda14cbcSMatt Macyif is_freebsd; then 27*eda14cbcSMatt Macy log_unsupported "FreeBSD has no hole punching mechanism for the time being." 28*eda14cbcSMatt Macy diskinfo -v $DISKS | grep -qE 'No.*# TRIM/UNMAP support' && 29*eda14cbcSMatt Macy log_unsupported "DISKS do not support discard (TRIM/UNMAP)" 30*eda14cbcSMatt Macyelse 31*eda14cbcSMatt Macy DISK1=${DISKS%% *} 32*eda14cbcSMatt Macy 33*eda14cbcSMatt Macy typeset -i max_discard=0 34*eda14cbcSMatt Macy if is_disk_device $DEV_RDSKDIR/$DISK1; then 35*eda14cbcSMatt Macy max_discard=$(lsblk -Dbn $DEV_RDSKDIR/$DISK1 | awk '{ print $4; exit }') 36*eda14cbcSMatt Macy fi 37*eda14cbcSMatt Macy 38*eda14cbcSMatt Macy if test $max_discard -eq 0; then 39*eda14cbcSMatt Macy log_unsupported "DISKS do not support discard (TRIM/UNMAP)" 40*eda14cbcSMatt Macy fi 41*eda14cbcSMatt Macyfi 42*eda14cbcSMatt Macy 43*eda14cbcSMatt Macylog_pass 44