-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test autotrim and manual trim for each vdev type. Testing autotrim in a reasonable amount of time requires lowering zfs_trim_min_ext_sz and forcing transaction groups.
- Loading branch information
Showing
10 changed files
with
389 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ SUBDIRS = \ | |
sparse \ | ||
threadsappend \ | ||
tmpfile \ | ||
trim \ | ||
truncate \ | ||
upgrade \ | ||
userquota \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/trim | ||
dist_pkgdata_SCRIPTS = \ | ||
setup.ksh \ | ||
trim.cfg \ | ||
trim.kshlib \ | ||
cleanup.ksh \ | ||
autotrim_001_pos.ksh \ | ||
manualtrim_001_pos.ksh |
114 changes: 114 additions & 0 deletions
114
tests/zfs-tests/tests/functional/trim/autotrim_001_pos.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#!/bin/ksh -p | ||
# | ||
# CDDL HEADER START | ||
# | ||
# The contents of this file are subject to the terms of the | ||
# Common Development and Distribution License (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# | ||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | ||
# or http://www.opensolaris.org/os/licensing. | ||
# See the License for the specific language governing permissions | ||
# and limitations under the License. | ||
# | ||
# When distributing Covered Code, include this CDDL HEADER in each | ||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. | ||
# If applicable, add the following below this CDDL HEADER, with the | ||
# fields enclosed by brackets "[]" replaced with your own identifying | ||
# information: Portions Copyright [yyyy] [name of copyright owner] | ||
# | ||
# CDDL HEADER END | ||
# | ||
|
||
# | ||
# Copyright 2007 Sun Microsystems, Inc. All rights reserved. | ||
# Use is subject to license terms. | ||
# | ||
# | ||
# Copyright (c) 2013, 2014 by Delphix. All rights reserved. | ||
# | ||
|
||
. $STF_SUITE/include/libtest.shlib | ||
. $STF_SUITE/tests/functional/trim/trim.cfg | ||
. $STF_SUITE/tests/functional/trim/trim.kshlib | ||
|
||
set_tunable zfs_trim_min_ext_sz 4096 | ||
set_tunable zfs_txgs_per_trim 2 | ||
|
||
function getsizemb | ||
{ | ||
typeset rval | ||
|
||
rval=$(du --block-size 1048576 -s "$1" | sed -e 's;[ ].*;;') | ||
echo -n "$rval" | ||
} | ||
|
||
function checkvdevs | ||
{ | ||
typeset vd sz | ||
|
||
for vd in $VDEVS; do | ||
sz=$(getsizemb $vd) | ||
log_note Size of $vd is $sz MB | ||
log_must test $sz -le $SHRUNK_SIZE_MB | ||
done | ||
} | ||
|
||
function txgs | ||
{ | ||
typeset x | ||
|
||
# Run some txgs in order to let autotrim do its work. | ||
# | ||
for x in 1 2 3; do | ||
log_must zfs snapshot $TRIMPOOL@snap | ||
log_must zfs destroy $TRIMPOOL@snap | ||
log_must zfs snapshot $TRIMPOOL@snap | ||
log_must zfs destroy $TRIMPOOL@snap | ||
done | ||
} | ||
|
||
# | ||
# Check various pool geometries: Create the pool, fill it, remove the test file, | ||
# run some txgs, export the pool and verify that the vdevs shrunk. | ||
# | ||
|
||
# | ||
# raidz | ||
# | ||
for z in 1 2 3; do | ||
setupvdevs | ||
log_must zpool create -f $TRIMPOOL raidz$z $VDEVS | ||
log_must zpool set autotrim=on $TRIMPOOL | ||
log_must file_write -o create -f "/$TRIMPOOL/$TESTFILE" -b $BLOCKSIZE -c $NUM_WRITES -d R -w | ||
log_must rm "/$TRIMPOOL/$TESTFILE" | ||
txgs | ||
log_must zpool export $TRIMPOOL | ||
checkvdevs | ||
done | ||
|
||
# | ||
# mirror | ||
# | ||
setupvdevs | ||
log_must zpool create -f $TRIMPOOL mirror $MIRROR_VDEVS_1 mirror $MIRROR_VDEVS_2 | ||
log_must zpool set autotrim=on $TRIMPOOL | ||
log_must file_write -o create -f "/$TRIMPOOL/$TESTFILE" -b $BLOCKSIZE -c $NUM_WRITES -d R -w | ||
log_must rm "/$TRIMPOOL/$TESTFILE" | ||
txgs | ||
log_must zpool export $TRIMPOOL | ||
checkvdevs | ||
|
||
# | ||
# stripe | ||
# | ||
setupvdevs | ||
log_must zpool create -f $TRIMPOOL $STRIPE_VDEVS | ||
log_must zpool set autotrim=on $TRIMPOOL | ||
log_must file_write -o create -f "/$TRIMPOOL/$TESTFILE" -b $BLOCKSIZE -c $NUM_WRITES -d R -w | ||
log_must rm "/$TRIMPOOL/$TESTFILE" | ||
txgs | ||
log_must zpool export $TRIMPOOL | ||
checkvdevs | ||
|
||
log_pass TRIM successfully shrunk vdevs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/ksh -p | ||
# | ||
# CDDL HEADER START | ||
# | ||
# The contents of this file are subject to the terms of the | ||
# Common Development and Distribution License (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# | ||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | ||
# or http://www.opensolaris.org/os/licensing. | ||
# See the License for the specific language governing permissions | ||
# and limitations under the License. | ||
# | ||
# When distributing Covered Code, include this CDDL HEADER in each | ||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. | ||
# If applicable, add the following below this CDDL HEADER, with the | ||
# fields enclosed by brackets "[]" replaced with your own identifying | ||
# information: Portions Copyright [yyyy] [name of copyright owner] | ||
# | ||
# CDDL HEADER END | ||
# | ||
|
||
# | ||
# Copyright 2007 Sun Microsystems, Inc. All rights reserved. | ||
# Use is subject to license terms. | ||
# | ||
|
||
. $STF_SUITE/include/libtest.shlib | ||
. $STF_SUITE/tests/functional/trim/trim.cfg | ||
|
||
rm -f $VDEVS |
100 changes: 100 additions & 0 deletions
100
tests/zfs-tests/tests/functional/trim/manualtrim_001_pos.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/bin/ksh -p | ||
# | ||
# CDDL HEADER START | ||
# | ||
# The contents of this file are subject to the terms of the | ||
# Common Development and Distribution License (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# | ||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | ||
# or http://www.opensolaris.org/os/licensing. | ||
# See the License for the specific language governing permissions | ||
# and limitations under the License. | ||
# | ||
# When distributing Covered Code, include this CDDL HEADER in each | ||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. | ||
# If applicable, add the following below this CDDL HEADER, with the | ||
# fields enclosed by brackets "[]" replaced with your own identifying | ||
# information: Portions Copyright [yyyy] [name of copyright owner] | ||
# | ||
# CDDL HEADER END | ||
# | ||
|
||
# | ||
# Copyright 2007 Sun Microsystems, Inc. All rights reserved. | ||
# Use is subject to license terms. | ||
# | ||
# | ||
# Copyright (c) 2013, 2014 by Delphix. All rights reserved. | ||
# | ||
|
||
. $STF_SUITE/include/libtest.shlib | ||
. $STF_SUITE/tests/functional/trim/trim.cfg | ||
. $STF_SUITE/tests/functional/trim/trim.kshlib | ||
|
||
set_tunable zfs_trim_min_ext_sz 4096 | ||
|
||
function getsizemb | ||
{ | ||
typeset rval | ||
|
||
rval=$(du --block-size 1048576 -s "$1" | sed -e 's;[ ].*;;') | ||
echo -n "$rval" | ||
} | ||
|
||
function checkvdevs | ||
{ | ||
typeset vd sz | ||
|
||
for vd in $VDEVS; do | ||
sz=$(getsizemb $vd) | ||
log_note Size of $vd is $sz MB | ||
log_must test $sz -le $SHRUNK_SIZE_MB | ||
done | ||
} | ||
|
||
function dotrim | ||
{ | ||
log_must rm "/$TRIMPOOL/$TESTFILE" | ||
log_must zpool export $TRIMPOOL | ||
log_must zpool import -d $VDEVDIR $TRIMPOOL | ||
log_must zpool trim $TRIMPOOL | ||
sleep 5 | ||
log_must zpool export $TRIMPOOL | ||
} | ||
|
||
# | ||
# Check various pool geometries: Create the pool, fill it, remove the test file, | ||
# perform a manual trim, export the pool and verify that the vdevs shrunk. | ||
# | ||
|
||
# | ||
# raidz | ||
# | ||
for z in 1 2 3; do | ||
setupvdevs | ||
log_must zpool create -f $TRIMPOOL raidz$z $VDEVS | ||
log_must file_write -o create -f "/$TRIMPOOL/$TESTFILE" -b $BLOCKSIZE -c $NUM_WRITES -d R -w | ||
dotrim | ||
checkvdevs | ||
done | ||
|
||
# | ||
# mirror | ||
# | ||
setupvdevs | ||
log_must zpool create -f $TRIMPOOL mirror $MIRROR_VDEVS_1 mirror $MIRROR_VDEVS_2 | ||
log_must file_write -o create -f "/$TRIMPOOL/$TESTFILE" -b $BLOCKSIZE -c $NUM_WRITES -d R -w | ||
dotrim | ||
checkvdevs | ||
|
||
# | ||
# stripe | ||
# | ||
setupvdevs | ||
log_must zpool create -f $TRIMPOOL $STRIPE_VDEVS | ||
log_must file_write -o create -f "/$TRIMPOOL/$TESTFILE" -b $BLOCKSIZE -c $NUM_WRITES -d R -w | ||
dotrim | ||
checkvdevs | ||
|
||
log_pass Manual TRIM successfully shrunk vdevs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/ksh -p | ||
# | ||
# CDDL HEADER START | ||
# | ||
# The contents of this file are subject to the terms of the | ||
# Common Development and Distribution License (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# | ||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | ||
# or http://www.opensolaris.org/os/licensing. | ||
# See the License for the specific language governing permissions | ||
# and limitations under the License. | ||
# | ||
# When distributing Covered Code, include this CDDL HEADER in each | ||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. | ||
# If applicable, add the following below this CDDL HEADER, with the | ||
# fields enclosed by brackets "[]" replaced with your own identifying | ||
# information: Portions Copyright [yyyy] [name of copyright owner] | ||
# | ||
# CDDL HEADER END | ||
# | ||
|
||
# | ||
# Copyright 2009 Sun Microsystems, Inc. All rights reserved. | ||
# Use is subject to license terms. | ||
# | ||
|
||
# | ||
# Copyright (c) 2013 by Delphix. All rights reserved. | ||
# | ||
|
||
. $STF_SUITE/include/libtest.shlib | ||
. $STF_SUITE/tests/functional/trim/trim.cfg | ||
. $STF_SUITE/tests/functional/trim/trim.kshlib | ||
|
||
log_pass TRIM setup succeeded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# | ||
# CDDL HEADER START | ||
# | ||
# The contents of this file are subject to the terms of the | ||
# Common Development and Distribution License (the "License"). | ||
# You may not use this file except in compliance with the License. | ||
# | ||
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | ||
# or http://www.opensolaris.org/os/licensing. | ||
# See the License for the specific language governing permissions | ||
# and limitations under the License. | ||
# | ||
# When distributing Covered Code, include this CDDL HEADER in each | ||
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. | ||
# If applicable, add the following below this CDDL HEADER, with the | ||
# fields enclosed by brackets "[]" replaced with your own identifying | ||
# information: Portions Copyright [yyyy] [name of copyright owner] | ||
# | ||
# CDDL HEADER END | ||
# | ||
|
||
# | ||
# Copyright 2008 Sun Microsystems, Inc. All rights reserved. | ||
# Use is subject to license terms. | ||
# | ||
|
||
# | ||
# Copyright (c) 2013 by Delphix. All rights reserved. | ||
# | ||
|
||
# | ||
# Parameters | ||
# | ||
TRIMPOOL=trimpool | ||
VDEVDIR="/tmp" | ||
VDEVS="/tmp/trim1.dev /tmp/trim2.dev /tmp/trim3.dev /tmp/trim4.dev /tmp/trim5.dev" | ||
VDEV_SIZE=128m | ||
TESTFILE=testfile | ||
SHRUNK_SIZE_MB=12 | ||
|
||
NUM_WRITES=2048 | ||
BLOCKSIZE=65536 | ||
|
||
# | ||
# Computed values and parameters | ||
# | ||
function get_mirror_vdevs | ||
{ | ||
set -- $VDEVS | ||
MIRROR_VDEVS_1="$1 $2" | ||
MIRROR_VDEVS_2="$3 $4" | ||
} | ||
get_mirror_vdevs | ||
|
||
function get_stripe_vdevs | ||
{ | ||
set -- $VDEVS | ||
STRIPE_VDEVS="$1 $2 $3 $4" | ||
} | ||
get_stripe_vdevs |
Oops, something went wrong.