aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDon Brady <[email protected]>2018-09-05 19:33:36 -0600
committerBrian Behlendorf <[email protected]>2018-09-05 18:33:36 -0700
commitcc99f275a28c43fe450a66a7544f73c4935f7361 (patch)
treef867e1d2cbb550a047c0f87986831252c41a2fd9 /tests
parentcfa37548ebc880580782b245f2d233ed540e7a01 (diff)
Pool allocation classes
Allocation Classes add the ability to have allocation classes in a pool that are dedicated to serving specific block categories, such as DDT data, metadata, and small file blocks. A pool can opt-in to this feature by adding a 'special' or 'dedup' top-level VDEV. Reviewed by: Pavel Zakharov <[email protected]> Reviewed-by: Richard Laager <[email protected]> Reviewed-by: Alek Pinchuk <[email protected]> Reviewed-by: HÃ¥kan Johansson <[email protected]> Reviewed-by: Andreas Dilger <[email protected]> Reviewed-by: DHE <[email protected]> Reviewed-by: Richard Elling <[email protected]> Reviewed-by: Gregor Kopka <[email protected]> Reviewed-by: Kash Pande <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Matthew Ahrens <[email protected]> Signed-off-by: Don Brady <[email protected]> Closes #5182
Diffstat (limited to 'tests')
-rw-r--r--tests/runfiles/linux.run8
-rw-r--r--tests/zfs-tests/tests/functional/Makefile.am1
-rw-r--r--tests/zfs-tests/tests/functional/alloc_class/Makefile.am19
-rw-r--r--tests/zfs-tests/tests/functional/alloc_class/alloc_class.cfg31
-rw-r--r--tests/zfs-tests/tests/functional/alloc_class/alloc_class.kshlib67
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/alloc_class_001_pos.ksh39
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/alloc_class_002_neg.ksh48
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/alloc_class_003_pos.ksh57
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/alloc_class_004_pos.ksh67
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh71
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/alloc_class_006_pos.ksh41
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/alloc_class_007_pos.ksh41
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/alloc_class_008_pos.ksh56
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/alloc_class_009_pos.ksh58
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh50
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/alloc_class_011_neg.ksh43
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/alloc_class_012_pos.ksh69
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/alloc_class_013_pos.ksh63
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/cleanup.ksh27
-rwxr-xr-xtests/zfs-tests/tests/functional/alloc_class/setup.ksh26
-rw-r--r--tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg1
-rwxr-xr-xtests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh6
22 files changed, 888 insertions, 1 deletions
diff --git a/tests/runfiles/linux.run b/tests/runfiles/linux.run
index e76399775..0a4b26c06 100644
--- a/tests/runfiles/linux.run
+++ b/tests/runfiles/linux.run
@@ -24,6 +24,14 @@ tags = ['functional']
tests = ['posix_001_pos', 'posix_002_pos', 'posix_003_pos']
tags = ['functional', 'acl', 'posix']
+[tests/functional/alloc_class]
+tests = ['alloc_class_001_pos', 'alloc_class_002_neg', 'alloc_class_003_pos',
+ 'alloc_class_004_pos', 'alloc_class_005_pos', 'alloc_class_006_pos',
+ 'alloc_class_007_pos', 'alloc_class_008_pos', 'alloc_class_009_pos',
+ 'alloc_class_010_pos', 'alloc_class_011_neg', 'alloc_class_012_pos',
+ 'alloc_class_013_pos']
+tags = ['functional', 'alloc_class']
+
[tests/functional/arc]
tests = ['dbufstats_001_pos', 'dbufstats_002_pos']
tags = ['functional', 'arc']
diff --git a/tests/zfs-tests/tests/functional/Makefile.am b/tests/zfs-tests/tests/functional/Makefile.am
index 5cd079b98..e0a4aca99 100644
--- a/tests/zfs-tests/tests/functional/Makefile.am
+++ b/tests/zfs-tests/tests/functional/Makefile.am
@@ -1,5 +1,6 @@
SUBDIRS = \
acl \
+ alloc_class \
arc \
atime \
bootfs \
diff --git a/tests/zfs-tests/tests/functional/alloc_class/Makefile.am b/tests/zfs-tests/tests/functional/alloc_class/Makefile.am
new file mode 100644
index 000000000..073eac988
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/Makefile.am
@@ -0,0 +1,19 @@
+pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/alloc_class
+dist_pkgdata_SCRIPTS = \
+ alloc_class.cfg \
+ alloc_class.kshlib \
+ setup.ksh \
+ cleanup.ksh \
+ alloc_class_001_pos.ksh \
+ alloc_class_002_neg.ksh \
+ alloc_class_003_pos.ksh \
+ alloc_class_004_pos.ksh \
+ alloc_class_005_pos.ksh \
+ alloc_class_006_pos.ksh \
+ alloc_class_007_pos.ksh \
+ alloc_class_008_pos.ksh \
+ alloc_class_009_pos.ksh \
+ alloc_class_010_pos.ksh \
+ alloc_class_011_neg.ksh \
+ alloc_class_012_pos.ksh \
+ alloc_class_013_pos.ksh
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class.cfg b/tests/zfs-tests/tests/functional/alloc_class/alloc_class.cfg
new file mode 100644
index 000000000..0bdae47f2
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class.cfg
@@ -0,0 +1,31 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2017, Intel Corporation.
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+
+export ZPOOL_DISK0="$TEST_BASE_DIR/device-0"
+export ZPOOL_DISK1="$TEST_BASE_DIR/device-1"
+export ZPOOL_DISK2="$TEST_BASE_DIR/device-2"
+export ZPOOL_DISKS="${ZPOOL_DISK0} ${ZPOOL_DISK1} ${ZPOOL_DISK2}"
+
+export CLASS_DISK0="$TEST_BASE_DIR/device-3"
+export CLASS_DISK1="$TEST_BASE_DIR/device-4"
+export CLASS_DISK2="$TEST_BASE_DIR/device-5"
+export CLASS_DISK3="$TEST_BASE_DIR/device-6"
+export CLASS_DISKS="${CLASS_DISK0} ${CLASS_DISK1} ${CLASS_DISK2} ${CLASS_DISK3}"
+
+export ZPOOL_DEVSIZE=1G
+export CLASS_DEVSIZE=512M
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class.kshlib b/tests/zfs-tests/tests/functional/alloc_class/alloc_class.kshlib
new file mode 100644
index 000000000..4c64cff69
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class.kshlib
@@ -0,0 +1,67 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2017, Intel Corporation.
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.cfg
+
+function disk_setup
+{
+ truncate -s $ZPOOL_DEVSIZE $ZPOOL_DISKS
+ truncate -s $CLASS_DEVSIZE $CLASS_DISKS
+}
+
+function disk_cleanup
+{
+ rm -f $ZPOOL_DEVSIZE $ZPOOL_DISKS 2> /dev/null
+ rm -f $CLASS_DEVSIZE $CLASS_DISKS 2> /dev/null
+}
+
+function cleanup
+{
+ if datasetexists $TESTPOOL ; then
+ zpool destroy -f $TESTPOOL 2> /dev/null
+ fi
+
+ disk_cleanup
+}
+
+#
+# Try zpool status/iostat for given pool
+#
+# $1 pool
+#
+function display_status
+{
+ typeset pool=$1
+
+ typeset -i ret=0
+ zpool status -xv $pool > /dev/null 2>&1
+ ret=$?
+
+ zpool iostat > /dev/null 2>&1
+ ((ret |= $?))
+
+ typeset mntpnt=$(get_prop mountpoint $pool)
+ dd if=/dev/random of=$mntpnt/testfile.$$ &
+ typeset pid=$!
+
+ zpool iostat -v 1 3 > /dev/null
+ ((ret |= $?))
+
+ kill -9 $pid
+
+ return $ret
+}
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_001_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_001_pos.ksh
new file mode 100755
index 000000000..441df8296
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_001_pos.ksh
@@ -0,0 +1,39 @@
+#!/bin/ksh -p
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2017, Intel Corporation.
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
+
+#
+# DESCRIPTION:
+# Creating a pool with a special device succeeds.
+#
+
+verify_runnable "global"
+
+claim="Creating a pool with a special device succeeds."
+
+log_assert $claim
+log_onexit cleanup
+
+log_must disk_setup
+log_must zpool create $TESTPOOL raidz $ZPOOL_DISKS special mirror \
+ $CLASS_DISK0 $CLASS_DISK1
+log_must display_status "$TESTPOOL"
+log_must zpool destroy -f "$TESTPOOL"
+
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_002_neg.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_002_neg.ksh
new file mode 100755
index 000000000..b2cac59fd
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_002_neg.ksh
@@ -0,0 +1,48 @@
+#!/bin/ksh -p
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2017, Intel Corporation.
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
+
+#
+# DESCRIPTION:
+# Creating a pool fails when an invalid special device type is specified.
+#
+claim="Creating a pool with an invalid special device type fails."
+
+verify_runnable "global"
+
+log_assert $claim
+log_onexit cleanup
+
+log_must disk_setup
+
+log_mustnot zpool create $TESTPOOL raidz $ZPOOL_DISKS special $CLASS_DISK0
+log_mustnot display_status $TESTPOOL
+log_mustnot zpool destroy -f $TESTPOOL
+
+log_mustnot zpool create $TESTPOOL $ZPOOL_DISKS special mirror \
+ $CLASS_DISK0 $CLASS_DISK1
+log_mustnot display_status $TESTPOOL
+log_mustnot zpool destroy -f $TESTPOOL
+
+log_mustnot zpool create $TESTPOOL raidz $ZPOOL_DISKS special raidz \
+ $CLASS_DISK0 $CLASS_DISK1 $CLASS_DISK2
+log_mustnot display_status $TESTPOOL
+log_mustnot zpool destroy -f $TESTPOOL
+
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_003_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_003_pos.ksh
new file mode 100755
index 000000000..78d40ce56
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_003_pos.ksh
@@ -0,0 +1,57 @@
+#!/bin/ksh -p
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2017, Intel Corporation.
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
+
+#
+# DESCRIPTION:
+# Adding a special device to a normal pool succeeds.
+#
+claim="Adding a special device to a normal pool succeeds."
+
+verify_runnable "global"
+
+log_assert $claim
+log_onexit cleanup
+
+log_must disk_setup
+
+for type in "" "mirror" "raidz"
+do
+ log_must zpool create $TESTPOOL $type $ZPOOL_DISKS
+
+ if [ "$type" = "mirror" ]; then
+ log_must zpool add $TESTPOOL special mirror \
+ $CLASS_DISK0 $CLASS_DISK1 $CLASS_DISK2
+ log_must zpool iostat -H $TESTPOOL $CLASS_DISK0
+ log_must zpool iostat -H $TESTPOOL $CLASS_DISK1
+ log_must zpool iostat -H $TESTPOOL $CLASS_DISK2
+ elif [ "$type" = "raidz" ]; then
+ log_must zpool add $TESTPOOL special mirror \
+ $CLASS_DISK0 $CLASS_DISK1
+ log_must zpool iostat -H $TESTPOOL $CLASS_DISK0
+ log_must zpool iostat -H $TESTPOOL $CLASS_DISK1
+ else
+ log_must zpool add $TESTPOOL special $CLASS_DISK0
+ log_must zpool iostat -H $TESTPOOL $CLASS_DISK0
+ fi
+
+ log_must zpool destroy -f $TESTPOOL
+done
+
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_004_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_004_pos.ksh
new file mode 100755
index 000000000..dcc6f7607
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_004_pos.ksh
@@ -0,0 +1,67 @@
+#!/bin/ksh -p
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2017, Intel Corporation.
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
+
+#
+# DESCRIPTION:
+# Checking if allocation_classes feature flag status is active after
+# creating a pool with a special device.
+#
+claim="Checking active allocation classes feature flag status successful."
+
+verify_runnable "global"
+
+log_assert $claim
+log_onexit cleanup
+
+log_must disk_setup
+
+typeset ac_value
+typeset stype=""
+typeset sdisks=""
+
+for type in "" "mirror" "raidz"
+do
+ if [ "$type" = "mirror" ]; then
+ stype="mirror"
+ sdisks="${CLASS_DISK0} ${CLASS_DISK1} ${CLASS_DISK2}"
+ elif [ "$type" = "raidz" ]; then
+ stype="mirror"
+ sdisks="${CLASS_DISK0} ${CLASS_DISK1}"
+ else
+ stype=""
+ sdisks="${CLASS_DISK0}"
+ fi
+
+ log_must zpool create $TESTPOOL $type $ZPOOL_DISKS \
+ special $stype $sdisks
+
+ ac_value="$(zpool get all -H -o property,value | \
+ egrep allocation_classes | nawk '{print $2}')"
+ if [ "$ac_value" = "active" ]; then
+ log_note "feature@allocation_classes is active"
+ else
+ log_fail "feature@allocation_classes not active, \
+ status = $ac_value"
+ fi
+
+ log_must zpool destroy -f $TESTPOOL
+done
+
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh
new file mode 100755
index 000000000..417c68aa7
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_005_pos.ksh
@@ -0,0 +1,71 @@
+#!/bin/ksh -p
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2017, Intel Corporation.
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
+
+#
+# DESCRIPTION:
+# Checking allocation_classes feature flag value after pool is created
+# (should be enabled) and also after a special device added to existing
+# pool (should be active).
+#
+
+verify_runnable "global"
+
+log_assert "Values of allocation_classes feature flag correct."
+log_onexit cleanup
+
+log_must disk_setup
+
+typeset ac_value
+
+for type in "" "mirror" "raidz"
+do
+ if [ "$type" = "mirror" ]; then
+ log_must zpool create $TESTPOOL $type $ZPOOL_DISK0 $ZPOOL_DISK1
+ else
+ log_must zpool create $TESTPOOL $type $ZPOOL_DISKS
+ fi
+ ac_value="$(zpool get all -H -o property,value | \
+ egrep allocation_classes | awk '{print $2}')"
+ if [ "$ac_value" = "enabled" ]; then
+ log_note "feature@allocation_classes is enabled"
+ else
+ log_fail "feature@allocation_classes not enabled, \
+ status = $ac_value"
+ fi
+
+ if [ "$type" = "" ]; then
+ log_must zpool add $TESTPOOL special $CLASS_DISK0
+ else
+ log_must zpool add $TESTPOOL special mirror \
+ $CLASS_DISK0 $CLASS_DISK1
+ fi
+ ac_value="$(zpool get all -H -o property,value | \
+ egrep allocation_classes | awk '{print $2}')"
+ if [ "$ac_value" = "active" ]; then
+ log_note "feature@allocation_classes is active"
+ else
+ log_fail "feature@allocation_classes not active, \
+ status = $ac_value"
+ fi
+
+ log_must zpool destroy -f $TESTPOOL
+done
+
+log_pass "Values of allocation_classes feature flag correct."
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_006_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_006_pos.ksh
new file mode 100755
index 000000000..5852b2876
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_006_pos.ksh
@@ -0,0 +1,41 @@
+#!/bin/ksh -p
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2017, Intel Corporation.
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
+
+#
+# DESCRIPTION:
+# Using zpool split command to detach disks from mirrored special pool
+# to create a new pool with the detached disks.
+#
+claim="zpool split command succeeds with special devices present."
+
+verify_runnable "global"
+
+log_assert $claim
+log_onexit cleanup
+
+log_must disk_setup
+
+log_must zpool create $TESTPOOL \
+ mirror $ZPOOL_DISK0 $ZPOOL_DISK1 \
+ special mirror $CLASS_DISK0 $CLASS_DISK1
+log_must zpool split $TESTPOOL split_pool
+log_must zpool destroy -f $TESTPOOL
+
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_007_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_007_pos.ksh
new file mode 100755
index 000000000..106a6d933
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_007_pos.ksh
@@ -0,0 +1,41 @@
+#!/bin/ksh -p
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2017, Intel Corporation.
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
+
+#
+# DESCRIPTION:
+# Replacing a special device succeeds
+#
+claim="Replacing a special device is successful."
+
+verify_runnable "global"
+
+log_assert $claim
+log_onexit cleanup
+
+log_must disk_setup
+
+log_must zpool create $TESTPOOL raidz $ZPOOL_DISKS \
+ special mirror $CLASS_DISK0 $CLASS_DISK1
+log_must zpool replace $TESTPOOL $CLASS_DISK1 $CLASS_DISK2
+log_must sleep 10
+log_must zpool iostat -H $TESTPOOL $CLASS_DISK2
+log_must zpool destroy -f $TESTPOOL
+
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_008_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_008_pos.ksh
new file mode 100755
index 000000000..f73fbbe38
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_008_pos.ksh
@@ -0,0 +1,56 @@
+#!/bin/ksh -p
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2017, Intel Corporation.
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
+
+#
+# DESCRIPTION:
+# Adding an additional special device to a pool with special succeeds.
+#
+claim="Adding an additional special device succeeds."
+
+verify_runnable "global"
+
+log_assert $claim
+log_onexit cleanup
+
+log_must disk_setup
+
+typeset special_type=""
+typeset create_disks=""
+typeset added_disks=""
+
+for type in "" "raidz"
+do
+ if [ "$type" = "raidz" ]; then
+ special_type="mirror"
+ create_disks="${CLASS_DISK0} ${CLASS_DISK1}"
+ added_disks="${CLASS_DISK2} ${CLASS_DISK3}"
+ else
+ special_type=""
+ create_disks="${CLASS_DISK0}"
+ added_disks="${CLASS_DISK1}"
+ fi
+ log_must zpool create $TESTPOOL $type $ZPOOL_DISKS \
+ special $special_type $create_disks
+ log_must zpool add $TESTPOOL special $special_type $added_disks
+ log_must zpool iostat $TESTPOOL $added_disks
+ log_must zpool destroy -f $TESTPOOL
+done
+
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_009_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_009_pos.ksh
new file mode 100755
index 000000000..7c1d6e15c
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_009_pos.ksh
@@ -0,0 +1,58 @@
+#!/bin/ksh -p
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2017, Intel Corporation.
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
+
+#
+# DESCRIPTION:
+# Importing and exporting pool with special device succeeds.
+#
+claim="Import/export of pool with special device mirror succeeds."
+
+verify_runnable "global"
+
+log_assert $claim
+log_onexit cleanup
+
+log_must disk_setup
+
+typeset stype=""
+typeset sdisks=""
+
+for type in "" "mirror" "raidz"
+do
+ if [ "$type" = "mirror" ]; then
+ stype="mirror"
+ sdisks="${CLASS_DISK0} ${CLASS_DISK1} ${CLASS_DISK2}"
+ elif [ "$type" = "raidz" ]; then
+ stype="mirror"
+ sdisks="${CLASS_DISK0} ${CLASS_DISK1}"
+ else
+ stype=""
+ special_args="${CLASS_DISK0}"
+ fi
+
+ log_must zpool create $TESTPOOL $type $ZPOOL_DISKS \
+ special $stype $sdisks
+ log_must zpool export $TESTPOOL
+ log_must zpool import -d $TEST_BASE_DIR -s $TESTPOOL
+ log_must display_status $TESTPOOL
+ log_must zpool destroy -f $TESTPOOL
+done
+
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh
new file mode 100755
index 000000000..2c14c69d8
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_010_pos.ksh
@@ -0,0 +1,50 @@
+#!/bin/ksh -p
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2017, Intel Corporation.
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
+
+#
+# DESCRIPTION:
+# Setting the special_small_blocks property to a valid value succeeds.
+#
+
+verify_runnable "global"
+
+claim="Setting the special_small_blocks property to a valid value succeeds."
+
+log_assert $claim
+log_onexit cleanup
+
+log_must disk_setup
+
+log_must zpool create $TESTPOOL raidz $ZPOOL_DISKS special mirror \
+ $CLASS_DISK0 $CLASS_DISK1
+
+for value in 0 512 1024 2048 4096 8192 16384 32768 65536 131072
+do
+ log_must zfs set special_small_blocks=$value $TESTPOOL
+ ACTUAL=$(zfs get -p special_small_blocks $TESTPOOL | \
+ grep special_small_blocks | awk '{print $3}')
+ if [ "$ACTUAL" != "$value" ]
+ then
+ log_fail "v. $ACTUAL set for $TESTPOOL, expected v. $value!"
+ fi
+done
+
+log_must zpool destroy -f "$TESTPOOL"
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_011_neg.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_011_neg.ksh
new file mode 100755
index 000000000..fe1ae366a
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_011_neg.ksh
@@ -0,0 +1,43 @@
+#!/bin/ksh -p
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2017, Intel Corporation.
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
+
+#
+# DESCRIPTION:
+# Setting the special_small_blocks property to invalid values fails.
+#
+
+verify_runnable "global"
+
+claim="Setting the special_small_blocks property to invalid values fails."
+
+log_assert $claim
+log_onexit cleanup
+
+log_must disk_setup
+log_must zpool create $TESTPOOL raidz $ZPOOL_DISKS special mirror \
+ $CLASS_DISK0 $CLASS_DISK1
+
+for value in 256 1025 262144
+do
+ log_mustnot zfs set special_small_blocks=$value $TESTPOOL
+done
+
+log_must zpool destroy -f "$TESTPOOL"
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_012_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_012_pos.ksh
new file mode 100755
index 000000000..eeb541f47
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_012_pos.ksh
@@ -0,0 +1,69 @@
+#!/bin/ksh -p
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
+
+#
+# DESCRIPTION:
+# Removing a special device from a pool succeeds.
+#
+
+verify_runnable "global"
+
+claim= "Removing a special device from a pool succeeds."
+
+log_assert $claim
+log_onexit cleanup
+
+#
+# Create a non-raidz pool so we can remove top-level vdevs
+#
+log_must disk_setup
+log_must zpool create $TESTPOOL $ZPOOL_DISK0 $ZPOOL_DISK1 $ZPOOL_DISK2 \
+ special $CLASS_DISK0 special $CLASS_DISK1
+log_must display_status "$TESTPOOL"
+
+#
+# Generate some metadata and small blocks in the special class before removal
+#
+typeset -l i=1
+typeset -l blocks=25
+
+log_must zfs create -o special_small_blocks=32K -o recordsize=32K \
+ $TESTPOOL/$TESTFS
+for i in 1 2 3 4; do
+ log_must dd if=/dev/urandom of=/$TESTPOOL/$TESTFS/testfile.$i bs=1M \
+ count=$blocks
+ ((blocks = blocks + 25))
+done
+log_must sync_pool $TESTPOOL
+log_must zpool list -v $TESTPOOL
+
+#
+# remove a special allocation vdev and force a remapping
+#
+log_must zpool remove $TESTPOOL $CLASS_DISK0
+log_must zfs remap $TESTPOOL/$TESTFS
+
+sleep 5
+log_must sync_pool $TESTPOOL
+sleep 1
+
+log_must zdb -bbcc $TESTPOOL
+log_must zpool destroy -f "$TESTPOOL"
+
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/alloc_class/alloc_class_013_pos.ksh b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_013_pos.ksh
new file mode 100755
index 000000000..b817bdacf
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/alloc_class_013_pos.ksh
@@ -0,0 +1,63 @@
+#!/bin/ksh -p
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
+
+#
+# DESCRIPTION:
+# Removing a dedup device from a pool succeeds.
+#
+
+verify_runnable "global"
+
+claim= "Removing a dedup device from a pool succeeds."
+
+log_assert $claim
+log_onexit cleanup
+
+#
+# Create a non-raidz pool so we can remove top-level vdevs
+#
+log_must disk_setup
+log_must zpool create $TESTPOOL $ZPOOL_DISKS dedup $CLASS_DISK0
+log_must display_status "$TESTPOOL"
+
+#
+# Generate some dedup data in the dedup class before removal
+#
+
+log_must zfs create -o dedup=on -V 2G $TESTPOOL/$TESTVOL
+
+log_must echo y | newfs $ZVOL_DEVDIR/$TESTPOOL/$TESTVOL >/dev/null 2>&1
+
+sync_pool
+log_must zpool list -v $TESTPOOL
+
+#
+# remove a dedup allocation vdev
+#
+log_must zpool remove $TESTPOOL $CLASS_DISK0
+
+sleep 5
+log_must sync_pool $TESTPOOL
+sleep 1
+
+log_must zdb -bbcc $TESTPOOL
+
+log_must zpool destroy -f "$TESTPOOL"
+
+log_pass $claim
diff --git a/tests/zfs-tests/tests/functional/alloc_class/cleanup.ksh b/tests/zfs-tests/tests/functional/alloc_class/cleanup.ksh
new file mode 100755
index 000000000..6f7e1d61a
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/cleanup.ksh
@@ -0,0 +1,27 @@
+#!/bin/ksh -p
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2017, Intel Corporation.
+# Copyright (c) 2018, Delphix
+#
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
+
+verify_runnable "global"
+
+pool_cleanup
+disk_cleanup
+
+log_pass
diff --git a/tests/zfs-tests/tests/functional/alloc_class/setup.ksh b/tests/zfs-tests/tests/functional/alloc_class/setup.ksh
new file mode 100755
index 000000000..bdccdb989
--- /dev/null
+++ b/tests/zfs-tests/tests/functional/alloc_class/setup.ksh
@@ -0,0 +1,26 @@
+#!/bin/ksh -p
+
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2017, Intel Corporation.
+# Copyright (c) 2018 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/alloc_class/alloc_class.kshlib
+
+verify_runnable "global"
+
+disk_cleanup
+
+log_pass
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg b/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg
index 6219caed7..8907533c9 100644
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_get/zpool_get.cfg
@@ -86,5 +86,6 @@ if is_linux; then
"feature@userobj_accounting"
"feature@encryption"
"feature@project_quota"
+ "feature@allocation_classes"
)
fi
diff --git a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh
index 64032331a..a9a407f8e 100755
--- a/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh
+++ b/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_vdevs.ksh
@@ -50,6 +50,7 @@ function cleanup
# "l" - log
# "ll" - mirrored log
# "c" - cache
+# "sc" - special class
#
function pool_config # <vdev-type>
{
@@ -66,6 +67,7 @@ function pool_config # <vdev-type>
disks[l]="l1"
disks[ll]="l1 l2"
disks[c]="c1"
+ disks[sc]="sc1 sc2"
case $1 in
d|t) # single disk or stripe
vdev='' ;;
@@ -85,6 +87,8 @@ function pool_config # <vdev-type>
vdev='log mirror';;
c) # cache
vdev='cache';;
+ sc) # mirrored special class
+ vdev='special mirror';;
*)
log_fail "setup_pool: unsupported vdev type '$1'"
esac
@@ -108,7 +112,7 @@ log_onexit cleanup
# "good" and "bad" pool layouts
# first token is always used with "zpool create"
# second to last tokens, if any, are used with "zpool add"
-typeset -a goodconfs=("m" "m l" "m s" "m c" "m m" "m3" "m3 m3" "m m3 l s c")
+typeset -a goodconfs=("m" "m l" "m s" "m c" "m m" "m3" "m3 m3" "m m3 l s c" "m m sc")
typeset -a badconfs=("d" "z1" "z2" "z3" "m d" "m3 d" "m z1" "m z2" "m z3")
typeset FILEDEV_PREFIX="$TEST_BASE_DIR/filedev"
typeset altroot="$TESTDIR/altroot-$TESTPOOL2"