Add zfs module feature and property info to sysfs

This extends our sysfs '/sys/module/zfs' entry to include feature 
and property attributes. The primary consumer of this information 
is user processes, like the zfs CLI, that need to know what the 
current loaded ZFS module supports. The libzfs binary will consult 
this information when instantiating the zfs and zpool property 
tables and the pool features table.

This introduces 4 kernel objects (dirs) into '/sys/module/zfs'
with corresponding attributes (files):
  features.runtime
  features.pool
  properties.dataset
  properties.pool

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Don Brady <don.brady@delphix.com>
Closes #7706
This commit is contained in:
Don Brady
2018-09-02 15:09:53 -04:00
committed by Brian Behlendorf
parent bb91178e60
commit e8bcb693d6
24 changed files with 1183 additions and 1 deletions
@@ -28,6 +28,7 @@ SUBDIRS = \
zfs_set \
zfs_share \
zfs_snapshot \
zfs_sysfs \
zfs_unload-key \
zfs_unmount \
zfs_unshare \
@@ -0,0 +1,10 @@
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/cli_root/zfs_sysfs
dist_pkgdata_SCRIPTS = \
setup.ksh \
cleanup.ksh \
zfeature_set_unsupported.ksh \
zfs_get_unsupported.ksh \
zfs_set_unsupported.ksh \
zfs_sysfs_live.ksh \
zpool_get_unsupported.ksh \
zpool_set_unsupported.ksh
@@ -0,0 +1,30 @@
#!/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
default_cleanup
@@ -0,0 +1,32 @@
#!/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
DISK=${DISKS%% *}
default_container_volume_setup $DISK
@@ -0,0 +1,54 @@
#!/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 (c) 2018 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# A feature not supported by the zfs module should fail in 'zpool set <feature>'
#
# STRATEGY:
# 1. Run zpool set <featureprop> with env var 'ZFS_SYSFS_PROP_SUPPORT_TEST'
# 2. Verify that zpool set returns error
#
verify_runnable "global"
if ! is_linux ; then
log_unsupported "sysfs is linux-only"
fi
claim="Features not supported by zfs module should fail in 'zpool set <feature>'"
unsupported_feature="feature@large_blocks"
value="enabled"
log_assert $claim
log_mustnot eval "ZFS_SYSFS_PROP_SUPPORT_TEST=yes zpool set \
${unsupported_feature}=${value} $TESTPOOL/$TESTFS >/dev/null 2>&1"
log_pass $claim
@@ -0,0 +1,53 @@
#!/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 (c) 2018 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# A property not supported by the zfs module should fail in 'zfs get <prop>'
#
# STRATEGY:
# 1. Run zfs get <prop> with the env variable 'ZFS_SYSFS_PROP_SUPPORT_TEST'
# 2. Verify that zfs get returns error
#
verify_runnable "global"
if ! is_linux ; then
log_unsupported "sysfs is linux-only"
fi
claim="Properties not supported by zfs module should fail in 'zfs get <prop>'"
unsupported_prop="dnodesize"
log_assert $claim
log_mustnot eval "ZFS_SYSFS_PROP_SUPPORT_TEST=yes zfs get ${unsupported_prop} \
$TESTPOOL/$TESTFS >/dev/null 2>&1"
log_pass $claim
@@ -0,0 +1,54 @@
#!/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 (c) 2018 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# A property not supported by the zfs module should fail in 'zfs set <prop>'
#
# STRATEGY:
# 1. Run zfs set <prop> with the env variable 'ZFS_SYSFS_PROP_SUPPORT_TEST'
# 2. Verify that zfs get returns error
#
verify_runnable "global"
if ! is_linux ; then
log_unsupported "sysfs is linux-only"
fi
claim="Properties not supported by zfs module should fail in 'zfs set <prop>'"
unsupported_prop="dnodesize"
value="any"
log_assert $claim
log_mustnot eval "ZFS_SYSFS_PROP_SUPPORT_TEST=yes zfs set \
${unsupported_prop}=${value} $TESTPOOL/$TESTFS >/dev/null 2>&1"
log_pass $claim
@@ -0,0 +1,57 @@
#!/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 (c) 2018 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# Test if the expected '/sys/module/zfs/<dir>/<attr>' are present
#
verify_runnable "global"
if ! is_linux ; then
log_unsupported "sysfs is linux-only"
fi
claim="Expected '/sys/module/zfs/<dir>/<attr>' attributes are present"
feature_attr="/sys/module/zfs/features.pool/org.open-zfs:large_blocks/guid"
pool_prop__attr="/sys/module/zfs/properties.pool/comment/values"
ds_prop__attr="/sys/module/zfs/properties.dataset/recordsize/values"
log_assert $claim
log_must cat $feature_attr
log_must cat $pool_prop__attr
log_must cat $ds_prop__attr
# force a read of all the attributes for show func code coverage
log_must grep -R "[a-z]" /sys/module/zfs/features.*
log_must grep -R "[a-z]" /sys/module/zfs/properties.*
log_mustnot grep -RE "[^[:print:]]" /sys/module/zfs/properties.*
log_pass $claim
@@ -0,0 +1,55 @@
#!/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 (c) 2018 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# A property not supported by the zfs module should fail in 'zpool get <prop>'
#
# STRATEGY:
# 1. Run zpool get <prop> with the env variable 'ZFS_SYSFS_PROP_SUPPORT_TEST'
# 2. Verify that zfs get returns error
#
verify_runnable "global"
if ! is_linux ; then
log_unsupported "sysfs is linux-only"
fi
export ZFS_SYSFS_PROP_SUPPORT_TEST
claim="Properties not supported by zfs module should fail in 'zpool get <prop>'"
unsupported_prop="comment"
log_assert $claim
log_mustnot eval "ZFS_SYSFS_PROP_SUPPORT_TEST=yes zpool get \
${unsupported_prop} $TESTPOOL/$TESTFS >/dev/null 2>&1"
log_pass $claim
@@ -0,0 +1,54 @@
#!/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 (c) 2018 by Delphix. All rights reserved.
#
. $STF_SUITE/include/libtest.shlib
#
# DESCRIPTION:
# A property not supported by the zfs module should fail in 'zpool set <prop>'
#
# STRATEGY:
# 1. Run zpool set <prop> with the env variable 'ZFS_SYSFS_PROP_SUPPORT_TEST'
# 2. Verify that zpool set returns error
#
verify_runnable "global"
if ! is_linux ; then
log_unsupported "sysfs is linux-only"
fi
claim="Properties not supported by zfs module should fail in 'zpool set <prop>'"
unsupported_prop="comment"
value="You Shall Not Pass"
log_assert $claim
log_mustnot eval "ZFS_SYSFS_PROP_SUPPORT_TEST=yes zpool set \
${unsupported_prop}=${value} $TESTPOOL/$TESTFS >/dev/null 2>&1"
log_pass $claim