1*084fd14fSBrian Behlendorf#!/bin/ksh -p 2*084fd14fSBrian Behlendorf# 3*084fd14fSBrian Behlendorf# CDDL HEADER START 4*084fd14fSBrian Behlendorf# 5*084fd14fSBrian Behlendorf# This file and its contents are supplied under the terms of the 6*084fd14fSBrian Behlendorf# Common Development and Distribution License ("CDDL"), version 1.0. 7*084fd14fSBrian Behlendorf# You may only use this file in accordance with the terms of version 8*084fd14fSBrian Behlendorf# 1.0 of the CDDL. 9*084fd14fSBrian Behlendorf# 10*084fd14fSBrian Behlendorf# A full copy of the text of the CDDL should have accompanied this 11*084fd14fSBrian Behlendorf# source. A copy of the CDDL is also available via the Internet at 12*084fd14fSBrian Behlendorf# http://www.illumos.org/license/CDDL. 13*084fd14fSBrian Behlendorf# 14*084fd14fSBrian Behlendorf# CDDL HEADER END 15*084fd14fSBrian Behlendorf# 16*084fd14fSBrian Behlendorf 17*084fd14fSBrian Behlendorf# 18*084fd14fSBrian Behlendorf# Copyright (c) 2019 by Tim Chase. All rights reserved. 19*084fd14fSBrian Behlendorf# Copyright (c) 2019 Lawrence Livermore National Security, LLC. 20*084fd14fSBrian Behlendorf# Copyright 2019 Joyent, Inc. 21*084fd14fSBrian Behlendorf# 22*084fd14fSBrian Behlendorf 23*084fd14fSBrian Behlendorf. $STF_SUITE/include/libtest.shlib 24*084fd14fSBrian Behlendorf 25*084fd14fSBrian Behlendorfverify_runnable "global" 26*084fd14fSBrian Behlendorf 27*084fd14fSBrian Behlendorftypeset -i max_discard=0 28*084fd14fSBrian Behlendorfif is_linux; then 29*084fd14fSBrian Behlendorf DISK1=${DISKS%% *} 30*084fd14fSBrian Behlendorf 31*084fd14fSBrian Behlendorf if [[ -b $DEV_RDSKDIR/$DISK1 ]]; then 32*084fd14fSBrian Behlendorf max_discard=$(lsblk -Dbn $DEV_RDSKDIR/$DISK1 | awk '{ print $4; exit }') 33*084fd14fSBrian Behlendorf fi 34*084fd14fSBrian Behlendorfelse 35*084fd14fSBrian Behlendorf for dsk in $DISKS; do 36*084fd14fSBrian Behlendorf if has_unmap $DEV_RDSKDIR/${dsk}s0; then 37*084fd14fSBrian Behlendorf max_discard=1 38*084fd14fSBrian Behlendorf fi 39*084fd14fSBrian Behlendorf done 40*084fd14fSBrian Behlendorffi 41*084fd14fSBrian Behlendorf 42*084fd14fSBrian Behlendorfif test $max_discard -eq 0; then 43*084fd14fSBrian Behlendorf log_unsupported "DISKS do not support discard (TRIM/UNMAP)" 44*084fd14fSBrian Behlendorffi 45*084fd14fSBrian Behlendorf 46*084fd14fSBrian Behlendorflog_pass 47